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