Skip to content

Commit

Permalink
rename module from nssdb -> nsstools
Browse files Browse the repository at this point in the history
To avoid a namespace conflict with the module this one was initially
forked from and has since become highly diverged.
  • Loading branch information
Joshua Hoblitt committed Feb 10, 2014
1 parent 258a04e commit c31de09
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ fixtures:
ref: '4.0.0'
'openssl': 'https://github.com/camptocamp/puppet-openssl.git'
symlinks:
nssdb: "#{source_dir}"
nsstools: "#{source_dir}"
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright 2013 Red Hat, Inc.
Copyright (C) 2014 Joshua Hoblitt <jhoblitt@cpan.org>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
13 changes: 7 additions & 6 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name 'rcritten/nssdb'
name 'jhoblitt/nsstools'
version '1.0.0'
source 'git://github.com/rcritten/puppet-nssdb.git'
author 'Rob Crittenden <rcritten@redhat.com>'

author 'Joshua Hoblitt <jhoblitt@cpan.org>'
license 'Apache'
summary 'NSS database Puppet Module'
description 'This module manages NSS databases.'
project_page 'https://github.com/rcritten/puppet-nssdb'
project_page 'https://github.com/jhoblitt/puppet-nsstools'
source 'git://github.com/jhoblitt/puppet-nsstools.git'
summary 'Manages NSS X.509 certificate databases.'
description 'Manages NSS X.509 certificate databases.'

dependency 'puppetlabs/stdlib', '>= 4.0.0'
dependency 'camptocamp/openssl', '>= 0.1.0'
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# nssdb puppet module
# nsstools puppet module

very simple puppet module to create an NSS database and add a certificate
and key via PEM files.

## Example of setting up 389 ds certs

```
nssdb::create { '/etc/dirsrv/slapd-ldap1':
nsstools::create { '/etc/dirsrv/slapd-ldap1':
owner => 'nobody',
group => 'nobody',
mode => '0660',
password => 'example',
manage_certdir => false,
}
nssdb::add_cert_and_key{ 'Server-Cert':
nsstools::add_cert_and_key{ 'Server-Cert':
certdir => '/etc/dirsrv/slapd-ldap1',
cert => '/tmp/foo.pem',
key => '/tmp/foo.key',
}
nssdb::add_cert { 'AlphaSSL CA':
nsstools::add_cert { 'AlphaSSL CA':
certdir => '/etc/dirsrv/slapd-ldap1',
cert => '/tmp/alphassl_intermediate.pem',
}
nssdb::add_cert { 'GlobalSign Root CA':
nsstools::add_cert { 'GlobalSign Root CA':
certdir => '/etc/dirsrv/slapd-ldap1',
cert => '/tmp/globalsign_root.pem',
}
Expand Down
10 changes: 5 additions & 5 deletions manifests/add_cert.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@
#
# Sample Usage:
#
# nssdb::add_cert { '/tmp/server.crt':
# nsstools::add_cert { '/tmp/server.crt':
# nickname => 'GlobalSign Root CA',
# certdir => '/etc/pki/foo',
# }
#
define nssdb::add_cert(
define nsstools::add_cert(
$certdir,
$cert,
$nickname = $title,
$trustargs = 'CT,,'
) {
include nssdb
include nsstools

exec { "add_cert_${title}":
path => ['/usr/bin'],
command => "certutil -d ${certdir} -A -n '${nickname}' -t '${trustargs}' -a -i ${cert}",
unless => "certutil -d ${certdir} -L -n '${nickname}'",
logoutput => true,
require => [
Nssdb::Create[$certdir],
Class['nssdb'],
Nsstools::Create[$certdir],
Class['nsstools'],
],
}
}
14 changes: 7 additions & 7 deletions manifests/add_cert_and_key.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
#
# Sample Usage:
#
# nssdb::add_cert_and_key{ 'Server-Cert':
# nsstools::add_cert_and_key{ 'Server-Cert':
# certdir => '/dne',
# cert => '/tmp/server.crt',
# key => '/tmp/server.key',
# }
#
define nssdb::add_cert_and_key (
define nsstools::add_cert_and_key (
$certdir,
$cert,
$key,
$nickname = $title
) {
include nssdb
include nsstools

# downcase and change spaces into _s
$pkcs12_name = downcase(regsubst("${nickname}.p12", '[\s]', '_', 'GM'))
Expand All @@ -39,8 +39,8 @@
creates => "${certdir}/${pkcs12_name}",
subscribe => File["${certdir}/nss-password.txt"],
require => [
Nssdb::Create[$certdir],
Class['nssdb'],
Nsstools::Create[$certdir],
Class['nsstools'],
],
}

Expand All @@ -51,8 +51,8 @@
logoutput => true,
require => [
Exec["generate_pkcs12_${title}"],
Nssdb::Create[$certdir],
Class['nssdb'],
Nsstools::Create[$certdir],
Class['nsstools'],
],
}

Expand Down
8 changes: 4 additions & 4 deletions manifests/create.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
#
# Sample Usage:
#
# nssdb::create {'test':
# nsstools::create {'test':
# owner => 'qpidd',
# group => 'qpidd',
# password => 'test'}
#
# This will create an NSS database in /etc/pki/test
#
define nssdb::create (
define nsstools::create (
$owner,
$group,
$password,
Expand All @@ -35,7 +35,7 @@
$certdir_mode = '0700',
$manage_certdir = true
) {
include nssdb
include nsstools

validate_absolute_path($certdir)

Expand Down Expand Up @@ -82,7 +82,7 @@
creates => ["${certdir}/cert8.db", "${certdir}/key3.db", "${certdir}/secmod.db"],
require => [
File["${certdir}/nss-password.txt"],
Class['nssdb'],
Class['nsstools'],
]
}
}
14 changes: 7 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# utility class
class nssdb (
class nsstools (
$require_openssl = true,
) {
validate_bool($require_openssl)

include nssdb::params
ensure_packages($::nssdb::params::package_name)
include nsstools::params
ensure_packages($::nsstools::params::package_name)

if $require_openssl {
include openssl

Class['openssl'] ->
Anchor['nssdb::begin']
Anchor['nsstools::begin']
}

anchor{ 'nssdb::begin': } ->
Package[$::nssdb::params::package_name] ->
anchor{ 'nssdb::end': }
anchor{ 'nsstools::begin': } ->
Package[$::nsstools::params::package_name] ->
anchor{ 'nsstools::end': }
}
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this class should be considered private
class nssdb::params {
class nsstools::params {
case $::osfamily {
'redhat': {
$package_name = ['nss-tools']
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/nssdb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'spec_helper'

describe 'nssdb', :type => :class do
describe 'nsstools', :type => :class do
describe 'on osfamily RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'default params' do
# rspec-puppet relationship matchers seem to be buggy in 1.0.1
# it { should contain_class('openssl').that_comes_before('Class[nssdb]') }
# it { should contain_class('openssl').that_comes_before('Class[nsstools]') }
it { should contain_class('openssl') }
it { should contain_package('nss-tools') }
end # default params
Expand All @@ -30,7 +30,7 @@
let(:params) {{ :require_openssl => 'foo' }}

it 'should fail' do
expect { should contain_class('nssdb') }.
expect { should contain_class('nsstools') }.
to raise_error(/not a boolean./)
end
end
Expand Down
18 changes: 9 additions & 9 deletions spec/defines/nssdb_add_cert_and_key_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'nssdb::add_cert_and_key', :type => :define do
describe 'nsstools::add_cert_and_key', :type => :define do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'default params' do
Expand All @@ -18,8 +18,8 @@
should contain_exec('generate_pkcs12_Server-Cert').with(
:command => "/usr/bin/openssl pkcs12 -export -in /tmp/server.cert -inkey /tmp/server.key -password 'file:/dne/nss-password.txt' -out '/dne/server-cert.p12' -name 'Server-Cert'",
:require => [
'Nssdb::Create[/dne]',
'Class[Nssdb]'
'Nsstools::Create[/dne]',
'Class[Nsstools]'
],
:creates => '/dne/server-cert.p12',
:subscribe => 'File[/dne/nss-password.txt]'
Expand All @@ -36,8 +36,8 @@
:logoutput => true,
:require => [
'Exec[generate_pkcs12_Server-Cert]',
'Nssdb::Create[/dne]',
'Class[Nssdb]'
'Nsstools::Create[/dne]',
'Class[Nsstools]'
]
)
end
Expand All @@ -60,8 +60,8 @@
should contain_exec('generate_pkcs12_foo').with(
:command => "/usr/bin/openssl pkcs12 -export -in /tmp/server.cert -inkey /tmp/server.key -password 'file:/dne/nss-password.txt' -out '/dne/server-cert.p12' -name 'Server-Cert'",
:require => [
'Nssdb::Create[/dne]',
'Class[Nssdb]'
'Nsstools::Create[/dne]',
'Class[Nsstools]'
],
:creates => '/dne/server-cert.p12',
:subscribe => 'File[/dne/nss-password.txt]'
Expand All @@ -78,8 +78,8 @@
:logoutput => true,
:require => [
'Exec[generate_pkcs12_foo]',
'Nssdb::Create[/dne]',
'Class[Nssdb]'
'Nsstools::Create[/dne]',
'Class[Nsstools]'
]
)
end
Expand Down
10 changes: 5 additions & 5 deletions spec/defines/nssdb_add_cert_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'nssdb::add_cert', :type => :define do
describe 'nsstools::add_cert', :type => :define do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'default params' do
Expand All @@ -20,8 +20,8 @@
:unless => "certutil -d /dne -L -n 'GlobalSign Root CA'",
:logoutput => true,
:require => [
'Nssdb::Create[/dne]',
'Class[Nssdb]'
'Nsstools::Create[/dne]',
'Class[Nsstools]'
]
)
end
Expand All @@ -47,8 +47,8 @@
:unless => "certutil -d /dne -L -n 'GlobalSign Root CA'",
:logoutput => true,
:require => [
'Nssdb::Create[/dne]',
'Class[Nssdb]'
'Nsstools::Create[/dne]',
'Class[Nsstools]'
]
)
end
Expand Down
10 changes: 5 additions & 5 deletions spec/defines/nssdb_create_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'nssdb::create', :type => :define do
describe 'nsstools::create', :type => :define do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'default params' do
Expand All @@ -13,7 +13,7 @@
}
end

context 'nssdb directory' do
context 'nsstools directory' do
it do
should contain_file('/obsolete').with(
:owner => 'nobody',
Expand Down Expand Up @@ -63,7 +63,7 @@
],
:require => [
'File[/obsolete/nss-password.txt]',
'Class[Nssdb]'
'Class[Nsstools]'
]
)
end
Expand All @@ -85,7 +85,7 @@
}
end

context 'nssdb directory' do
context 'nsstools directory' do
it { should_not contain_file('/obsolete') }
end

Expand Down Expand Up @@ -125,7 +125,7 @@
],
:require => [
'File[/obsolete/nss-password.txt]',
'Class[Nssdb]'
'Class[Nsstools]'
]
)
end
Expand Down
12 changes: 6 additions & 6 deletions tests/create.pp
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# NOTE: This requires that the directory /tmp/nssdb already exists
# NOTE: This requires that the directory /tmp/nsstools already exists

# Create a test database owned by the user rcrit
nssdb::create { '/tmp/nssdb':
nsstools::create { '/tmp/nsstools':
owner => 'rcrit',
group => 'rcrit',
password => 'test',
}

# Add a certificate and private key from PEM fiels
nssdb::add_cert_and_key { 'test':
certdir => '/tmp/nssdb',
nsstools::add_cert_and_key { 'test':
certdir => '/tmp/nsstools',
cert => '/tmp/cert.pem',
key => '/tmp/key.pem',
}

# You can confirm that things are loaded properly with:
#
# List the certs:
# certutil -L -d /tmp/nssdb/test
# certutil -L -d /tmp/nsstools/test
#
# Verify the cert:
# certutil -V -u V -d /tmp/nssdb/test -n test
# certutil -V -u V -d /tmp/nsstools/test -n test

0 comments on commit c31de09

Please sign in to comment.