Skip to content

Commit d8dbfb3

Browse files
committed
Add new flag to make ssl cert generation optional
1 parent fcf99d7 commit d8dbfb3

File tree

2 files changed

+52
-40
lines changed

2 files changed

+52
-40
lines changed

manifests/master.pp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
# ['puppetdb_startup_timeout'] - The timeout for puppetdb
3333
# ['dns_alt_names'] - Comma separated list of alternative DNS names
3434
# ['digest_algorithm'] - The algorithm to use for file digests.
35+
# ['generate_ssl_certs'] - Generate ssl certs (false to disable)
3536
#
3637
# Requires:
3738
#
@@ -83,6 +84,7 @@
8384
$puppetdb_strict_validation = $::puppet::params::puppetdb_strict_validation,
8485
$dns_alt_names = ['puppet'],
8586
$digest_algorithm = $::puppet::params::digest_algorithm,
87+
$generate_ssl_certs = true,
8688
) inherits puppet::params {
8789

8890
anchor { 'puppet::master::begin': }
@@ -121,14 +123,15 @@
121123

122124
Anchor['puppet::master::begin'] ->
123125
class {'puppet::passenger':
124-
puppet_passenger_port => $puppet_passenger_port,
125-
puppet_docroot => $puppet_docroot,
126-
apache_serveradmin => $apache_serveradmin,
127-
puppet_conf => $::puppet::params::puppet_conf,
128-
puppet_ssldir => $puppet_ssldir,
129-
certname => $certname,
130-
conf_dir => $::puppet::params::confdir,
131-
dns_alt_names => join($dns_alt_names,','),
126+
puppet_passenger_port => $puppet_passenger_port,
127+
puppet_docroot => $puppet_docroot,
128+
apache_serveradmin => $apache_serveradmin,
129+
puppet_conf => $::puppet::params::puppet_conf,
130+
puppet_ssldir => $puppet_ssldir,
131+
certname => $certname,
132+
conf_dir => $::puppet::params::confdir,
133+
dns_alt_names => join($dns_alt_names,','),
134+
generate_ssl_certs => $generate_ssl_certs,
132135
} ->
133136
Anchor['puppet::master::end']
134137

manifests/passenger.pp

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This class installs and configures the puppetdb terminus pacakge
44
#
55
# Parameters:
6+
# ['generate_ssl_certs'] - Generate ssl certs (false to disable)
67
# ['puppet_passenger_port'] - The port for the virtual host
78
# ['puppet_docroot'] - Apache documnet root
89
# ['apache_serveradmin'] - The apache server admin
@@ -31,6 +32,7 @@
3132
# }
3233
#
3334
class puppet::passenger(
35+
$generate_ssl_certs = true,
3436
$puppet_passenger_port,
3537
$puppet_docroot,
3638
$apache_serveradmin,
@@ -52,43 +54,50 @@
5254
group => $::puppet::params::puppet_group,
5355
mode => '0750',
5456
}
57+
}
5558

56-
file{"${puppet_ssldir}/ca":
57-
ensure => directory,
58-
owner => $::puppet::params::puppet_user,
59-
group => $::puppet::params::puppet_group,
60-
mode => '0770',
61-
before => Exec['Certificate_Check'],
62-
}
59+
if str2bool($generate_ssl_certs) == true {
60+
61+
if $::osfamily == 'redhat' {
62+
63+
file{"${puppet_ssldir}/ca":
64+
ensure => directory,
65+
owner => $::puppet::params::puppet_user,
66+
group => $::puppet::params::puppet_group,
67+
mode => '0770',
68+
before => Exec['Certificate_Check'],
69+
}
70+
71+
file{"${puppet_ssldir}/ca/requests":
72+
ensure => directory,
73+
owner => $::puppet::params::puppet_user,
74+
group => $::puppet::params::puppet_group,
75+
mode => '0750',
76+
before => Exec['Certificate_Check'],
77+
}
6378

64-
file{"${puppet_ssldir}/ca/requests":
65-
ensure => directory,
66-
owner => $::puppet::params::puppet_user,
67-
group => $::puppet::params::puppet_group,
68-
mode => '0750',
69-
before => Exec['Certificate_Check'],
7079
}
71-
}
80+
# first we need to generate the cert
81+
# Clean the installed certs out ifrst
82+
$crt_clean_cmd = "puppet cert clean ${certname}"
83+
# I would have preferred to use puppet cert generate, but it does not
84+
# return the corret exit code on some versions of puppet
85+
$crt_gen_cmd = "puppet certificate --ca-location=local --dns_alt_names=$dns_alt_names generate ${certname}"
86+
# I am using the sign command here b/c AFAICT, the sign command for certificate
87+
# does not work
88+
$crt_sign_cmd = "puppet cert sign --allow-dns-alt-names ${certname}"
89+
# find is required to move the cert into the certs directory which is
90+
# where it needs to be for puppetdb to find it
91+
$cert_find_cmd = "puppet certificate --ca-location=local find ${certname}"
7292

73-
# first we need to generate the cert
74-
# Clean the installed certs out ifrst
75-
$crt_clean_cmd = "puppet cert clean ${certname}"
76-
# I would have preferred to use puppet cert generate, but it does not
77-
# return the corret exit code on some versions of puppet
78-
$crt_gen_cmd = "puppet certificate --ca-location=local --dns_alt_names=$dns_alt_names generate ${certname}"
79-
# I am using the sign command here b/c AFAICT, the sign command for certificate
80-
# does not work
81-
$crt_sign_cmd = "puppet cert sign --allow-dns-alt-names ${certname}"
82-
# find is required to move the cert into the certs directory which is
83-
# where it needs to be for puppetdb to find it
84-
$cert_find_cmd = "puppet certificate --ca-location=local find ${certname}"
93+
exec { 'Certificate_Check':
94+
command => "${crt_clean_cmd} ; ${crt_gen_cmd} && ${crt_sign_cmd} && ${cert_find_cmd}",
95+
unless => "/bin/ls ${puppet_ssldir}/certs/${certname}.pem",
96+
path => '/usr/bin:/usr/local/bin',
97+
logoutput => on_failure,
98+
require => File[$puppet_conf]
99+
}
85100

86-
exec { 'Certificate_Check':
87-
command => "${crt_clean_cmd} ; ${crt_gen_cmd} && ${crt_sign_cmd} && ${cert_find_cmd}",
88-
unless => "/bin/ls ${puppet_ssldir}/certs/${certname}.pem",
89-
path => '/usr/bin:/usr/local/bin',
90-
logoutput => on_failure,
91-
require => File[$puppet_conf]
92101
}
93102

94103
file { $puppet_docroot:

0 commit comments

Comments
 (0)