Skip to content

Commit a733330

Browse files
author
Joshua Hoblitt
committed
add certdir param to nssdb::create type
Defaults to the type's title.
1 parent 729396f commit a733330

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

manifests/create.pp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Create an empty NSS database with a password file.
22
#
33
# Parameters:
4-
# $owner - required - the file/directory user
5-
# $group - required - the file/directory group
6-
# $password - required - password to set on the database
7-
# $mode - optional - defaults to '0600'
8-
# $certdir_mode - optional - defaults to '0700'
4+
# $owner - required - the file/directory user
5+
# $group - required - the file/directory group
6+
# $password - required - password to set on the database
7+
# $certdir - optional - defaults to title
8+
# $mode - optional - defaults to '0600'
9+
# $certdir_mode - optional - defaults to '0700'
910
#
1011
# Actions:
1112
# creates a new NSS database, consisting of 4 files:
@@ -29,21 +30,21 @@
2930
$owner,
3031
$group,
3132
$password,
33+
$certdir = $title,
3234
$mode = '0600',
3335
$certdir_mode = '0700',
3436
$manage_certdir = true
3537
) {
3638
include nssdb
3739

38-
validate_absolute_path($title)
39-
$certdir = $title
40+
validate_absolute_path($certdir)
4041

4142
if $manage_certdir {
4243
file { $certdir:
43-
ensure => directory,
44-
mode => $certdir_mode,
45-
owner => $owner,
46-
group => $group,
44+
ensure => directory,
45+
mode => $certdir_mode,
46+
owner => $owner,
47+
group => $group,
4748
}
4849

4950
$require_certdir = File[$certdir]

spec/defines/nssdb_create_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@
6969
end # default params
7070

7171
context 'all params' do
72-
let(:title) { '/obsolete' }
72+
# when certdir is set, title should not have to be an absolute path
73+
let(:title) { 'foo' }
7374
let(:params) do
7475
{
76+
:certdir => '/obsolete',
7577
:owner => 'nobody',
7678
:group => 'nobody',
7779
:mode => '0660',
@@ -104,15 +106,15 @@
104106
:owner => 'nobody',
105107
:group => 'nobody',
106108
:mode => '0660',
107-
:require => [ 'File[/obsolete/password.conf]', 'Exec[create_nss_db_/obsolete]']
109+
:require => [ 'File[/obsolete/password.conf]', 'Exec[create_nss_db_foo]']
108110
)
109111
end
110112
end
111113
end
112114

113115
context 'create nss db' do
114116
it do
115-
should contain_exec('create_nss_db_/obsolete').with(
117+
should contain_exec('create_nss_db_foo').with(
116118
:command => %r{-d /obsolete -f /obsolete},
117119
:creates => [
118120
'/obsolete/cert8.db',

0 commit comments

Comments
 (0)