Skip to content

Commit 1e71832

Browse files
author
Gavin Rogers
committed
cert cleaning for unicorn
1 parent 7f201ad commit 1e71832

File tree

2 files changed

+38
-27
lines changed

2 files changed

+38
-27
lines changed

manifests/master.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@
134134
nginx: {
135135
Anchor['puppet::master::begin'] ->
136136
class {'puppet::unicorn':
137+
certname => $certname,
138+
puppet_conf => $puppet_conf,
139+
puppet_ssldir => $puppet_ssldir,
140+
dns_alt_names => $dns_alt_names,
137141
listen_address => $listen_address,
138142
puppet_proxy_port => $puppet_proxy_port,
139143
disable_ssl => $disable_ssl,

manifests/unicorn.pp

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
# with big help from Rob 'rnelson0' Nelson and the_scourge
2525

2626
class puppet::unicorn (
27+
$certname,
28+
$puppet_conf,
29+
$puppet_ssldir,
30+
$dns_alt_names,
2731
$listen_address,
2832
$puppet_proxy_port,
2933
$disable_ssl,
@@ -81,36 +85,39 @@
8185
}
8286
# update SELinux
8387
if $::selinux_config_mode == 'enforcing' {
84-
package {['policycoreutils', 'checkpolicy', 'policycoreutils-python']:
85-
ensure => 'latest',
86-
} ->
87-
file {'selinux template':
88-
path => '/tmp/nginx.te',
89-
ensure => file,
90-
content => template('puppet/unicorn_selinux_template'),
91-
notify => Exec['building_selinux_module_from_template'],
92-
}
93-
exec {'building_selinux_module_from_template':
94-
path => [ "/usr/bin", "/usr/local/bin" ],
95-
command => 'checkmodule -M -m -o /tmp/nginx.mod /tmp/nginx.te',
96-
refreshonly => true,
97-
notify => Exec['building_selinux_policy_package_from_module'],
88+
class { selinux:
89+
mode => 'enforcing'
9890
}
99-
exec {'building_selinux_policy_package_from_module':
100-
path => [ "/usr/bin", "/usr/local/bin" ],
101-
command => 'semodule_package -o /tmp/nginx.pp -m /tmp/nginx.mod',
102-
refreshonly => true,
103-
}
104-
file {'/usr/share/selinux/targeted/nginx.pp':
105-
source => 'file:///tmp/nginx.pp',
106-
notify => Exec['building_selinux_policy_package_from_module'],
107-
}
108-
selmodule {'nginx':
109-
ensure => 'present',
110-
syncversion => true,
111-
require => File['/usr/share/selinux/targeted/nginx.pp'],
91+
selinux::module{ 'nginx':
92+
ensure => 'present',
93+
content => template('puppet/unicorn_selinux_template'),
11294
}
11395
}
96+
97+
# first we need to generate the cert
98+
# Clean the installed certs out ifrst
99+
$crt_clean_cmd = "puppet cert clean ${certname}"
100+
# I would have preferred to use puppet cert generate, but it does not
101+
# return the corret exit code on some versions of puppet
102+
$crt_gen_cmd = "puppet certificate --ca-location=local --dns_alt_names=$dns_alt_names generate ${certname}"
103+
# I am using the sign command here b/c AFAICT, the sign command for certificate
104+
# does not work
105+
$crt_sign_cmd = "puppet cert sign --allow-dns-alt-names ${certname}"
106+
# find is required to move the cert into the certs directory which is
107+
# where it needs to be for puppetdb to find it
108+
$cert_find_cmd = "puppet certificate --ca-location=local find ${certname}"
109+
110+
exec { 'Certificate_Check':
111+
command => "${crt_clean_cmd} ; ${crt_gen_cmd} && ${crt_sign_cmd} && ${cert_find_cmd}",
112+
unless => "/bin/ls ${puppet_ssldir}/certs/${certname}.pem",
113+
path => '/usr/bin:/usr/local/bin',
114+
logoutput => on_failure,
115+
require => File[$puppet_conf]
116+
}
117+
118+
119+
120+
114121
# hacky vhost
115122
file {'puppetmaster-vhost':
116123
path => '/etc/nginx/sites-available/puppetmaster',

0 commit comments

Comments
 (0)