Skip to content

Commit

Permalink
Merge pull request #1 from jfryman/master
Browse files Browse the repository at this point in the history
Merging upstream changes
  • Loading branch information
justicel committed Jul 25, 2013
2 parents 06f5045 + 17d1eda commit 30e9773
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 11 deletions.
27 changes: 27 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,30 @@ Add an smtp proxy
}
}
</pre>

# Hiera Support
Define the nginx resources in Hiera. Here are the examples:

<pre>
nginx::nginx_upstreams:
'puppet_rack_app':
ensure: present
members:
- localhost:3000
- localhost:3001
- localhost:3002
nginx::nginx_vhosts:
'www.puppetlabs.com':
www_root: '/var/www/www.puppetlabs.com'
'rack.puppetlabs.com':
ensure: present
proxy: 'http://puppet_rack_app'
nginx::nginx_locations:
'static':
location: '~ "^/static/[0-9a-fA-F]{8}\/(.*)$"'
vhost: www.puppetlabs.com
'userContent':
location: /userContent
vhost: www.puppetlabs.com
www_root: /var/www/html
</pre>
3 changes: 2 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
$proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$types_hash_max_size = $nginx::params::nx_types_hash_max_size,
$types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size
$types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size,
$http_cfg_append = $nginx::params::nx_http_cfg_append
) inherits nginx::params {
File {
owner => 'root',
Expand Down
14 changes: 13 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
$configtest_enable = $nginx::params::nx_configtest_enable,
$service_restart = $nginx::params::nx_service_restart,
$mail = $nginx::params::nx_mail,
$server_tokens = $nginx::params::nx_server_tokens
$server_tokens = $nginx::params::nx_server_tokens,
$http_cfg_append = $nginx::params::nx_http_cfg_append,
$nginx_vhosts = {},
$nginx_upstreams = {},
$nginx_locations = {},
) inherits nginx::params {

include stdlib
Expand All @@ -63,6 +67,7 @@
proxy_cache_inactive => $proxy_cache_inactive,
confd_purge => $confd_purge,
server_tokens => $server_tokens,
http_cfg_append => $http_cfg_append,
require => Class['nginx::package'],
notify => Class['nginx::service'],
}
Expand All @@ -72,6 +77,13 @@
service_restart => $service_restart,
}

validate_hash($nginx_upstreams)
create_resources('nginx::resource::upstream', $nginx_upstreams)
validate_hash($nginx_vhosts)
create_resources('nginx::resource::vhost', $nginx_vhosts)
validate_hash($nginx_locations)
create_resources('nginx::resource::location', $nginx_locations)

# Allow the end user to establish relationships to the "main" class
# and preserve the relationship to the implementation classes through
# a transitive relationship to the composite class.
Expand Down
14 changes: 10 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
$nx_types_hash_bucket_size = 512
$nx_names_hash_bucket_size = 64
$nx_multi_accept = off
$nx_events_use = false # One of [kqueue|rtsig|epoll|/dev/poll|select|poll|eventport] or false to use OS default
# One of [kqueue|rtsig|epoll|/dev/poll|select|poll|eventport]
# or false to use OS default
$nx_events_use = false
$nx_sendfile = on
$nx_keepalive_timeout = 65
$nx_tcp_nodelay = on
Expand Down Expand Up @@ -70,12 +72,16 @@
/(?i-mx:fedora|rhel|redhat|centos|scientific|suse|opensuse|amazon|gentoo)/ => 'nginx',
}

# Service restart after Nginx 0.7.53 could also be just "/path/to/nginx/bin -s HUP"
# Some init scripts do a configtest, some don't. If configtest_enable it's true
# then service restart will take $nx_service_restart value, forcing configtest.
# Service restart after Nginx 0.7.53 could also be just
# "/path/to/nginx/bin -s HUP" Some init scripts do a configtest, some don't.
# If configtest_enable it's true then service restart will take
# $nx_service_restart value, forcing configtest.

$nx_configtest_enable = false
$nx_service_restart = '/etc/init.d/nginx configtest && /etc/init.d/nginx restart'

$nx_mail = false

$nx_http_cfg_append = false

}
1 change: 1 addition & 0 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
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'],
}
Expand Down
1 change: 0 additions & 1 deletion spec/classes/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
shared_examples 'redhat' do |operatingsystem|
let(:facts) {{ :operatingsystem => operatingsystem }}
it { should contain_package('nginx') }
it { should contain_package('GeoIP') }
it { should contain_package('gd') }
it { should contain_package('libXpm') }
it { should contain_package('libxslt') }
Expand Down
10 changes: 8 additions & 2 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ http {
keepalive_timeout <%= scope.lookupvar('nginx::params::nx_keepalive_timeout')%>;
tcp_nodelay <%= scope.lookupvar('nginx::params::nx_tcp_nodelay')%>;

<% if scope.lookupvar('nginx::params::nx_gzip') == 'on' %>
<% if scope.lookupvar('nginx::params::nx_gzip') == 'on' %>
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
<% end -%>
<% end -%>

<% if @proxy_cache_path -%>
proxy_cache_path <%= @proxy_cache_path %> levels=<%= @proxy_cache_levels %> keys_zone=<%= @proxy_cache_keys_zone %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %>;
<% end -%>

<% if @http_cfg_append -%><% @http_cfg_append.sort_by{|k,v| k}.each do |key,value| -%>
<%= key %> <%= value %>;
<% end -%>
<% end -%>

include /etc/nginx/conf.d/*.conf;

}
<% if scope.lookupvar('nginx::mail') %>
mail {
Expand Down
4 changes: 2 additions & 2 deletions templates/vhost/vhost_location_empty.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
location <%= @location %> {
<% @location_custom_cfg.sort_by {|k,v| k}.each do |key,value| -%>
<% if @location_custom_cfg -%><% @location_custom_cfg.sort_by {|k,v| k}.each do |key,value| -%>
<%= key %> <%= value %>;
<% end -%>
<% end -%><% end -%>
}

0 comments on commit 30e9773

Please sign in to comment.