Skip to content

Commit 06d74a0

Browse files
author
Tim Meusel
committed
update nginx vhost template
now it is possible to specify an endless amount of remote puppet masters and to disable the local one (so it only acts as a master)
1 parent 28c8f12 commit 06d74a0

File tree

5 files changed

+47
-20
lines changed

5 files changed

+47
-20
lines changed

manifests/master.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
# ['unicorn_package'] - package name of a unicorn rpm. if provided we install it, otherwise we built it via gem/gcc
4040
# ['unicorn_path'] - custom path to the unicorn binary
4141
# ['generate_ssl_certs'] - Generate ssl certs (false to disable)
42+
# ['disable_master'] - this disables the normal master, the server will only act as a CA, currently only supported by nginx
43+
# ['upstream'] - define additional masters reachable via tcp as an array, currently only supported by nginx
4244
#
4345
# Requires:
4446
#
@@ -99,6 +101,8 @@
99101
$unicorn_package = $::puppet::params::unicorn_package,
100102
$generate_ssl_certs = true,
101103
$puppetdb_version = 'present',
104+
$disable_master = $::puppet::params::disable_master,
105+
$upstream = $::puppet::params::upstream,
102106
) inherits puppet::params {
103107

104108
anchor { 'puppet::master::begin': }
@@ -148,6 +152,8 @@
148152
backup_upstream => $backup_upstream,
149153
unicorn_package => $unicorn_package,
150154
unicorn_path => $unicorn_path,
155+
disable_master => $disable_master,
156+
upstream => $upstream,
151157
} ->
152158
Anchor['puppet::master::end']
153159
}

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
$backup_upstream = []
3838
$unicorn_package = undef
3939
$unicorn_path = '/usr/local/bin/unicorn'
40+
$disable_master = false
41+
$upstream = []
4042

4143
# Only used when environments == directory
4244
$environmentpath = "${confdir}/environments"

manifests/passenger.pp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
# This class installs and configures the puppetdb terminus pacakge
44
#
55
# Parameters:
6-
# ['puppet_proxy_port'] - The port for the virtual host
7-
# ['generate_ssl_certs'] - Generate ssl certs (false to disable)
8-
# ['puppet_docroot'] - Apache documnet root
9-
# ['apache_serveradmin'] - The apache server admin
10-
# ['puppet_conf'] - The puppet config dir
11-
# ['puppet_ssldir'] - The pupet ssl dir
12-
# ['certname'] - The puppet certname
13-
# [conf_dir] - The configuration directory of the puppet install
6+
# ['puppet_proxy_port'] - The port for the virtual host
7+
# ['generate_ssl_certs'] - Generate ssl certs (false to disable)
8+
# ['puppet_docroot'] - Apache documnet root
9+
# ['apache_serveradmin'] - The apache server admin
10+
# ['puppet_conf'] - The puppet config dir
11+
# ['puppet_ssldir'] - The pupet ssl dir
12+
# ['certname'] - The puppet certname
13+
# [conf_dir] - The configuration directory of the puppet install
1414
#
1515
# Actions:
1616
# - Configures apache and passenger for puppet master use.
@@ -45,7 +45,7 @@
4545
){
4646
include apache
4747
include puppet::params
48-
class { 'apache::mod::passenger': passenger_max_pool_size => 12, }
48+
class { '::apache::mod::passenger': passenger_max_pool_size => 12, }
4949
include apache::mod::ssl
5050

5151
if $::osfamily == 'redhat' {

manifests/unicorn.pp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
# Class: puppet::unicorn
22
#
33
# Parameters:
4-
# ['listen_address'] - IP for binding the webserver, defaults to *
5-
# ['puppet_proxy_port'] - The port for the virtual host
6-
# ['disable_ssl'] - Disables SSL on the webserver. usefull if you use this master behind a loadbalancer. currently only supported by nginx, defaults to undef
7-
# ['backup_upstream'] - specify another puppet master as fallback. currently only supported by nginx
8-
# ['unicorn_package'] - package name of a unicorn rpm. if provided we install it, otherwise we built it via gem/gcc
9-
# ['unicorn_path'] - custom path to the unicorn binary
4+
# ['certname'] -
5+
# ['puppet_conf'] -
6+
# ['puppet_ssldir'] -
7+
# ['dns_alt_names'] -
8+
# ['listen_address'] - IP for binding the webserver, defaults to *
9+
# ['puppet_proxy_port'] - The port for the virtual host
10+
# ['disable_ssl'] - Disables SSL on the webserver. usefull if you use this master behind a loadbalancer. currently only supported by nginx, defaults to undef
11+
# ['backup_upstream'] - specify several puppet master as fallback. currently only supported by nginx
12+
# ['unicorn_package'] - package name of a unicorn rpm. if provided we install it, otherwise we built it via gem/gcc
13+
# ['unicorn_path'] - custom path to the unicorn binary
14+
# ['disable_master'] - this disables the normal master, the server will only act as a CA
15+
# ['upstream'] - define additional masters reachable via tcp as an array
1016
#
1117
# Actions:
1218
# - Configures nginx and unicorn for puppet master use. Tested only on CentOS 7
19+
# - server can act as a simple LB with multiple puppet master backends and backups
1320
#
1421
# Requires:
1522
# - nginx
@@ -34,6 +41,8 @@
3441
$backup_upstream,
3542
$unicorn_package,
3643
$unicorn_path,
44+
$disable_master,
45+
$upstream,
3746
){
3847
class { '::nginx':
3948
worker_processes => $::processorcount,
@@ -96,10 +105,10 @@
96105
}
97106

98107
# first we need to generate the cert
99-
# Clean the installed certs out ifrst
108+
# Clean the installed certs out first
100109
$crt_clean_cmd = "puppet cert clean ${certname}"
101110
# I would have preferred to use puppet cert generate, but it does not
102-
# return the corret exit code on some versions of puppet
111+
# return the correct exit code on some versions of puppet
103112
$crt_gen_cmd = "puppet certificate --ca-location=local --dns_alt_names=$dns_alt_names generate ${certname}"
104113
# I am using the sign command here b/c AFAICT, the sign command for certificate
105114
# does not work
@@ -116,9 +125,6 @@
116125
require => File[$puppet_conf]
117126
}
118127

119-
120-
121-
122128
# hacky vhost
123129
file {'puppetmaster-vhost':
124130
path => '/etc/nginx/sites-available/puppetmaster',

templates/puppetmaster

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
# define the new unicorn backend
22
upstream puppetmaster_unicorn {
3+
<% unless @disable_master -%>
34
server unix:/var/run/puppet/puppetmaster_unicorn.sock fail_timeout=5;
5+
<% else -%>
6+
<% @upstream.each do |server| -%>
7+
server <%= server %>;
8+
<% end -%>
49
<% @backup_upstream.each do |server| -%>
510
server <%= server %> backup;
611
<% end -%>
712
}
813

14+
# define our CA server
15+
upstream puppetca {
16+
server unix:/var/run/puppet/puppetmaster_unicorn.sock;
17+
}
918
# define our proxy for breaking up SSL
1019
server {
1120
<% unless @disable_ssl -%>
@@ -33,6 +42,10 @@ server {
3342
proxy_pass http://puppetmaster_unicorn;
3443
proxy_redirect off;
3544
}
45+
location ~ ^/([^/]+/certificate.*)$ {
46+
proxy_pass http://puppetca;
47+
proxy_redirect off;
48+
}
3649
access_log /var/log/nginx/puppetmaster-access.log;
3750
error_log /var/log/nginx/puppetmaster-error.log;
3851
}

0 commit comments

Comments
 (0)