2011-06-07 01:05:27 +02:00
|
|
|
# Class: nginx
|
|
|
|
#
|
|
|
|
# This module manages NGINX.
|
|
|
|
#
|
|
|
|
# Parameters:
|
2011-06-15 05:02:55 +02:00
|
|
|
#
|
2014-01-10 04:42:16 +01:00
|
|
|
# There are no default parameters for this class. All module parameters
|
|
|
|
# are managed via the nginx::params class
|
2011-06-07 01:05:27 +02:00
|
|
|
#
|
|
|
|
# Actions:
|
|
|
|
#
|
|
|
|
# Requires:
|
2011-06-21 21:03:47 +02:00
|
|
|
# puppetlabs-stdlib - https://github.com/puppetlabs/puppetlabs-stdlib
|
2011-06-15 18:50:55 +02:00
|
|
|
#
|
2011-06-07 01:05:27 +02:00
|
|
|
# Packaged NGINX
|
|
|
|
# - RHEL: EPEL or custom package
|
|
|
|
# - Debian/Ubuntu: Default Install or custom package
|
|
|
|
# - SuSE: Default Install or custom package
|
|
|
|
#
|
2011-06-15 18:50:55 +02:00
|
|
|
# stdlib
|
|
|
|
# - puppetlabs-stdlib module >= 0.1.6
|
|
|
|
# - plugin sync enabled to obtain the anchor type
|
|
|
|
#
|
2011-06-07 01:05:27 +02:00
|
|
|
# Sample Usage:
|
|
|
|
#
|
|
|
|
# The module works with sensible defaults:
|
|
|
|
#
|
|
|
|
# node default {
|
|
|
|
# include nginx
|
|
|
|
# }
|
2012-09-28 18:59:32 +02:00
|
|
|
class nginx (
|
2014-06-04 21:35:12 +02:00
|
|
|
$client_body_buffer_size = $nginx::params::nx_client_body_buffer_size,
|
2014-03-07 15:52:38 +01:00
|
|
|
$client_body_temp_path = $nginx::params::nx_client_body_temp_path,
|
2014-06-04 18:08:40 +02:00
|
|
|
$client_max_body_size = $nginx::params::nx_client_max_body_size,
|
2014-05-15 15:29:59 +02:00
|
|
|
$confd_purge = $nginx::params::nx_confd_purge,
|
2014-06-04 18:08:40 +02:00
|
|
|
$configtest_enable = $nginx::params::nx_configtest_enable,
|
2014-06-13 12:15:42 +02:00
|
|
|
$conf_dir = $nginx::params::nx_conf_dir,
|
2014-06-04 18:08:40 +02:00
|
|
|
$conf_template = $nginx::params::nx_conf_template,
|
2014-06-05 00:00:41 +02:00
|
|
|
$daemon_user = $nginx::params::nx_daemon_user,
|
2014-06-04 18:08:40 +02:00
|
|
|
$events_use = $nginx::params::nx_events_use,
|
2014-05-15 15:29:59 +02:00
|
|
|
$fastcgi_cache_inactive = $nginx::params::nx_fastcgi_cache_inactive,
|
|
|
|
$fastcgi_cache_key = $nginx::params::nx_fastcgi_cache_key,
|
2014-06-04 18:08:40 +02:00
|
|
|
$fastcgi_cache_keys_zone = $nginx::params::nx_fastcgi_cache_keys_zone,
|
|
|
|
$fastcgi_cache_levels = $nginx::params::nx_fastcgi_cache_levels,
|
|
|
|
$fastcgi_cache_max_size = $nginx::params::nx_fastcgi_cache_max_size,
|
|
|
|
$fastcgi_cache_path = $nginx::params::nx_fastcgi_cache_path,
|
2014-05-15 15:29:59 +02:00
|
|
|
$fastcgi_cache_use_stale = $nginx::params::nx_fastcgi_cache_use_stale,
|
2014-06-04 18:08:40 +02:00
|
|
|
$gzip = $nginx::params::nx_gzip,
|
|
|
|
$http_access_log = $nginx::params::nx_http_access_log,
|
|
|
|
$http_cfg_append = $nginx::params::nx_http_cfg_append,
|
2014-03-07 15:52:38 +01:00
|
|
|
$http_tcp_nodelay = $nginx::params::nx_http_tcp_nodelay,
|
|
|
|
$http_tcp_nopush = $nginx::params::nx_http_tcp_nopush,
|
|
|
|
$keepalive_timeout = $nginx::params::nx_keepalive_timeout,
|
|
|
|
$logdir = $nginx::params::nx_logdir,
|
2014-05-15 15:29:59 +02:00
|
|
|
$mail = $nginx::params::nx_mail,
|
2014-06-04 18:08:40 +02:00
|
|
|
$manage_repo = $nginx::params::manage_repo,
|
|
|
|
$multi_accept = $nginx::params::nx_multi_accept,
|
2014-05-15 15:29:59 +02:00
|
|
|
$names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size,
|
|
|
|
$names_hash_max_size = $nginx::params::nx_names_hash_max_size,
|
2014-06-04 18:08:40 +02:00
|
|
|
$nginx_error_log = $nginx::params::nx_nginx_error_log,
|
|
|
|
$nginx_locations = {},
|
|
|
|
$nginx_mailhosts = {},
|
|
|
|
$nginx_upstreams = {},
|
|
|
|
$nginx_vhosts = {},
|
|
|
|
$package_ensure = $nginx::params::package_ensure,
|
|
|
|
$package_name = $nginx::params::package_name,
|
|
|
|
$package_source = $nginx::params::package_source,
|
2014-03-07 15:52:38 +01:00
|
|
|
$pid = $nginx::params::nx_pid,
|
2014-05-15 15:29:59 +02:00
|
|
|
$proxy_buffers = $nginx::params::nx_proxy_buffers,
|
|
|
|
$proxy_buffer_size = $nginx::params::nx_proxy_buffer_size,
|
2014-06-04 18:08:40 +02:00
|
|
|
$proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive,
|
|
|
|
$proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone,
|
|
|
|
$proxy_cache_levels = $nginx::params::nx_proxy_cache_levels,
|
|
|
|
$proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size,
|
|
|
|
$proxy_cache_path = $nginx::params::nx_proxy_cache_path,
|
2014-05-15 15:29:59 +02:00
|
|
|
$proxy_conf_template = $nginx::params::nx_proxy_conf_template,
|
2014-06-04 21:35:12 +02:00
|
|
|
$proxy_connect_timeout = $nginx::params::nx_proxy_connect_timeout,
|
2014-05-15 15:29:59 +02:00
|
|
|
$proxy_headers_hash_bucket_size = $nginx::params::nx_proxy_headers_hash_bucket_size,
|
2014-06-04 18:08:40 +02:00
|
|
|
$proxy_http_version = $nginx::params::nx_proxy_http_version,
|
2014-06-04 21:35:12 +02:00
|
|
|
$proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
|
2014-06-04 18:08:40 +02:00
|
|
|
$proxy_redirect = $nginx::params::nx_proxy_redirect,
|
2014-06-04 21:35:12 +02:00
|
|
|
$proxy_send_timeout = $nginx::params::nx_proxy_send_timeout,
|
2014-06-04 18:08:40 +02:00
|
|
|
$proxy_set_header = $nginx::params::nx_proxy_set_header,
|
2014-03-07 15:52:38 +01:00
|
|
|
$proxy_temp_path = $nginx::params::nx_proxy_temp_path,
|
|
|
|
$run_dir = $nginx::params::nx_run_dir,
|
2014-05-28 09:11:59 +02:00
|
|
|
$sendfile = $nginx::params::nx_sendfile,
|
2014-06-04 18:08:40 +02:00
|
|
|
$server_tokens = $nginx::params::nx_server_tokens,
|
|
|
|
$service_ensure = $nginx::params::nx_service_ensure,
|
|
|
|
$service_restart = $nginx::params::nx_service_restart,
|
2014-03-07 15:52:38 +01:00
|
|
|
$spdy = $nginx::params::nx_spdy,
|
2014-05-15 14:51:37 +02:00
|
|
|
$super_user = $nginx::params::nx_super_user,
|
2014-03-07 15:52:38 +01:00
|
|
|
$temp_dir = $nginx::params::nx_temp_dir,
|
|
|
|
$types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size,
|
|
|
|
$types_hash_max_size = $nginx::params::nx_types_hash_max_size,
|
2014-06-04 18:08:40 +02:00
|
|
|
$vhost_purge = $nginx::params::nx_vhost_purge,
|
|
|
|
$worker_connections = $nginx::params::nx_worker_connections,
|
|
|
|
$worker_processes = $nginx::params::nx_worker_processes,
|
|
|
|
$worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile,
|
2014-07-03 16:06:54 +02:00
|
|
|
$global_owner = $nginx::params::nx_global_owner,
|
|
|
|
$global_group = $nginx::params::nx_global_group,
|
|
|
|
$global_mode = $nginx::params::nx_global_mode,
|
|
|
|
$sites_available_owner = $nginx::params::nx_sites_available_owner,
|
|
|
|
$sites_available_group = $nginx::params::nx_sites_available_group,
|
|
|
|
$sites_available_mode = $nginx::params::nx_sites_available_mode,
|
2014-06-12 20:12:24 +02:00
|
|
|
$geo_mappings = {},
|
|
|
|
$string_mappings = {},
|
2012-09-28 18:59:32 +02:00
|
|
|
) inherits nginx::params {
|
2011-06-15 18:50:55 +02:00
|
|
|
|
2012-09-24 16:52:48 +02:00
|
|
|
include stdlib
|
2011-06-15 05:02:55 +02:00
|
|
|
|
2014-01-06 22:23:08 +01:00
|
|
|
if (!is_string($worker_processes)) and (!is_integer($worker_processes)) {
|
2014-01-14 12:46:26 +01:00
|
|
|
fail('$worker_processes must be an integer or have value "auto".')
|
2014-01-06 22:23:08 +01:00
|
|
|
}
|
|
|
|
if (!is_integer($worker_connections)) {
|
|
|
|
fail('$worker_connections must be an integer.')
|
|
|
|
}
|
2014-03-12 18:17:41 +01:00
|
|
|
if (!is_integer($worker_rlimit_nofile)) {
|
|
|
|
fail('$worker_rlimit_nofile must be an integer.')
|
|
|
|
}
|
2014-06-04 22:39:06 +02:00
|
|
|
if (!is_string($events_use)) and ($events_use != false) {
|
|
|
|
fail('$events_use must be a string or false.')
|
|
|
|
}
|
2014-05-31 16:06:23 +02:00
|
|
|
validate_string($multi_accept)
|
2014-01-06 22:23:08 +01:00
|
|
|
validate_string($package_name)
|
|
|
|
validate_string($package_ensure)
|
|
|
|
validate_string($package_source)
|
|
|
|
validate_array($proxy_set_header)
|
|
|
|
validate_string($proxy_http_version)
|
|
|
|
validate_bool($confd_purge)
|
2014-03-07 20:39:40 +01:00
|
|
|
validate_bool($vhost_purge)
|
2014-01-06 22:23:08 +01:00
|
|
|
if ($proxy_cache_path != false) {
|
|
|
|
validate_string($proxy_cache_path)
|
|
|
|
}
|
2014-07-20 03:00:24 +02:00
|
|
|
validate_re($proxy_cache_levels, '^[12](:[12])*$')
|
2014-01-06 22:23:08 +01:00
|
|
|
validate_string($proxy_cache_keys_zone)
|
|
|
|
validate_string($proxy_cache_max_size)
|
|
|
|
validate_string($proxy_cache_inactive)
|
2014-05-15 15:29:59 +02:00
|
|
|
|
|
|
|
if ($fastcgi_cache_path != false) {
|
2014-04-26 17:14:55 +02:00
|
|
|
validate_string($fastcgi_cache_path)
|
|
|
|
}
|
2014-07-20 03:00:24 +02:00
|
|
|
validate_re($fastcgi_cache_levels, '^[12](:[12])*$')
|
2014-04-26 17:14:55 +02:00
|
|
|
validate_string($fastcgi_cache_keys_zone)
|
|
|
|
validate_string($fastcgi_cache_max_size)
|
|
|
|
validate_string($fastcgi_cache_inactive)
|
2014-04-27 15:49:45 +02:00
|
|
|
if ($fastcgi_cache_key != false) {
|
2014-06-04 22:06:37 +02:00
|
|
|
validate_string($fastcgi_cache_key)
|
2014-04-27 15:49:45 +02:00
|
|
|
}
|
|
|
|
if ($fastcgi_cache_use_stale != false) {
|
2014-06-04 22:06:37 +02:00
|
|
|
validate_string($fastcgi_cache_use_stale)
|
2014-04-27 15:49:45 +02:00
|
|
|
}
|
2014-04-26 17:14:55 +02:00
|
|
|
|
2014-01-06 22:23:08 +01:00
|
|
|
validate_bool($configtest_enable)
|
|
|
|
validate_string($service_restart)
|
|
|
|
validate_bool($mail)
|
|
|
|
validate_string($server_tokens)
|
|
|
|
validate_string($client_max_body_size)
|
2014-01-10 04:42:16 +01:00
|
|
|
if (!is_integer($names_hash_bucket_size)) {
|
|
|
|
fail('$names_hash_bucket_size must be an integer.')
|
|
|
|
}
|
|
|
|
if (!is_integer($names_hash_max_size)) {
|
|
|
|
fail('$names_hash_max_size must be an integer.')
|
|
|
|
}
|
2014-01-06 22:23:08 +01:00
|
|
|
validate_string($proxy_buffers)
|
|
|
|
validate_string($proxy_buffer_size)
|
|
|
|
if ($http_cfg_append != false) {
|
2014-07-02 12:07:54 +02:00
|
|
|
if !(is_hash($http_cfg_append) or is_array($http_cfg_append)) {
|
2014-06-30 08:37:43 +02:00
|
|
|
fail('$http_cfg_append must be either a hash or array')
|
|
|
|
}
|
2014-01-06 22:23:08 +01:00
|
|
|
}
|
2014-06-30 08:37:43 +02:00
|
|
|
|
2014-01-06 22:23:08 +01:00
|
|
|
validate_string($nginx_error_log)
|
|
|
|
validate_string($http_access_log)
|
|
|
|
validate_hash($nginx_upstreams)
|
|
|
|
validate_hash($nginx_vhosts)
|
|
|
|
validate_hash($nginx_locations)
|
2014-04-07 22:54:33 +02:00
|
|
|
validate_hash($nginx_mailhosts)
|
2014-01-06 22:23:08 +01:00
|
|
|
validate_bool($manage_repo)
|
2014-05-15 16:34:01 +02:00
|
|
|
validate_string($proxy_headers_hash_bucket_size)
|
2014-06-04 23:28:04 +02:00
|
|
|
validate_bool($super_user)
|
2014-01-06 22:23:08 +01:00
|
|
|
|
2014-06-12 20:12:24 +02:00
|
|
|
validate_hash($string_mappings)
|
|
|
|
validate_hash($geo_mappings)
|
|
|
|
|
2011-06-15 18:50:55 +02:00
|
|
|
class { 'nginx::package':
|
2013-10-07 16:27:17 +02:00
|
|
|
package_name => $package_name,
|
|
|
|
package_source => $package_source,
|
|
|
|
package_ensure => $package_ensure,
|
2014-01-10 04:42:16 +01:00
|
|
|
notify => Class['nginx::service'],
|
|
|
|
manage_repo => $manage_repo,
|
2011-06-21 21:03:47 +02:00
|
|
|
}
|
2011-06-15 05:02:55 +02:00
|
|
|
|
2011-06-21 21:03:47 +02:00
|
|
|
class { 'nginx::config':
|
2014-06-04 21:35:12 +02:00
|
|
|
client_body_buffer_size => $client_body_buffer_size,
|
2014-03-07 15:52:38 +01:00
|
|
|
client_body_temp_path => $client_body_temp_path,
|
2014-06-04 18:08:40 +02:00
|
|
|
client_max_body_size => $client_max_body_size,
|
|
|
|
confd_purge => $confd_purge,
|
2014-06-13 12:15:42 +02:00
|
|
|
conf_dir => $conf_dir,
|
2014-06-04 18:08:40 +02:00
|
|
|
conf_template => $conf_template,
|
2014-06-05 00:00:41 +02:00
|
|
|
daemon_user => $daemon_user,
|
2014-05-31 16:06:23 +02:00
|
|
|
events_use => $events_use,
|
2014-05-15 16:34:01 +02:00
|
|
|
fastcgi_cache_inactive => $fastcgi_cache_inactive,
|
|
|
|
fastcgi_cache_key => $fastcgi_cache_key,
|
2014-06-04 18:08:40 +02:00
|
|
|
fastcgi_cache_keys_zone => $fastcgi_cache_keys_zone,
|
|
|
|
fastcgi_cache_levels => $fastcgi_cache_levels,
|
|
|
|
fastcgi_cache_max_size => $fastcgi_cache_max_size,
|
|
|
|
fastcgi_cache_path => $fastcgi_cache_path,
|
2014-05-15 16:34:01 +02:00
|
|
|
fastcgi_cache_use_stale => $fastcgi_cache_use_stale,
|
2014-06-04 18:08:40 +02:00
|
|
|
gzip => $gzip,
|
|
|
|
http_access_log => $http_access_log,
|
|
|
|
http_cfg_append => $http_cfg_append,
|
2014-03-07 15:52:38 +01:00
|
|
|
http_tcp_nodelay => $http_tcp_nodelay,
|
|
|
|
http_tcp_nopush => $http_tcp_nopush,
|
|
|
|
keepalive_timeout => $keepalive_timeout,
|
|
|
|
logdir => $logdir,
|
|
|
|
mail => $mail,
|
2014-06-04 18:08:40 +02:00
|
|
|
multi_accept => $multi_accept,
|
2014-05-15 16:34:01 +02:00
|
|
|
names_hash_bucket_size => $names_hash_bucket_size,
|
|
|
|
names_hash_max_size => $names_hash_max_size,
|
2014-06-04 18:08:40 +02:00
|
|
|
nginx_error_log => $nginx_error_log,
|
2014-03-07 15:52:38 +01:00
|
|
|
pid => $pid,
|
2014-05-15 16:34:01 +02:00
|
|
|
proxy_buffers => $proxy_buffers,
|
|
|
|
proxy_buffer_size => $proxy_buffer_size,
|
2014-06-04 18:08:40 +02:00
|
|
|
proxy_cache_inactive => $proxy_cache_inactive,
|
|
|
|
proxy_cache_keys_zone => $proxy_cache_keys_zone,
|
|
|
|
proxy_cache_levels => $proxy_cache_levels,
|
|
|
|
proxy_cache_max_size => $proxy_cache_max_size,
|
|
|
|
proxy_cache_path => $proxy_cache_path,
|
2014-05-15 16:34:01 +02:00
|
|
|
proxy_conf_template => $proxy_conf_template,
|
2014-06-04 21:35:12 +02:00
|
|
|
proxy_connect_timeout => $proxy_connect_timeout,
|
2014-06-04 18:08:40 +02:00
|
|
|
proxy_headers_hash_bucket_size => $proxy_headers_hash_bucket_size,
|
|
|
|
proxy_http_version => $proxy_http_version,
|
2014-06-04 21:35:12 +02:00
|
|
|
proxy_read_timeout => $proxy_read_timeout,
|
2014-05-15 16:34:01 +02:00
|
|
|
proxy_redirect => $proxy_redirect,
|
2014-06-04 21:35:12 +02:00
|
|
|
proxy_send_timeout => $proxy_send_timeout,
|
2014-06-04 18:08:40 +02:00
|
|
|
proxy_set_header => $proxy_set_header,
|
2014-03-07 15:52:38 +01:00
|
|
|
proxy_temp_path => $proxy_temp_path,
|
|
|
|
run_dir => $run_dir,
|
2014-05-28 09:48:07 +02:00
|
|
|
sendfile => $sendfile,
|
2014-06-04 18:08:40 +02:00
|
|
|
server_tokens => $server_tokens,
|
2014-03-07 15:52:38 +01:00
|
|
|
spdy => $spdy,
|
2014-05-15 14:51:37 +02:00
|
|
|
super_user => $super_user,
|
2014-03-07 15:52:38 +01:00
|
|
|
temp_dir => $temp_dir,
|
|
|
|
types_hash_bucket_size => $types_hash_bucket_size,
|
|
|
|
types_hash_max_size => $types_hash_max_size,
|
2014-06-04 18:08:40 +02:00
|
|
|
vhost_purge => $vhost_purge,
|
|
|
|
worker_connections => $worker_connections,
|
|
|
|
worker_processes => $worker_processes,
|
|
|
|
worker_rlimit_nofile => $worker_rlimit_nofile,
|
2014-07-03 16:06:54 +02:00
|
|
|
global_owner => $global_owner,
|
|
|
|
global_group => $global_group,
|
|
|
|
global_mode => $global_mode,
|
|
|
|
sites_available_owner => $sites_available_owner,
|
|
|
|
sites_available_group => $sites_available_group,
|
|
|
|
sites_available_mode => $sites_available_mode,
|
2014-05-15 16:34:01 +02:00
|
|
|
require => Class['nginx::package'],
|
|
|
|
notify => Class['nginx::service'],
|
2011-06-21 21:03:47 +02:00
|
|
|
}
|
2011-06-15 05:02:55 +02:00
|
|
|
|
2013-03-16 10:34:07 +01:00
|
|
|
class { 'nginx::service':
|
2012-09-30 22:29:55 +02:00
|
|
|
}
|
2011-06-15 05:02:17 +02:00
|
|
|
|
2013-07-19 00:10:12 +02:00
|
|
|
create_resources('nginx::resource::upstream', $nginx_upstreams)
|
|
|
|
create_resources('nginx::resource::vhost', $nginx_vhosts)
|
|
|
|
create_resources('nginx::resource::location', $nginx_locations)
|
2014-04-07 22:54:33 +02:00
|
|
|
create_resources('nginx::resource::mailhost', $nginx_mailhosts)
|
2014-06-12 20:12:24 +02:00
|
|
|
create_resources('nginx::resource::map', $string_mappings)
|
|
|
|
create_resources('nginx::resource::geo', $geo_mappings)
|
2013-07-19 00:10:12 +02:00
|
|
|
|
2011-06-15 18:50:55 +02:00
|
|
|
# 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.
|
|
|
|
anchor{ 'nginx::begin':
|
|
|
|
before => Class['nginx::package'],
|
|
|
|
notify => Class['nginx::service'],
|
|
|
|
}
|
2011-06-21 21:03:47 +02:00
|
|
|
anchor { 'nginx::end':
|
|
|
|
require => Class['nginx::service'],
|
|
|
|
}
|
2011-05-25 04:20:48 +02:00
|
|
|
}
|