module-nginx/manifests/init.pp

166 lines
6 KiB
ObjectPascal
Raw Normal View History

2011-06-07 01:05:27 +02:00
# Class: nginx
#
# This module manages NGINX.
#
# Parameters:
#
# 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-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
#
# 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
# }
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,
$vhost_purge = $nginx::params::nx_vhost_purge,
$proxy_cache_path = $nginx::params::nx_proxy_cache_path,
$proxy_cache_levels = $nginx::params::nx_proxy_cache_levels,
$proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone,
$proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size,
$proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive,
$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,
2013-09-04 18:37:18 +02:00
$client_max_body_size = $nginx::params::nx_client_max_body_size,
$names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size,
$names_hash_max_size = $nginx::params::nx_names_hash_max_size,
2013-09-05 23:57:50 +02:00
$proxy_buffers = $nginx::params::nx_proxy_buffers,
$proxy_buffer_size = $nginx::params::nx_proxy_buffer_size,
$http_cfg_append = $nginx::params::nx_http_cfg_append,
$nginx_error_log = $nginx::params::nx_nginx_error_log,
$http_access_log = $nginx::params::nx_http_access_log,
2014-01-17 10:29:56 +01:00
$gzip = $nginx::params::nx_gzip,
$nginx_vhosts = {},
$nginx_upstreams = {},
$nginx_locations = {},
$manage_repo = $nginx::params::manage_repo,
) inherits nginx::params {
include stdlib
2014-01-06 22:23:08 +01:00
if (!is_string($worker_processes)) and (!is_integer($worker_processes)) {
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.')
}
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)
validate_bool($vhost_purge)
2014-01-06 22:23:08 +01:00
if ($proxy_cache_path != false) {
validate_string($proxy_cache_path)
}
if (!is_integer($proxy_cache_levels)) {
fail('$proxy_cache_levels must be an integer.')
}
validate_string($proxy_cache_keys_zone)
validate_string($proxy_cache_max_size)
validate_string($proxy_cache_inactive)
validate_bool($configtest_enable)
validate_string($service_restart)
validate_bool($mail)
validate_string($server_tokens)
validate_string($client_max_body_size)
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) {
validate_hash($http_cfg_append)
}
validate_string($nginx_error_log)
validate_string($http_access_log)
validate_hash($nginx_upstreams)
validate_hash($nginx_vhosts)
validate_hash($nginx_locations)
validate_bool($manage_repo)
class { 'nginx::package':
2013-10-07 16:27:17 +02:00
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
notify => Class['nginx::service'],
manage_repo => $manage_repo,
2011-06-21 21:03:47 +02:00
}
2011-06-21 21:03:47 +02:00
class { 'nginx::config':
worker_processes => $worker_processes,
worker_connections => $worker_connections,
proxy_set_header => $proxy_set_header,
proxy_http_version => $proxy_http_version,
proxy_cache_path => $proxy_cache_path,
proxy_cache_levels => $proxy_cache_levels,
proxy_cache_keys_zone => $proxy_cache_keys_zone,
proxy_cache_max_size => $proxy_cache_max_size,
proxy_cache_inactive => $proxy_cache_inactive,
confd_purge => $confd_purge,
vhost_purge => $vhost_purge,
server_tokens => $server_tokens,
client_max_body_size => $client_max_body_size,
names_hash_bucket_size => $names_hash_bucket_size,
names_hash_max_size => $names_hash_max_size,
proxy_buffers => $proxy_buffers,
proxy_buffer_size => $proxy_buffer_size,
http_cfg_append => $http_cfg_append,
nginx_error_log => $nginx_error_log,
http_access_log => $http_access_log,
2014-02-14 09:47:38 +01:00
gzip => $gzip,
require => Class['nginx::package'],
notify => Class['nginx::service'],
2011-06-21 21:03:47 +02:00
}
class { 'nginx::service':
configtest_enable => $configtest_enable,
2013-05-06 11:37:37 +02:00
service_restart => $service_restart,
}
create_resources('nginx::resource::upstream', $nginx_upstreams)
create_resources('nginx::resource::vhost', $nginx_vhosts)
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.
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
}