Skip to content

Commit

Permalink
Merge pull request #145 from deric/master
Browse files Browse the repository at this point in the history
support for nginx passenger debian repositories
  • Loading branch information
James Fryman committed Oct 7, 2013
2 parents 315d7e1 + 303efc6 commit c314aa6
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 34 deletions.
5 changes: 5 additions & 0 deletions manifests/init.pp
Expand Up @@ -31,7 +31,9 @@
class nginx (
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$package_name = $nginx::params::package_name,
$package_ensure = $nginx::params::package_ensure,
$package_source = $nginx::params::package_source,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$confd_purge = $nginx::params::nx_confd_purge,
Expand All @@ -58,6 +60,9 @@
include stdlib

class { 'nginx::package':
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
notify => Class['nginx::service'],
}

Expand Down
9 changes: 8 additions & 1 deletion manifests/package.pp
Expand Up @@ -13,7 +13,11 @@
# Sample Usage:
#
# This class file is not called directly
class nginx::package {
class nginx::package(
$package_name = 'nginx',
$package_source = 'nginx',
$package_ensure = 'present',
) {
anchor { 'nginx::package::begin': }
anchor { 'nginx::package::end': }

Expand All @@ -26,6 +30,9 @@
}
'debian': {
class { 'nginx::package::debian':
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}
Expand Down
40 changes: 32 additions & 8 deletions manifests/package/debian.pp
Expand Up @@ -13,23 +13,47 @@
# Sample Usage:
#
# This class file is not called directly
class nginx::package::debian {
class nginx::package::debian(
$package_name = 'nginx',
$package_source = 'nginx',
$package_ensure = 'present'
) {
$distro = downcase($::operatingsystem)

package { 'nginx':
ensure => $nginx::package_ensure,
package { $package_name:
ensure => $package_ensure,
require => Anchor['nginx::apt_repo'],
}

anchor { 'nginx::apt_repo' : }

include '::apt'

apt::source { 'nginx':
location => "http://nginx.org/packages/${distro}",
repos => 'nginx',
key => '7BD9BF62',
key_source => 'http://nginx.org/keys/nginx_signing.key',
case $package_source {
'nginx': {
apt::source { 'nginx':
location => "http://nginx.org/packages/${distro}",
repos => 'nginx',
key => '7BD9BF62',
key_source => 'http://nginx.org/keys/nginx_signing.key',
}
}
'passenger': {
ensure_resource('package', 'apt-transport-https', {'ensure' => 'present' })

apt::source { 'nginx':
location => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
repos => "main",
key => '561F9B9CAC40B2F7',
key_source => 'https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt',
}

package { 'passenger':
ensure => 'present',
require => Anchor['nginx::apt_repo'],
}
}
default: {}
}

exec { 'apt_get_update_for_nginx':
Expand Down
3 changes: 3 additions & 0 deletions manifests/params.pp
Expand Up @@ -88,5 +88,8 @@
$nx_nginx_error_log = "${nx_logdir}/error.log"
$nx_http_access_log = "${nx_logdir}/access.log"

# package name depends on distribution, e.g. for Debian nginx-full | nginx-light
$package_name = 'nginx'
$package_ensure = 'present'
$package_source = 'nginx'
}
54 changes: 31 additions & 23 deletions manifests/resource/vhost.pp
Expand Up @@ -74,7 +74,8 @@
# options like log format to the end.
# [*error_log*] - Where to write error log. May add additional
# options like error level to the end.
#
# [*passenger_cgi_param*] - Allows one to define additional CGI environment
# variables to pass to the backend application
# Actions:
#
# Requires:
Expand Down Expand Up @@ -104,6 +105,7 @@
$ssl_port = '443',
$ssl_protocols = 'SSLv3 TLSv1 TLSv1.1 TLSv1.2',
$ssl_ciphers = 'HIGH:!aNULL:!MD5',
$ssl_cache = 'shared:SSL:10m',
$spdy = $nginx::params::nx_spdy,
$proxy = undef,
$proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
Expand Down Expand Up @@ -132,6 +134,8 @@
$include_files = undef,
$access_log = undef,
$error_log = undef,
$passenger_cgi_param = undef,
$use_default_location = true,
) {

validate_array($location_allow)
Expand Down Expand Up @@ -190,28 +194,32 @@
if ($ssl == true) and ($ssl_port == $listen_port) {
$ssl_only = true
}

# Create the default location reference for the vHost
nginx::resource::location {"${name}-default":
ensure => $ensure,
vhost => $name,
ssl => $ssl,
ssl_only => $ssl_only,
location => '/',
location_allow => $location_allow,
location_deny => $location_deny,
proxy => $proxy,
proxy_read_timeout => $proxy_read_timeout,
proxy_cache => $proxy_cache,
proxy_cache_valid => $proxy_cache_valid,
fastcgi => $fastcgi,
fastcgi_params => $fastcgi_params,
fastcgi_script => $fastcgi_script,
try_files => $try_files,
www_root => $www_root,
index_files => $index_files,
location_custom_cfg => $location_custom_cfg,
notify => Class['nginx::service'],

if $use_default_location == true {
# Create the default location reference for the vHost
nginx::resource::location {"${name}-default":
ensure => $ensure,
vhost => $name,
ssl => $ssl,
ssl_only => $ssl_only,
location => '/',
location_allow => $location_allow,
location_deny => $location_deny,
proxy => $proxy,
proxy_read_timeout => $proxy_read_timeout,
proxy_cache => $proxy_cache,
proxy_cache_valid => $proxy_cache_valid,
fastcgi => $fastcgi,
fastcgi_params => $fastcgi_params,
fastcgi_script => $fastcgi_script,
try_files => $try_files,
www_root => $www_root,
index_files => $index_files,
location_custom_cfg => $location_custom_cfg,
notify => Class['nginx::service'],
}
} else {
$root = $www_root
}

# Support location_cfg_prepend and location_cfg_append on default location created by vhost
Expand Down
6 changes: 6 additions & 0 deletions templates/vhost/vhost_header.erb
Expand Up @@ -17,6 +17,12 @@ server {
<% if @vhost_cfg_prepend -%><% vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
<%= key %> <%= value %>;
<% end -%><% end -%>
<% if @root -%>
root <%= @root %>;
<% end -%>
<% if @passenger_cgi_param -%><% @passenger_cgi_param.each do |key,value| -%>
passenger_set_cgi_param <%= key %> <%= value %>;
<% end -%><% end -%>
<% @proxy_set_header.each do |header| -%>
proxy_set_header <%= header %>;
<% end -%>
Expand Down
2 changes: 1 addition & 1 deletion templates/vhost/vhost_ssl_footer.erb
@@ -1,7 +1,7 @@
<% if @include_files %><% @include_files.each do |file| -%>
include <%= file %>;
<% end -%><% end -%>
<% if @vhost_cfg_append -%><% vhost_cfg_append.each do |key,value| -%>
<% if @vhost_cfg_append -%><% @vhost_cfg_append.each do |key,value| -%>
<%= key %> <%= value %>;
<% end -%>
<% end -%>
Expand Down
11 changes: 10 additions & 1 deletion templates/vhost/vhost_ssl_header.erb
Expand Up @@ -9,7 +9,7 @@ server {

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

access_log <%= @ssl_access_log %>;
error_log <%= @ssl_error_log %>;

<% if @root -%>
root <%= @root %>;
<% end -%>
<% if @passenger_cgi_param -%><% @passenger_cgi_param.each do |key,value| -%>
passenger_set_cgi_param <%= key %> <%= value %>;
<% end -%><% end -%>


0 comments on commit c314aa6

Please sign in to comment.