Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Commit e19ca60

Browse files
committed
Merge pull request #102 from danieldreier/switch_nginx_modules
Switch to jfryman/nginx module
2 parents 067d7e3 + f91813f commit e19ca60

File tree

9 files changed

+104
-118
lines changed

9 files changed

+104
-118
lines changed

.fixtures.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ fixtures:
1111
unicorn: "git://github.com/puppetlabs-operations/puppet-unicorn.git"
1212
rack: "git://github.com/puppetlabs-operations/puppet-rack.git"
1313
bundler: "git://github.com/puppetlabs-operations/puppet-bundler.git"
14-
nginx: "git://github.com/puppetlabs-operations/puppet-nginx.git"
14+
nginx:
15+
repo: "git://github.com/jfryman/puppet-nginx.git"
16+
ref: "v0.0.10"
1517
inifile: "git://github.com/puppetlabs/puppetlabs-inifile.git"
1618
apache: "git://github.com/puppetlabs/puppetlabs-apache.git"
1719
portage: "git://github.com/gentoo/puppet-portage.git"

Modulefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ dependency 'ploperations/unicorn', '>= 1.0.0'
1515
dependency 'puppetlabs/inifile', '>= 1.0.0'
1616
dependency 'puppetlabs/apache', '>= 0.9.0'
1717
dependency 'gentoo/portage', '>= 2.1.0'
18-
dependency 'ploperations/nginx'
18+
dependency 'jfryman/nginx', '<= 0.0.10'
1919
dependency 'danieldreier/thin'

manifests/init.pp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88
# This module should not be directly included.
99
#
1010
class puppet (
11-
$logdir = $puppet::params::puppet_logdir,
12-
$vardir = $puppet::params::puppet_vardir,
13-
$ssldir = $puppet::params::puppet_ssldir,
14-
$rundir = $puppet::params::puppet_rundir,
11+
$logdir = $puppet::params::puppet_logdir,
12+
$vardir = $puppet::params::puppet_vardir,
13+
$ssldir = $puppet::params::puppet_ssldir,
14+
$rundir = $puppet::params::puppet_rundir,
15+
$confdir = $puppet::params::puppet_confdir,
1516
) inherits puppet::params {
1617

18+
file { $confdir:
19+
ensure => 'directory',
20+
owner => 'puppet',
21+
group => 'puppet',
22+
}
1723
}

manifests/server/thin.pp

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
loglevel => 'warning',
1212
}
1313

14-
class { 'puppet::server::standalone': enabled => false }
15-
class { '::thin': }
16-
class { 'nginx::server': }
14+
class { 'puppet::server::standalone':
15+
enabled => false,
16+
before => Class['nginx'],
17+
}
18+
include ::thin
19+
include nginx
1720

1821
Ini_setting {
1922
ensure => 'present',
@@ -30,10 +33,40 @@
3033
setting => 'ssl_client_verify_header';
3134
}
3235

33-
$servers = $::processorcount
34-
nginx::vhost { 'puppetmaster':
35-
port => 8140,
36-
template => 'puppet/vhost/nginx/thin.conf.erb',
36+
$servers = $::processorcount
37+
$servername = pick($::puppet::server::servername, $::clientcert, $::fqdn)
38+
$thin_socket = "unix:${puppet::params::puppet_rundir}/puppetmaster.0.sock"
39+
40+
nginx::resource::vhost { 'puppetmaster':
41+
server_name => [$servername],
42+
ssl => true,
43+
ssl_port => '8140',
44+
listen_port => '8140', # force ssl_only by matching ssl_port
45+
ssl_cert => "${::puppet::ssldir}/certs/${servername}.pem",
46+
ssl_key => "${::puppet::ssldir}/private_keys/${servername}.pem",
47+
ssl_ciphers => $::puppet::server::ssl_ciphers,
48+
ssl_protocols => $::puppet::server::ssl_protocols,
49+
proxy_read_timeout => '300',
50+
proxy => 'http://puppetmaster_thin',
51+
vhost_cfg_append => {
52+
ssl_crl => "${::puppet::ssldir}/crl.pem",
53+
ssl_client_certificate => "${::puppet::ssldir}/certs/ca.pem",
54+
ssl_verify_client => 'optional',
55+
proxy_connect_timeout => '300',
56+
proxy_set_header => [ 'Host $host',
57+
'X-Real-IP $remote_addr',
58+
'X-Forwarded-For $proxy_add_x_forwarded_for',
59+
'X-Client-Verify $ssl_client_verify',
60+
'X-Client-DN $ssl_client_s_dn',
61+
'X-SSL-Issuer $ssl_client_i_dn'],
62+
root => '/usr/share/empty',
63+
}
64+
}
65+
66+
nginx::resource::upstream { 'puppetmaster_thin':
67+
members => [
68+
$thin_socket
69+
],
3770
}
3871

3972
concat::fragment { 'proctitle':
@@ -49,7 +82,7 @@
4982
chdir => $puppet::params::puppet_confdir,
5083
subscribe => Concat["${::puppet::params::puppet_confdir}/config.ru"],
5184
require => Class['::thin'],
52-
socket => '/var/run/thin/puppetmaster.sock',
85+
socket => "${puppet::params::puppet_rundir}/puppetmaster.sock",
5386
force_home => '/etc/puppet',
5487
}
5588
}

manifests/server/unicorn.pp

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,55 @@
22

33
include puppet::params
44
include puppet::server::rack
5-
include nginx::server
5+
class { 'nginx': }
66

