Skip to content

Commit c314aa6

Browse files
author
James Fryman
committed
Merge pull request voxpupuli#145 from deric/master
support for nginx passenger debian repositories
2 parents 315d7e1 + 303efc6 commit c314aa6

File tree

8 files changed

+96
-34
lines changed

8 files changed

+96
-34
lines changed

manifests/init.pp

+5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
class nginx (
3232
$worker_processes = $nginx::params::nx_worker_processes,
3333
$worker_connections = $nginx::params::nx_worker_connections,
34+
$package_name = $nginx::params::package_name,
3435
$package_ensure = $nginx::params::package_ensure,
36+
$package_source = $nginx::params::package_source,
3537
$proxy_set_header = $nginx::params::nx_proxy_set_header,
3638
$proxy_http_version = $nginx::params::nx_proxy_http_version,
3739
$confd_purge = $nginx::params::nx_confd_purge,
@@ -58,6 +60,9 @@
5860
include stdlib
5961

6062
class { 'nginx::package':
63+
package_name => $package_name,
64+
package_source => $package_source,
65+
package_ensure => $package_ensure,
6166
notify => Class['nginx::service'],
6267
}
6368

manifests/package.pp

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
# Sample Usage:
1414
#
1515
# This class file is not called directly
16-
class nginx::package {
16+
class nginx::package(
17+
$package_name = 'nginx',
18+
$package_source = 'nginx',
19+
$package_ensure = 'present',
20+
) {
1721
anchor { 'nginx::package::begin': }
1822
anchor { 'nginx::package::end': }
1923

@@ -26,6 +30,9 @@
2630
}
2731
'debian': {
2832
class { 'nginx::package::debian':
33+
package_name => $package_name,
34+
package_source => $package_source,
35+
package_ensure => $package_ensure,
2936
require => Anchor['nginx::package::begin'],
3037
before => Anchor['nginx::package::end'],
3138
}

manifests/package/debian.pp

+32-8
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,47 @@
1313
# Sample Usage:
1414
#
1515
# This class file is not called directly
16-
class nginx::package::debian {
16+
class nginx::package::debian(
17+
$package_name = 'nginx',
18+
$package_source = 'nginx',
19+
$package_ensure = 'present'
20+
) {
1721
$distro = downcase($::operatingsystem)
1822

19-
package { 'nginx':
20-
ensure => $nginx::package_ensure,
23+
package { $package_name:
24+
ensure => $package_ensure,
2125
require => Anchor['nginx::apt_repo'],
2226
}
2327

2428
anchor { 'nginx::apt_repo' : }
2529

2630
include '::apt'
2731

28-
apt::source { 'nginx':
29-
location => "http://nginx.org/packages/${distro}",
30-
repos => 'nginx',
31-
key => '7BD9BF62',
32-
key_source => 'http://nginx.org/keys/nginx_signing.key',
32+
case $package_source {
33+
'nginx': {
34+
apt::source { 'nginx':
35+
location => "http://nginx.org/packages/${distro}",
36+
repos => 'nginx',
37+
key => '7BD9BF62',
38+
key_source => 'http://nginx.org/keys/nginx_signing.key',
39+
}
40+
}
41+
'passenger': {
42+
ensure_resource('package', 'apt-transport-https', {'ensure' => 'present' })
43+
44+
apt::source { 'nginx':
45+
location => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
46+
repos => "main",
47+
key => '561F9B9CAC40B2F7',
48+
key_source => 'https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt',
49+
}
50+
51+
package { 'passenger':
52+
ensure => 'present',
53+
require => Anchor['nginx::apt_repo'],
54+
}
55+
}
56+
default: {}
3357
}
3458

3559
exec { 'apt_get_update_for_nginx':

manifests/params.pp

+3
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,8 @@
8888
$nx_nginx_error_log = "${nx_logdir}/error.log"
8989
$nx_http_access_log = "${nx_logdir}/access.log"
9090

91+
# package name depends on distribution, e.g. for Debian nginx-full | nginx-light
92+
$package_name = 'nginx'
9193
$package_ensure = 'present'
94+
$package_source = 'nginx'
9295
}

manifests/resource/vhost.pp

+31-23
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
# options like log format to the end.
7575
# [*error_log*] - Where to write error log. May add additional
7676
# options like error level to the end.
77-
#
77+
# [*passenger_cgi_param*] - Allows one to define additional CGI environment
78+
# variables to pass to the backend application
7879
# Actions:
7980
#
8081
# Requires:
@@ -104,6 +105,7 @@
104105
$ssl_port = '443',
105106
$ssl_protocols = 'SSLv3 TLSv1 TLSv1.1 TLSv1.2',
106107
$ssl_ciphers = 'HIGH:!aNULL:!MD5',
108+
$ssl_cache = 'shared:SSL:10m',
107109
$spdy = $nginx::params::nx_spdy,
108110
$proxy = undef,
109111
$proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
@@ -132,6 +134,8 @@
132134
$include_files = undef,
133135
$access_log = undef,
134136
$error_log = undef,
137+
$passenger_cgi_param = undef,
138+
$use_default_location = true,
135139
) {
136140

137141
validate_array($location_allow)
@@ -190,28 +194,32 @@
190194
if ($ssl == true) and ($ssl_port == $listen_port) {
191195
$ssl_only = true
192196
}
193-
194-
# Create the default location reference for the vHost
195-
nginx::resource::location {"${name}-default":
196-
ensure => $ensure,
197-
vhost => $name,
198-
ssl => $ssl,
199-
ssl_only => $ssl_only,
200-
location => '/',
201-
location_allow => $location_allow,
202-
location_deny => $location_deny,
203-
proxy => $proxy,
204-
proxy_read_timeout => $proxy_read_timeout,
205-
proxy_cache => $proxy_cache,
206-
proxy_cache_valid => $proxy_cache_valid,
207-
fastcgi => $fastcgi,
208-
fastcgi_params => $fastcgi_params,
209-
fastcgi_script => $fastcgi_script,
210-
try_files => $try_files,
211-
www_root => $www_root,
212-
index_files => $index_files,
213-
location_custom_cfg => $location_custom_cfg,
214-
notify => Class['nginx::service'],
197+
198+
if $use_default_location == true {
199+
# Create the default location reference for the vHost
200+
nginx::resource::location {"${name}-default":
201+
ensure => $ensure,
202+
vhost => $name,
203+
ssl => $ssl,
204+
ssl_only => $ssl_only,
205+
location => '/',
206+
location_allow => $location_allow,
207+
location_deny => $location_deny,
208+
proxy => $proxy,
209+
proxy_read_timeout => $proxy_read_timeout,
210+
proxy_cache => $proxy_cache,
211+
proxy_cache_valid => $proxy_cache_valid,
212+
fastcgi => $fastcgi,
213+
fastcgi_params => $fastcgi_params,
214+
fastcgi_script => $fastcgi_script,
215+
try_files => $try_files,
216+
www_root => $www_root,
217+
index_files => $index_files,
218+
location_custom_cfg => $location_custom_cfg,
219+
notify => Class['nginx::service'],
220+
}
221+
} else {
222+
$root = $www_root
215223
}
216224

217225
# Support location_cfg_prepend and location_cfg_append on default location created by vhost

templates/vhost/vhost_header.erb

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ server {
1717
<% if @vhost_cfg_prepend -%><% vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
1818
<%= key %> <%= value %>;
1919
<% end -%><% end -%>
20+
<% if @root -%>
21+
root <%= @root %>;
22+
<% end -%>
23+
<% if @passenger_cgi_param -%><% @passenger_cgi_param.each do |key,value| -%>
24+
passenger_set_cgi_param <%= key %> <%= value %>;
25+
<% end -%><% end -%>
2026
<% @proxy_set_header.each do |header| -%>
2127
proxy_set_header <%= header %>;
2228
<% end -%>

templates/vhost/vhost_ssl_footer.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<% if @include_files %><% @include_files.each do |file| -%>
22
include <%= file %>;
33
<% end -%><% end -%>
4-
<% if @vhost_cfg_append -%><% vhost_cfg_append.each do |key,value| -%>
4+
<% if @vhost_cfg_append -%><% @vhost_cfg_append.each do |key,value| -%>
55
<%= key %> <%= value %>;
66
<% end -%>
77
<% end -%>

templates/vhost/vhost_ssl_header.erb

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ server {
99

1010
ssl_certificate <%= scope.lookupvar('nginx::params::nx_conf_dir') %>/<%= @name.gsub(' ', '_') %>.crt;
1111
ssl_certificate_key <%= scope.lookupvar('nginx::params::nx_conf_dir') %>/<%= @name.gsub(' ', '_') %>.key;
12-
ssl_session_cache shared:SSL:10m;
12+
ssl_session_cache <%= @ssl_cache %>;
1313
ssl_session_timeout 5m;
1414
ssl_protocols <%= @ssl_protocols %>;
1515
ssl_ciphers <%= @ssl_ciphers %>;
@@ -23,3 +23,12 @@ server {
2323

2424
access_log <%= @ssl_access_log %>;
2525
error_log <%= @ssl_error_log %>;
26+
27+
<% if @root -%>
28+
root <%= @root %>;
29+
<% end -%>
30+
<% if @passenger_cgi_param -%><% @passenger_cgi_param.each do |key,value| -%>
31+
passenger_set_cgi_param <%= key %> <%= value %>;
32+
<% end -%><% end -%>
33+
34+

0 commit comments

Comments
 (0)