Skip to content

Commit 28c8f12

Browse files
committed
Merge pull request #5 from gavinrogers/feature-nginx
Feature nginx
2 parents a3c5214 + 539b45e commit 28c8f12

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

README.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ as this module requires the passenger apache module.
1313

1414
Requires the following modules from puppetforge: [stdlib](https://forge.puppetlabs.com/puppetlabs/stdlib), [apache](https://forge.puppetlabs.com/puppetlabs/apache), [concat](https://forge.puppetlabs.com/puppetlabs/concat), [inifile](https://forge.puppetlabs.com/puppetlabs/inifile)
1515

16+
1617
## Usage Note ##
1718

1819
If you are using this module to install a puppetmaster and serving the manifest of
@@ -58,7 +59,7 @@ Optionally, an `environmentpath` parameter can be supplied to configure the base
5859
webserver => 'nginx'
5960
}
6061

61-
The default installed webserver is httpd with passenger, but via the webserver param you can switch to nginx with unicorn (nginx is currently only tested on centos7, testers are welcome)
62+
The default installed webserver is httpd with passenger, but via the webserver param you can switch to nginx with unicorn (nginx is currently only tested on centos7, testers are welcome). Note that if you have selinux enabled, you must have [this](https://github.com/gavinrogers/puppet-selinux) selinux module installed.
6263

6364
## Agent ##
6465
class { 'puppet::agent':

manifests/master.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
nginx: {
139139
Anchor['puppet::master::begin'] ->
140140
class {'puppet::unicorn':
141+
certname => $certname,
142+
puppet_conf => $puppet_conf,
143+
puppet_ssldir => $puppet_ssldir,
144+
dns_alt_names => $dns_alt_names,
141145
listen_address => $listen_address,
142146
puppet_proxy_port => $puppet_proxy_port,
143147
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,
@@ -82,36 +86,39 @@
8286
}
8387
# update SELinux
8488
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'
9991
}
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'),
11395
}
11496
}
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+
115122
# hacky vhost
116123
file {'puppetmaster-vhost':
117124
path => '/etc/nginx/sites-available/puppetmaster',

0 commit comments

Comments
 (0)