77
class { 'puppet::server::standalone':
88
enabled => false,
99
before => [
10-
Nginx::Unicorn['puppetmaster'],
10+
Nginx::Resource::Vhost['puppetmaster'],
1111
Unicorn::App['puppetmaster'],
1212
],
1313
}
1414

1515
$servername = pick($::puppet::server::servername, $::clientcert, $::fqdn)
16-
$unicorn_socket = "${puppet::params::puppet_rundir}/puppetmaster_unicorn.sock"
16+
$unicorn_socket = "unix:${puppet::params::puppet_rundir}/puppetmaster_unicorn.sock"
1717

18-
nginx::unicorn { 'puppetmaster':
19-
servername => $servername,
20-
path => $::puppet::params::puppet_confdir,
21-
unicorn_socket => $unicorn_socket,
22-
ssl => true,
23-
sslonly => true,
24-
ssl_port => '8140',
25-
ssl_cert => "${::puppet::ssldir}/certs/${servername}.pem",
26-
ssl_key => "${::puppet::ssldir}/private_keys/${servername}.pem",
27-
ssl_ca => "${::puppet::ssldir}/certs/ca.pem",
28-
ssl_crl_path => "${::puppet::ssldir}/crl.pem",
29-
ssl_ciphers => $::puppet::server::ssl_ciphers,
30-
ssl_protocols => $::puppet::server::ssl_protocols,
31-
ssl_verify_client => 'optional',
32-
magic => "proxy_connect_timeout 300s;\n proxy_read_timeout 300s;",
18+
nginx::resource::vhost { 'puppetmaster':
19+
server_name => [$servername],
20+
ssl => true,
21+
ssl_port => '8140',
22+
listen_port => '8140', # force ssl_only by matching ssl_port
23+
ssl_cert => "${::puppet::ssldir}/certs/${servername}.pem",
24+
ssl_key => "${::puppet::ssldir}/private_keys/${servername}.pem",
25+
ssl_ciphers => $::puppet::server::ssl_ciphers,
26+
ssl_protocols => $::puppet::server::ssl_protocols,
27+
proxy_read_timeout => '300',
28+
proxy => "http://puppetmaster_unicorn",
29+
vhost_cfg_append => {
30+
ssl_crl => "${::puppet::ssldir}/crl.pem",
31+
ssl_client_certificate => "${::puppet::ssldir}/certs/ca.pem",
32+
ssl_verify_client => 'optional',
33+
proxy_connect_timeout => '300',
34+
proxy_set_header => [ 'Host $host', 'X-Real-IP $remote_addr', 'X-Forwarded-For $proxy_add_x_forwarded_for', 'X-Client-Verify $ssl_client_verify', 'X-Client-DN $ssl_client_s_dn', 'X-SSL-Issuer $ssl_client_i_dn'],
35+
root => '/usr/share/empty',
36+
}
37+
}
38+
39+
nginx::resource::upstream { 'puppetmaster_unicorn':
40+
members => [
41+
$unicorn_socket
42+
],
3343
}
3444

3545
unicorn::app { 'puppetmaster':
36-
approot => $::puppet::params::puppet_confdir,
37-
config_file => "${::puppet::params::puppet_confdir}/unicorn.conf",
38-
pidfile => "${::puppet::params::puppet_rundir}/puppetmaster_unicorn.pid",
39-
socket => $unicorn_socket,
40-
logdir => $::puppet::params::puppet_logdir,
41-
user => 'puppet',
42-
group => 'puppet',
43-
before => Service['nginx'],
44-
subscribe => Concat["${::puppet::params::puppet_confdir}/config.ru"],
46+
approot => $::puppet::params::puppet_confdir,
47+
config_file => "${::puppet::params::puppet_confdir}/unicorn.conf",
48+
pidfile => "${::puppet::params::puppet_rundir}/puppetmaster_unicorn.pid",
49+
socket => $unicorn_socket,
50+
logdir => $::puppet::params::puppet_logdir,
51+
user => 'puppet',
52+
group => 'puppet',
53+
before => Service['nginx'],
54+
# export_home => $::confdir, # uncomment pending https://github.com/puppetlabs-operations/puppet-unicorn/pull/14
4555
}
4656
}

spec/spec_helper_acceptance.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
mod 'unicorn', :git => 'git://github.com/puppetlabs-operations/puppet-unicorn.git'
4848
mod 'rack', :git => 'git://github.com/puppetlabs-operations/puppet-rack.git'
4949
mod 'bundler', :git => 'git://github.com/puppetlabs-operations/puppet-bundler.git'
50-
mod 'nginx', :git => 'git://github.com/puppetlabs-operations/puppet-nginx.git'
50+
mod 'nginx', :git => 'git://github.com/jfryman/puppet-nginx.git'
5151
mod 'inifile', :git => 'git://github.com/puppetlabs/puppetlabs-inifile.git'
5252
mod 'apache', :git => 'git://github.com/puppetlabs/puppetlabs-apache.git'
5353
mod 'portage', :git => 'git://github.com/gentoo/puppet-portage.git'

templates/unicorn_puppetmaster

Lines changed: 0 additions & 76 deletions
This file was deleted.

tests/thin.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
host { 'puppet':
2+
ensure => 'present',
3+
ip => $::ipaddress,
4+
target => '/etc/hosts',
5+
}
6+
17
class { 'puppet::server':
28
servertype => 'thin',
39
ca => true,

tests/unicorn.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class { 'puppet::server':
2+
servertype => 'unicorn',
3+
ca => true,
4+
}
5+

0 commit comments

Comments
 (0)