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

Commit b011ead

Browse files
author
Daniel Dreier
committed
Fix broken nginx-unicorn support
addresses puppet-puppet issue 119 by switching from using the default location in the vhost to using an explicitly defined location, in order to avoid the default headers that cannot be unset on the default location. Add beaker tests to test for this problem Note that the beaker tests for this pass, but there are still failures. I think it's better to get this fixed and add tests rather than blocking on fixing everything. Also updates rack case statement to support puppet 3.7.x
1 parent e4cd512 commit b011ead

File tree

4 files changed

+55
-17
lines changed

4 files changed

+55
-17
lines changed

manifests/server/rack.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
$run_template = $::puppetversion ? {
2222
/^2.7/ => 'puppet/config.ru/99-run-2.7.erb',
23-
/^3.[0-6]/ => 'puppet/config.ru/99-run-3.0.erb',
23+
/^3.[0-7]/ => 'puppet/config.ru/99-run-3.0.erb',
2424
}
2525

2626
concat::fragment { 'run-puppet-master':

manifests/server/unicorn.pp

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

77
class { 'puppet::server::standalone':
88
enabled => false,
@@ -11,31 +11,63 @@
1111
Unicorn::App['puppetmaster'],
1212
],
1313
}
14+
Ini_setting {
15+
ensure => 'present',
16+
section => 'master',
17+
path => $puppet::params::puppet_conf,
18+
}
19+
ini_setting {
20+
'ssl_client_header':
21+
ensure => present,
22+
setting => 'ssl_client_header',
23+
value => 'HTTP_X_CLIENT_DN';
24+
'ssl_client_verify_header':
25+
ensure => present,
26+
setting => 'ssl_client_verify_header',
27+
value => 'HTTP_X_CLIENT_VERIFY';
28+
}
1429

1530
$servername = pick($::puppet::server::servername, $::clientcert, $::fqdn)
1631
$unicorn_socket = "unix:${puppet::params::puppet_rundir}/puppetmaster_unicorn.sock"
1732

1833
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 => {
34+
server_name => [$servername],
35+
ssl => true,
36+
ssl_port => '8140',
37+
listen_port => '8140', # force ssl_only by matching ssl_port
38+
ssl_cert => "${::puppet::ssldir}/certs/${servername}.pem",
39+
ssl_key => "${::puppet::ssldir}/private_keys/${servername}.pem",
40+
ssl_ciphers => $::puppet::server::ssl_ciphers,
41+
ssl_protocols => $::puppet::server::ssl_protocols,
42+
use_default_location => false,
43+
vhost_cfg_append => {
3044
ssl_crl => "${::puppet::ssldir}/crl.pem",
3145
ssl_client_certificate => "${::puppet::ssldir}/certs/ca.pem",
3246
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'],
47+
proxy_set_header => [ 'Host $host',
48+
'X-Real-IP $remote_addr',
49+
'X-Forwarded-For $proxy_add_x_forwarded_for',
50+
'X-Client-Verify $ssl_client_verify',
51+
'X-Client-DN $ssl_client_s_dn',
52+
'X-SSL-Issuer $ssl_client_i_dn'],
3553
root => '/usr/share/empty',
3654
}
3755
}
38-
56+
nginx::resource::location { 'unicorn_upstream':
57+
ensure => present,
58+
location => '/',
59+
vhost => 'puppetmaster',
60+
proxy_set_header => [],
61+
location_custom_cfg => {
62+
proxy_pass => "http://puppetmaster_unicorn",
63+
proxy_redirect => 'off',
64+
proxy_connect_timeout => '90',
65+
proxy_read_timeout => '300',
66+
},
67+
# this priority sets concat order so that the location is created inside
68+
# the server block. This works around a possible bug in jfryman/nginx.
69+
priority => 701,
70+
}
3971
nginx::resource::upstream { 'puppetmaster_unicorn':
4072
members => [
4173
$unicorn_socket

spec/acceptance/server_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ class { "puppet::server":
9494
apply_manifest(pp, :catch_failures => true)
9595
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
9696
end
97+
describe command('puppet agent --test --server puppet') do
98+
its(:exit_status) { should eq 0 }
99+
its(:stderr) { should_not match /Forbidden request:/ }
100+
its(:stderr) { should_not match /Error:/ }
101+
end
97102

98103
describe package('nginx') do
99104
it {

spec/spec_helper_acceptance.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
install_package host, 'rubygems'
3434
install_package host, 'git'
3535
on host, 'hash r10k || gem install r10k --no-ri --no-rdoc'
36+
on host, 'echo "$(facter ipaddress) puppet" >> /etc/hosts'
3637

3738
puppetfile = <<-EOS
3839
mod 'stdlib', :git => 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
@@ -47,7 +48,7 @@
4748
mod 'unicorn', :git => 'git://github.com/puppetlabs-operations/puppet-unicorn.git'
4849
mod 'rack', :git => 'git://github.com/puppetlabs-operations/puppet-rack.git'
4950
mod 'bundler', :git => 'git://github.com/puppetlabs-operations/puppet-bundler.git'
50-
mod 'nginx', :git => 'git://github.com/jfryman/puppet-nginx.git'
51+
mod 'nginx', :git => 'git://github.com/jfryman/puppet-nginx.git', :ref => 'v0.0.10'
5152
mod 'inifile', :git => 'git://github.com/puppetlabs/puppetlabs-inifile.git'
5253
mod 'apache', :git => 'git://github.com/puppetlabs/puppetlabs-apache.git'
5354
mod 'portage', :git => 'git://github.com/gentoo/puppet-portage.git'

0 commit comments

Comments
 (0)