2011-06-07 01:05:27 +02:00
|
|
|
# Class: nginx::config
|
|
|
|
#
|
|
|
|
# This module manages NGINX bootstrap and configuration
|
|
|
|
#
|
|
|
|
# Parameters:
|
2011-06-15 21:40:42 +02:00
|
|
|
#
|
|
|
|
# There are no default parameters for this class.
|
2011-06-07 01:05:27 +02:00
|
|
|
#
|
|
|
|
# Actions:
|
|
|
|
#
|
|
|
|
# Requires:
|
|
|
|
#
|
|
|
|
# Sample Usage:
|
|
|
|
#
|
|
|
|
# This class file is not called directly
|
2012-09-28 18:59:32 +02:00
|
|
|
class nginx::config(
|
2013-03-27 19:13:52 +01:00
|
|
|
$worker_processes = $nginx::params::nx_worker_processes,
|
|
|
|
$worker_connections = $nginx::params::nx_worker_connections,
|
2014-03-12 18:17:41 +01:00
|
|
|
$worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile,
|
2013-03-27 19:13:52 +01:00
|
|
|
$confd_purge = $nginx::params::nx_confd_purge,
|
2014-03-07 20:39:40 +01:00
|
|
|
$vhost_purge = $nginx::params::nx_vhost_purge,
|
2013-05-21 15:15:59 +02:00
|
|
|
$server_tokens = $nginx::params::nx_server_tokens,
|
2013-05-21 14:30:21 +02:00
|
|
|
$proxy_set_header = $nginx::params::nx_proxy_set_header,
|
2013-03-27 19:13:52 +01:00
|
|
|
$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,
|
2013-05-21 14:30:21 +02:00
|
|
|
$proxy_http_version = $nginx::params::nx_proxy_http_version,
|
2014-01-10 04:42:16 +01:00
|
|
|
$names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size,
|
|
|
|
$names_hash_max_size = $nginx::params::nx_names_hash_max_size,
|
2013-05-21 14:30:21 +02:00
|
|
|
$types_hash_max_size = $nginx::params::nx_types_hash_max_size,
|
2013-07-21 02:12:18 +02:00
|
|
|
$types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size,
|
2013-09-04 18:37:18 +02:00
|
|
|
$client_max_body_size = $nginx::params::nx_client_max_body_size,
|
2013-09-05 23:57:50 +02:00
|
|
|
$proxy_buffers = $nginx::params::nx_proxy_buffers,
|
2013-08-08 03:27:13 +02:00
|
|
|
$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,
|
2013-09-06 00:15:45 +02:00
|
|
|
$proxy_buffer_size = $nginx::params::nx_proxy_buffer_size,
|
2014-02-14 09:47:38 +01:00
|
|
|
$gzip = $nginx::params::nx_gzip,
|
2014-03-10 21:19:25 +01:00
|
|
|
$conf_template = $nginx::params::nx_conf_template,
|
2014-03-10 21:44:46 +01:00
|
|
|
$proxy_conf_template = $nginx::params::nx_proxy_conf_template,
|
2014-03-27 21:55:11 +01:00
|
|
|
$proxy_redirect = $nginx::params::nx_proxy_redirect,
|
2012-09-28 18:59:32 +02:00
|
|
|
) inherits nginx::params {
|
2014-01-06 22:25:46 +01:00
|
|
|
|
2011-06-15 21:40:42 +02:00
|
|
|
File {
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
|
2013-03-27 19:13:52 +01:00
|
|
|
file { $nginx::params::nx_conf_dir:
|
2011-06-15 21:40:42 +02:00
|
|
|
ensure => directory,
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "${nginx::params::nx_conf_dir}/conf.d":
|
|
|
|
ensure => directory,
|
|
|
|
}
|
2012-09-30 10:30:04 +02:00
|
|
|
if $confd_purge == true {
|
|
|
|
File["${nginx::params::nx_conf_dir}/conf.d"] {
|
2013-03-16 10:34:07 +01:00
|
|
|
purge => true,
|
2012-09-30 10:30:04 +02:00
|
|
|
recurse => true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
add support for mail module
See http://wiki.nginx.org/Modules#Mail_modules
Sample Usage:
nginx::resource::mailhost { 'domain1.example':
ensure => present,
auth_http => 'server2.example/cgi-bin/auth',
protocol => 'smtp',
listen_port => 587,
ssl_port => 465,
starttls => 'only',
xclient => 'off',
ssl => 'true',
ssl_cert => '/tmp/server.crt',
ssl_key => '/tmp/server.pem',
}
2013-03-11 14:05:00 +01:00
|
|
|
file { "${nginx::params::nx_conf_dir}/conf.mail.d":
|
|
|
|
ensure => directory,
|
|
|
|
}
|
|
|
|
if $confd_purge == true {
|
|
|
|
File["${nginx::params::nx_conf_dir}/conf.mail.d"] {
|
2013-05-08 14:15:42 +02:00
|
|
|
purge => true,
|
add support for mail module
See http://wiki.nginx.org/Modules#Mail_modules
Sample Usage:
nginx::resource::mailhost { 'domain1.example':
ensure => present,
auth_http => 'server2.example/cgi-bin/auth',
protocol => 'smtp',
listen_port => 587,
ssl_port => 465,
starttls => 'only',
xclient => 'off',
ssl => 'true',
ssl_cert => '/tmp/server.crt',
ssl_key => '/tmp/server.pem',
}
2013-03-11 14:05:00 +01:00
|
|
|
recurse => true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-01 01:56:38 +01:00
|
|
|
file { "${nginx::params::nx_conf_dir}/conf.d/vhost_autogen.conf":
|
|
|
|
ensure => absent,
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "${nginx::params::nx_conf_dir}/conf.mail.d/vhost_autogen.conf":
|
|
|
|
ensure => absent,
|
|
|
|
}
|
|
|
|
|
2013-03-27 19:13:52 +01:00
|
|
|
file {$nginx::config::nx_run_dir:
|
2011-06-15 21:40:42 +02:00
|
|
|
ensure => directory,
|
|
|
|
}
|
|
|
|
|
2013-03-27 19:13:52 +01:00
|
|
|
file {$nginx::config::nx_client_body_temp_path:
|
2011-06-15 21:40:42 +02:00
|
|
|
ensure => directory,
|
|
|
|
owner => $nginx::params::nx_daemon_user,
|
|
|
|
}
|
|
|
|
|
2013-03-27 19:13:52 +01:00
|
|
|
file {$nginx::config::nx_proxy_temp_path:
|
2011-06-15 21:40:42 +02:00
|
|
|
ensure => directory,
|
|
|
|
owner => $nginx::params::nx_daemon_user,
|
|
|
|
}
|
|
|
|
|
2013-12-01 01:51:31 +01:00
|
|
|
file { "${nginx::params::nx_conf_dir}/sites-available":
|
|
|
|
ensure => directory,
|
|
|
|
}
|
|
|
|
|
2014-03-07 20:39:40 +01:00
|
|
|
if $vhost_purge == true {
|
|
|
|
File["${nginx::params::nx_conf_dir}/sites-available"] {
|
|
|
|
purge => true,
|
|
|
|
recurse => true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-01 01:51:31 +01:00
|
|
|
file { "${nginx::params::nx_conf_dir}/sites-enabled":
|
|
|
|
ensure => directory,
|
|
|
|
}
|
|
|
|
|
2014-03-07 20:39:40 +01:00
|
|
|
if $vhost_purge == true {
|
|
|
|
File["${nginx::params::nx_conf_dir}/sites-enabled"] {
|
|
|
|
purge => true,
|
|
|
|
recurse => true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-15 21:40:42 +02:00
|
|
|
file { '/etc/nginx/sites-enabled/default':
|
|
|
|
ensure => absent,
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "${nginx::params::nx_conf_dir}/nginx.conf":
|
|
|
|
ensure => file,
|
2014-03-10 21:19:25 +01:00
|
|
|
content => template($conf_template),
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
file { "${nginx::params::nx_conf_dir}/conf.d/proxy.conf":
|
|
|
|
ensure => file,
|
2014-03-10 21:44:46 +01:00
|
|
|
content => template($proxy_conf_template),
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|
|
|
|
|
2014-03-28 13:37:49 +01:00
|
|
|
file { "${nginx::params::nx_conf_dir}/conf.d/default.conf":
|
|
|
|
ensure => absent,
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "${nginx::params::nx_conf_dir}/conf.d/example_ssl.conf":
|
|
|
|
ensure => absent,
|
|
|
|
}
|
|
|
|
|
2013-12-02 19:53:10 +01:00
|
|
|
file { "${nginx::config::nx_temp_dir}/nginx.d":
|
|
|
|
ensure => absent,
|
|
|
|
purge => true,
|
|
|
|
recurse => true,
|
2014-03-04 10:03:17 +01:00
|
|
|
force => true,
|
2013-12-02 19:53:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
file { "${nginx::config::nx_temp_dir}/nginx.mail.d":
|
|
|
|
ensure => absent,
|
|
|
|
purge => true,
|
|
|
|
recurse => true,
|
2014-03-04 10:03:17 +01:00
|
|
|
force => true,
|
2013-12-02 19:53:10 +01:00
|
|
|
}
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|