Skip to content

Commit

Permalink
add certdir param to nssdb::create type
Browse files Browse the repository at this point in the history
Defaults to the type's title.
  • Loading branch information
Joshua Hoblitt committed Feb 10, 2014
1 parent 729396f commit a733330
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
23 changes: 12 additions & 11 deletions manifests/create.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Create an empty NSS database with a password file.
#
# Parameters:
# $owner - required - the file/directory user
# $group - required - the file/directory group
# $password - required - password to set on the database
# $mode - optional - defaults to '0600'
# $certdir_mode - optional - defaults to '0700'
# $owner - required - the file/directory user
# $group - required - the file/directory group
# $password - required - password to set on the database
# $certdir - optional - defaults to title
# $mode - optional - defaults to '0600'
# $certdir_mode - optional - defaults to '0700'
#
# Actions:
# creates a new NSS database, consisting of 4 files:
Expand All @@ -29,21 +30,21 @@
$owner,
$group,
$password,
$certdir = $title,
$mode = '0600',
$certdir_mode = '0700',
$manage_certdir = true
) {
include nssdb

validate_absolute_path($title)
$certdir = $title
validate_absolute_path($certdir)

if $manage_certdir {
file { $certdir:
ensure => directory,
mode => $certdir_mode,
owner => $owner,
group => $group,
ensure => directory,
mode => $certdir_mode,
owner => $owner,
group => $group,
}

$require_certdir = File[$certdir]
Expand Down
8 changes: 5 additions & 3 deletions spec/defines/nssdb_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@
end # default params

context 'all params' do
let(:title) { '/obsolete' }
# when certdir is set, title should not have to be an absolute path
let(:title) { 'foo' }
let(:params) do
{
:certdir => '/obsolete',
:owner => 'nobody',
:group => 'nobody',
:mode => '0660',
Expand Down Expand Up @@ -104,15 +106,15 @@
:owner => 'nobody',
:group => 'nobody',
:mode => '0660',
:require => [ 'File[/obsolete/password.conf]', 'Exec[create_nss_db_/obsolete]']
:require => [ 'File[/obsolete/password.conf]', 'Exec[create_nss_db_foo]']
)
end
end
end

context 'create nss db' do
it do
should contain_exec('create_nss_db_/obsolete').with(
should contain_exec('create_nss_db_foo').with(
:command => %r{-d /obsolete -f /obsolete},
:creates => [
'/obsolete/cert8.db',
Expand Down

0 comments on commit a733330

Please sign in to comment.