commit
30e9773aeb
8 changed files with 63 additions and 11 deletions
|
@ -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>
|
||||
|
|
|
@ -26,7 +26,8 @@ class nginx::config(
|
|||
$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',
|
||||
|
|
|
@ -42,7 +42,11 @@ class nginx (
|
|||
$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
|
||||
|
@ -63,6 +67,7 @@ class nginx (
|
|||
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'],
|
||||
}
|
||||
|
@ -72,6 +77,13 @@ class nginx (
|
|||
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.
|
||||
|
|
|
@ -25,7 +25,9 @@ class nginx::params {
|
|||
$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
|
||||
|
@ -70,12 +72,16 @@ class nginx::params {
|
|||
/(?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
|
||||
|
||||
}
|
||||
|
|
|
@ -158,6 +158,7 @@ define nginx::resource::vhost (
|
|||
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'],
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ describe 'nginx::package' do
|
|||
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') }
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 -%>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue