Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configuration revamp #269

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 52 additions & 35 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,45 @@
#
# This class file is not called directly
class nginx::config(
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$client_body_temp_path = $nginx::params::nx_client_body_temp_path,
$client_max_body_size = $nginx::params::nx_client_max_body_size,
$conf_dir = $nginx::params::nx_conf_dir,
$confd_purge = $nginx::params::nx_confd_purge,
$server_tokens = $nginx::params::nx_server_tokens,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$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,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$daemon_user = $nginx::params::nx_daemon_user,
$events_use = $nginx::params::nx_events_use,
$gzip = $nginx::params::nx_gzip,
$http_access_log = $nginx::params::nx_http_access_log,
$http_cfg_append = $nginx::params::nx_http_cfg_append,
$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,
$mail = $nginx::params::nx_mail,
$multi_accept = $nginx::params::nx_multi_accept,
$names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size,
$names_hash_max_size = $nginx::params::nx_names_hash_max_size,
$types_hash_max_size = $nginx::params::nx_types_hash_max_size,
$types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size,
$client_max_body_size = $nginx::params::nx_client_max_body_size,
$proxy_buffers = $nginx::params::nx_proxy_buffers,
$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,
$pid = $nginx::params::nx_pid,
$proxy_buffer_size = $nginx::params::nx_proxy_buffer_size,
$gzip = $nginx::params::nx_gzip,
$proxy_buffers = $nginx::params::nx_proxy_buffers,
$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,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_temp_path = $nginx::params::nx_proxy_temp_path,
$run_dir = $nginx::params::nx_run_dir,
$sendfile = $nginx::params::nx_sendfile,
$server_tokens = $nginx::params::nx_server_tokens,
$spdy = $nginx::params::nx_spdy,
$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,
$worker_connections = $nginx::params::nx_worker_connections,
$worker_processes = $nginx::params::nx_worker_processes,
$worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile
) inherits nginx::params {

if $caller_module_name != $module_name {
Expand All @@ -48,82 +65,82 @@
mode => '0644',
}

file { $nginx::params::nx_conf_dir:
file { $conf_dir:
ensure => directory,
}

file { "${nginx::params::nx_conf_dir}/conf.d":
file { "${conf_dir}/conf.d":
ensure => directory,
}
if $confd_purge == true {
File["${nginx::params::nx_conf_dir}/conf.d"] {
File["${conf_dir}/conf.d"] {
purge => true,
recurse => true,
}
}

file { "${nginx::params::nx_conf_dir}/conf.mail.d":
file { "${conf_dir}/conf.mail.d":
ensure => directory,
}
if $confd_purge == true {
File["${nginx::params::nx_conf_dir}/conf.mail.d"] {
File["${conf_dir}/conf.mail.d"] {
purge => true,
recurse => true,
}
}

file { "${nginx::params::nx_conf_dir}/conf.d/vhost_autogen.conf":
file { "${conf_dir}/conf.d/vhost_autogen.conf":
ensure => absent,
}

file { "${nginx::params::nx_conf_dir}/conf.mail.d/vhost_autogen.conf":
file { "${conf_dir}/conf.mail.d/vhost_autogen.conf":
ensure => absent,
}

file {$nginx::config::nx_run_dir:
file {$run_dir:
ensure => directory,
}

file {$nginx::config::nx_client_body_temp_path:
file {$client_body_temp_path:
ensure => directory,
owner => $nginx::params::nx_daemon_user,
owner => $daemon_user,
}

file {$nginx::config::nx_proxy_temp_path:
file {$proxy_temp_path:
ensure => directory,
owner => $nginx::params::nx_daemon_user,
owner => $daemon_user,
}

file { "${nginx::params::nx_conf_dir}/sites-available":
file { "${conf_dir}/sites-available":
ensure => directory,
}

file { "${nginx::params::nx_conf_dir}/sites-enabled":
file { "${conf_dir}/sites-enabled":
ensure => directory,
}

file { '/etc/nginx/sites-enabled/default':
ensure => absent,
}

file { "${nginx::params::nx_conf_dir}/nginx.conf":
file { "${conf_dir}/nginx.conf":
ensure => file,
content => template('nginx/conf.d/nginx.conf.erb'),
}

file { "${nginx::params::nx_conf_dir}/conf.d/proxy.conf":
file { "${conf_dir}/conf.d/proxy.conf":
ensure => file,
content => template('nginx/conf.d/proxy.conf.erb'),
}

file { "${nginx::config::nx_temp_dir}/nginx.d":
file { "${temp_dir}/nginx.d":
ensure => absent,
purge => true,
recurse => true,
force => true,
}

file { "${nginx::config::nx_temp_dir}/nginx.mail.d":
file { "${temp_dir}/nginx.mail.d":
ensure => absent,
purge => true,
recurse => true,
Expand Down
115 changes: 76 additions & 39 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,54 @@
# 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,
$client_body_temp_path = $nginx::params::nx_client_body_temp_path,
$client_max_body_size = $nginx::params::nx_client_max_body_size,
$conf_dir = $nginx::params::nx_conf_dir,
$confd_purge = $nginx::params::nx_confd_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,
$daemon_user = $nginx::params::nx_daemon_user,
$events_use = $nginx::params::nx_events_use,
$gzip = $nginx::params::nx_gzip,
$http_access_log = $nginx::params::nx_http_access_log,
$http_cfg_append = $nginx::params::nx_http_cfg_append,
$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,
$mail = $nginx::params::nx_mail,
$server_tokens = $nginx::params::nx_server_tokens,
$client_max_body_size = $nginx::params::nx_client_max_body_size,
$manage_repo = $nginx::params::manage_repo,
$multi_accept = $nginx::params::nx_multi_accept,
$names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size,
$names_hash_max_size = $nginx::params::nx_names_hash_max_size,
$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,
$gzip = $nginx::params::nx_gzip,
$package_ensure = $nginx::params::package_ensure,
$package_name = $nginx::params::package_name,
$package_source = $nginx::params::package_source,
$pid = $nginx::params::nx_pid,
$proxy_buffer_size = $nginx::params::nx_proxy_buffer_size,
$proxy_buffers = $nginx::params::nx_proxy_buffers,
$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,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_temp_path = $nginx::params::nx_proxy_temp_path,
$run_dir = $nginx::params::nx_run_dir,
$sendfile = $nginx::params::nx_sendfile,
$server_tokens = $nginx::params::nx_server_tokens,
$service_restart = $nginx::params::nx_service_restart,
$spdy = $nginx::params::nx_spdy,
$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,
$worker_connections = $nginx::params::nx_worker_connections,
$worker_processes = $nginx::params::nx_worker_processes,
$worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile,
$nginx_vhosts = {},
$nginx_upstreams = {},
$nginx_locations = {},
$manage_repo = $nginx::params::manage_repo,
$nginx_locations = {}
) inherits nginx::params {

include stdlib
Expand Down Expand Up @@ -116,33 +134,52 @@
}

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,
server_tokens => $server_tokens,
client_body_temp_path => $client_body_temp_path,
client_max_body_size => $client_max_body_size,
conf_dir => $conf_dir,
confd_purge => $confd_purge,
daemon_user => $daemon_user,
gzip => $gzip,
events_use => $events_use,
http_access_log => $http_access_log,
http_cfg_append => $http_cfg_append,
http_tcp_nodelay => $http_tcp_nodelay,
http_tcp_nopush => $http_tcp_nopush,
keepalive_timeout => $keepalive_timeout,
logdir => $logdir,
mail => $mail,
multi_accept => $multi_accept,
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,
gzip => $gzip,
pid => $pid,
proxy_buffer_size => $proxy_buffer_size,
proxy_buffers => $proxy_buffers,
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,
proxy_http_version => $proxy_http_version,
proxy_set_header => $proxy_set_header,
proxy_temp_path => $proxy_temp_path,
run_dir => $run_dir,
sendfile => $sendfile,
server_tokens => $server_tokens,
spdy => $spdy,
temp_dir => $temp_dir,
types_hash_bucket_size => $types_hash_bucket_size,
types_hash_max_size => $types_hash_max_size,
worker_connections => $worker_connections,
worker_processes => $worker_processes,
worker_rlimit_nofile => $worker_rlimit_nofile,
require => Class['nginx::package'],
notify => Class['nginx::service'],
}

class { 'nginx::service':
configtest_enable => $configtest_enable,
service_restart => $service_restart,
service_restart => $service_restart
}

create_resources('nginx::resource::upstream', $nginx_upstreams)
Expand Down
4 changes: 3 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$nx_conf_dir = '/etc/nginx'
$nx_confd_purge = false
$nx_worker_processes = 1
$nx_worker_rlimit_nofile = false
$nx_worker_connections = 1024
$nx_types_hash_max_size = 1024
$nx_types_hash_bucket_size = 512
Expand All @@ -36,7 +37,8 @@
$nx_events_use = false
$nx_sendfile = on
$nx_keepalive_timeout = 65
$nx_tcp_nodelay = on
$nx_http_tcp_nodelay = on
$nx_http_tcp_nopush = false
$nx_gzip = on
$nx_server_tokens = on
$nx_spdy = off
Expand Down
6 changes: 3 additions & 3 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
'index.htm',
'index.php'],
$proxy = undef,
$proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
$proxy_read_timeout = $nginx::config::proxy_read_timeout,
$fastcgi = undef,
$fastcgi_params = '/etc/nginx/fastcgi_params',
$fastcgi_script = undef,
Expand Down Expand Up @@ -228,7 +228,7 @@
}

$vhost_sanitized = regsubst($vhost, ' ', '_', 'G')
$config_file = "${nginx::config::nx_conf_dir}/sites-available/${vhost_sanitized}.conf"
$config_file = "${nginx::config::conf_dir}/sites-available/${vhost_sanitized}.conf"

$location_sanitized_tmp = regsubst($location, '\/', '_', 'G')
$location_sanitized = regsubst($location_sanitized_tmp, '\\', '_', 'G')
Expand Down Expand Up @@ -288,7 +288,7 @@

if ($auth_basic_user_file != undef) {
#Generate htpasswd with provided file-locations
file { "${nginx::params::nx_conf_dir}/${location_sanitized}_htpasswd":
file { "${nginx::config::conf_dir}/${location_sanitized}_htpasswd":
ensure => $ensure,
mode => '0644',
source => $auth_basic_user_file,
Expand Down
2 changes: 1 addition & 1 deletion manifests/resource/mailhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
validate_string($xclient)
validate_array($server_name)

$config_file = "${nginx::config::nx_conf_dir}/conf.mail.d/${name}.conf"
$config_file = "${nginx::config::conf_dir}/conf.mail.d/${name}.conf"

# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
# and support does not exist for it in the kernel.
Expand Down
Loading