Skip to content

Commit 4fcbb4b

Browse files
Merge pull request #37 from jyundt/master
Added support for dns_alt_names.
2 parents d90fa03 + 5263996 commit 4fcbb4b

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

Modulefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ project_page 'https://github.com/stephenrjohnson/puppetlabs-puppet'
1010
dependency 'puppetlabs/inifile', '>= 1.0.0'
1111
dependency 'puppetlabs/apache', '>= 0.8.0'
1212
dependency 'puppetlabs/puppetdb', '>= 2.0.0'
13+
dependency 'puppetlabs/stdlib', '>= 3.0.0'

manifests/master.pp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
# ['pluginsync'] - Enable plugin sync
2727
# ['parser'] - Which parser to use
2828
# ['puppetdb_startup_timeout'] - The timeout for puppetdb
29+
# ['dns_alt_names'] - Comma separated list of alternative DNS names
2930
#
3031
# Requires:
3132
#
@@ -70,7 +71,8 @@
7071
$pluginsync = true,
7172
$parser = $::puppet::params::parser,
7273
$puppetdb_startup_timeout = '60',
73-
$puppetdb_strict_validation = $::puppet::params::puppetdb_strict_validation
74+
$puppetdb_strict_validation = $::puppet::params::puppetdb_strict_validation,
75+
$dns_alt_names = ['puppet'],
7476
) inherits puppet::params {
7577

7678
anchor { 'puppet::master::begin': }
@@ -116,6 +118,7 @@
116118
puppet_ssldir => $::puppet::params::puppet_ssldir,
117119
certname => $certname,
118120
conf_dir => $::puppet::params::confdir,
121+
dns_alt_names => join($dns_alt_names,","),
119122
} ->
120123
Anchor['puppet::master::end']
121124

@@ -244,5 +247,11 @@
244247
}
245248
}
246249

250+
ini_setting {'puppetmasterdnsaltnames':
251+
ensure => present,
252+
setting => 'dns_alt_names',
253+
value => join($dns_alt_names, ","),
254+
}
255+
247256
anchor { 'puppet::master::end': }
248257
}

manifests/passenger.pp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
$puppet_conf,
3838
$puppet_ssldir,
3939
$certname,
40-
$conf_dir
40+
$conf_dir,
41+
$dns_alt_names
4142
){
4243
include apache
4344
include puppet::params
@@ -74,7 +75,7 @@
7475
$crt_clean_cmd = "puppet cert clean ${certname}"
7576
# I would have preferred to use puppet cert generate, but it does not
7677
# return the corret exit code on some versions of puppet
77-
$crt_gen_cmd = "puppet certificate --ca-location=local --dns_alt_names=puppet generate ${certname}"
78+
$crt_gen_cmd = "puppet certificate --ca-location=local --dns_alt_names=$dns_alt_names generate ${certname}"
7879
# I am using the sign command here b/c AFAICT, the sign command for certificate
7980
# does not work
8081
$crt_sign_cmd = "puppet cert sign --allow-dns-alt-names ${certname}"

spec/classes/puppet_master_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
:autosign => 'true',
2222
:certname => 'test.example.com',
2323
:storeconfigs => 'true',
24-
:storeconfigs_dbserver => 'test.example.com'
24+
:storeconfigs_dbserver => 'test.example.com',
25+
:dns_alt_names => ['puppet']
2526

2627
}
2728
end
@@ -128,6 +129,13 @@
128129
:path => '/etc/puppet/puppet.conf',
129130
:value => 'true'
130131
)
132+
should contain_ini_setting('puppetmasterdnsaltnames').with(
133+
:ensure => 'present',
134+
:section => 'master',
135+
:setting => 'dns_alt_names',
136+
:path => '/etc/puppet/puppet.conf',
137+
:value => params[:dns_alt_names].join(',')
138+
)
131139
should contain_anchor('puppet::master::begin').with_before(
132140
['Class[Puppet::Passenger]', 'Class[Puppet::Storeconfigs]']
133141
)
@@ -154,7 +162,8 @@
154162
:autosign => 'true',
155163
:certname => 'test.example.com',
156164
:storeconfigs => 'true',
157-
:storeconfigs_dbserver => 'test.example.com'
165+
:storeconfigs_dbserver => 'test.example.com',
166+
:dns_alt_names => ['puppet']
158167

159168
}
160169
end
@@ -260,6 +269,13 @@
260269
:path => '/etc/puppet/puppet.conf',
261270
:value => 'true'
262271
)
272+
should contain_ini_setting('puppetmasterdnsaltnames').with(
273+
:ensure => 'present',
274+
:section => 'master',
275+
:setting => 'dns_alt_names',
276+
:path => '/etc/puppet/puppet.conf',
277+
:value => params[:dns_alt_names].join(',')
278+
)
263279
should contain_anchor('puppet::master::begin').with_before(
264280
['Class[Puppet::Passenger]', 'Class[Puppet::Storeconfigs]']
265281
)

spec/classes/puppet_passenger_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
:puppet_ssldir => '/var/lib/puppet/ssl',
1111
:certname => 'test.test.com',
1212
:conf_dir => '/etc/puppet',
13+
:dns_alt_names => ['puppet'],
1314
}
1415
end
1516
context 'on Debian' do
@@ -29,7 +30,7 @@
2930
should contain_exec('Certificate_Check').with(
3031
:command =>
3132
"puppet cert clean #{params[:certname]} ; " +
32-
"puppet certificate --ca-location=local --dns_alt_names=puppet generate #{params[:certname]}" +
33+
"puppet certificate --ca-location=local --dns_alt_names=#{params[:dns_alt_names].join(',')} generate #{params[:certname]}" +
3334
" && puppet cert sign --allow-dns-alt-names #{params[:certname]}" +
3435
" && puppet certificate --ca-location=local find #{params[:certname]}",
3536
:unless => "/bin/ls #{params[:puppet_ssldir]}/certs/#{params[:certname]}.pem",

spec/spec_helper_system.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
shell('puppet module install puppetlabs-inifile --version ">= 1.0.0"')
2525
shell('puppet module install puppetlabs-apache --version ">= 0.8.0"')
2626
shell('puppet module install puppetlabs-puppetdb --version ">= 2.0.0"')
27+
shell('puppet module install puppetlabs-stdlib --version ">= 3.0.0"')
2728
if node.facts['osfamily'] == 'Debian'
2829
shell('puppet module install puppetlabs-apt')
2930
end

0 commit comments

Comments
 (0)