Skip to content

Commit

Permalink
Merge pull request #950 from wyardley/namespace_changes
Browse files Browse the repository at this point in the history
Major change: Rework namespace (get rid of ::config namespace again)
  • Loading branch information
bastelfreak authored Nov 4, 2016
2 parents a4b630a + 3104d02 commit 471ae97
Show file tree
Hide file tree
Showing 25 changed files with 1,465 additions and 1,668 deletions.
52 changes: 0 additions & 52 deletions docs/hiera.md

This file was deleted.

308 changes: 100 additions & 208 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,215 +13,107 @@
# Sample Usage:
#
# This class file is not called directly
class nginx::config(
### START Module/App Configuration ###
$client_body_temp_path = $::nginx::params::client_body_temp_path,
$confd_only = false,
$confd_purge = false,
$conf_dir = $::nginx::params::conf_dir,
$daemon_user = $::nginx::params::daemon_user,
$global_owner = $::nginx::params::global_owner,
$global_group = $::nginx::params::global_group,
$global_mode = $::nginx::params::global_mode,
$log_dir = $::nginx::params::log_dir,
$log_group = $::nginx::params::log_group,
$log_mode = '0750',
$http_access_log = "${log_dir}/${::nginx::params::http_access_log_file}",
$http_format_log = undef,
$nginx_error_log = "${log_dir}/${::nginx::params::nginx_error_log_file}",
$nginx_error_log_severity = 'error',
$pid = $::nginx::params::pid,
$proxy_temp_path = $::nginx::params::proxy_temp_path,
$root_group = $::nginx::params::root_group,
$run_dir = $::nginx::params::run_dir,
$sites_available_owner = $::nginx::params::sites_available_owner,
$sites_available_group = $::nginx::params::sites_available_group,
$sites_available_mode = $::nginx::params::sites_available_mode,
$super_user = $::nginx::params::super_user,
$temp_dir = $::nginx::params::temp_dir,
$vhost_purge = false,
class nginx::config {

assert_private()

$client_body_temp_path = $::nginx::client_body_temp_path
$confd_only = $::nginx::confd_only
$confd_purge = $::nginx::confd_purge
$conf_dir = $::nginx::conf_dir
$daemon = $::nginx::daemon
$daemon_user = $::nginx::daemon_user
$global_owner = $::nginx::global_owner
$global_group = $::nginx::global_group
$global_mode = $::nginx::global_mode
$log_dir = $::nginx::log_dir
$log_group = $::nginx::log_group
$log_mode = $::nginx::log_mode
$http_access_log = $::nginx::http_access_log
$http_format_log = $::nginx::http_format_log
$nginx_error_log = $::nginx::nginx_error_log
$nginx_error_log_severity = $::nginx::nginx_error_log_severity
$pid = $::nginx::pid
$proxy_temp_path = $::nginx::proxy_temp_path
$root_group = $::nginx::root_group
$run_dir = $::nginx::run_dir
$sites_available_owner = $::nginx::sites_available_owner
$sites_available_group = $::nginx::sites_available_group
$sites_available_mode = $::nginx::sites_available_mode
$super_user = $::nginx::super_user
$temp_dir = $::nginx::temp_dir
$vhost_purge = $::nginx::vhost_purge
$accept_mutex = $::nginx::accept_mutex
$accept_mutex_delay = $::nginx::accept_mutex_delay
$client_body_buffer_size = $::nginx::client_body_buffer_size
$client_max_body_size = $::nginx::client_max_body_size
$client_body_timeout = $::nginx::client_body_timeout
$send_timeout = $::nginx::send_timeout
$lingering_timeout = $::nginx::lingering_timeout
$events_use = $::nginx::events_use
$fastcgi_cache_inactive = $::nginx::fastcgi_cache_inactive
$fastcgi_cache_key = $::nginx::fastcgi_cache_key
$fastcgi_cache_keys_zone = $::nginx::fastcgi_cache_keys_zone
$fastcgi_cache_levels = $::nginx::fastcgi_cache_levels
$fastcgi_cache_max_size = $::nginx::fastcgi_cache_max_size
$fastcgi_cache_path = $::nginx::fastcgi_cache_path
$fastcgi_cache_use_stale = $::nginx::fastcgi_cache_use_stale
$gzip = $::nginx::gzip
$gzip_buffers = $::nginx::gzip_buffers
$gzip_comp_level = $::nginx::gzip_comp_level
$gzip_disable = $::nginx::gzip_disable
$gzip_min_length = $::nginx::gzip_min_length
$gzip_http_version = $::nginx::gzip_http_version
$gzip_proxied = $::nginx::gzip_proxied
$gzip_types = $::nginx::gzip_types
$gzip_vary = $::nginx::gzip_vary
$http_cfg_prepend = $::nginx::http_cfg_prepend
$http_cfg_append = $::nginx::http_cfg_append
$http_tcp_nodelay = $::nginx::http_tcp_nodelay
$http_tcp_nopush = $::nginx::http_tcp_nopush
$keepalive_timeout = $::nginx::keepalive_timeout
$keepalive_requests = $::nginx::keepalive_requests
$log_format = $::nginx::log_format
$mail = $::nginx::mail
$stream = $::nginx::stream
$multi_accept = $::nginx::multi_accept
$names_hash_bucket_size = $::nginx::names_hash_bucket_size
$names_hash_max_size = $::nginx::names_hash_max_size
$nginx_cfg_prepend = $::nginx::nginx_cfg_prepend
$proxy_buffers = $::nginx::proxy_buffers
$proxy_buffer_size = $::nginx::proxy_buffer_size
$proxy_cache_inactive = $::nginx::proxy_cache_inactive
$proxy_cache_keys_zone = $::nginx::proxy_cache_keys_zone
$proxy_cache_levels = $::nginx::proxy_cache_levels
$proxy_cache_max_size = $::nginx::proxy_cache_max_size
$proxy_cache_path = $::nginx::proxy_cache_path
$proxy_use_temp_path = $::nginx::proxy_use_temp_path
$proxy_connect_timeout = $::nginx::proxy_connect_timeout
$proxy_headers_hash_bucket_size = $::nginx::proxy_headers_hash_bucket_size
$proxy_http_version = $::nginx::proxy_http_version
$proxy_read_timeout = $::nginx::proxy_read_timeout
$proxy_redirect = $::nginx::proxy_redirect
$proxy_send_timeout = $::nginx::proxy_send_timeout
$proxy_set_header = $::nginx::proxy_set_header
$proxy_hide_header = $::nginx::proxy_hide_header
$proxy_pass_header = $::nginx::proxy_pass_header
$sendfile = $::nginx::sendfile
$server_tokens = $::nginx::server_tokens
$spdy = $::nginx::spdy
$http2 = $::nginx::http2
$ssl_stapling = $::nginx::ssl_stapling
$types_hash_bucket_size = $::nginx::types_hash_bucket_size
$types_hash_max_size = $::nginx::types_hash_max_size
$worker_connections = $::nginx::worker_connections
$worker_processes = $::nginx::worker_processes
$worker_rlimit_nofile = $::nginx::worker_rlimit_nofile
$ssl_protocols = $::nginx::ssl_protocols
$ssl_ciphers = $::nginx::ssl_ciphers

# Non-configurable settings
$conf_template = 'nginx/conf.d/nginx.conf.erb'
$proxy_conf_template = undef

# Primary Templates
$conf_template = 'nginx/conf.d/nginx.conf.erb',
$proxy_conf_template = undef,
### END Module/App Configuration ###

### START Nginx Configuration ###
$accept_mutex = 'on',
$accept_mutex_delay = '500ms',
$client_body_buffer_size = '128k',
$client_max_body_size = '10m',
$client_body_timeout = '60',
$daemon = undef,
$send_timeout = '60',
$lingering_timeout = '5',
$events_use = false,
$fastcgi_cache_inactive = '20m',
$fastcgi_cache_key = false,
$fastcgi_cache_keys_zone = 'd3:100m',
$fastcgi_cache_levels = '1',
$fastcgi_cache_max_size = '500m',
$fastcgi_cache_path = false,
$fastcgi_cache_use_stale = false,
$gzip = 'on',
$gzip_buffers = undef,
$gzip_comp_level = 1,
$gzip_disable = 'msie6',
$gzip_min_length = 20,
$gzip_http_version = 1.1,
$gzip_proxied = 'off',
$gzip_types = undef,
$gzip_vary = 'off',
$http_cfg_prepend = false,
$http_cfg_append = false,
$http_tcp_nodelay = 'on',
$http_tcp_nopush = 'off',
$keepalive_timeout = '65',
$keepalive_requests = '100',
$log_format = {},
$mail = false,
$stream = false,
$multi_accept = 'off',
$names_hash_bucket_size = '64',
$names_hash_max_size = '512',
$nginx_cfg_prepend = false,
$proxy_buffers = '32 4k',
$proxy_buffer_size = '8k',
$proxy_cache_inactive = '20m',
$proxy_cache_keys_zone = 'd2:100m',
$proxy_cache_levels = '1',
$proxy_cache_max_size = '500m',
$proxy_cache_path = false,
$proxy_use_temp_path = false,
$proxy_connect_timeout = '90',
$proxy_headers_hash_bucket_size = '64',
$proxy_http_version = undef,
$proxy_read_timeout = '90',
$proxy_redirect = undef,
$proxy_send_timeout = '90',
$proxy_set_header = [
'Host $host',
'X-Real-IP $remote_addr',
'X-Forwarded-For $proxy_add_x_forwarded_for',
'Proxy ""',
],
$proxy_hide_header = [],
$proxy_pass_header = [],
$sendfile = 'on',
$server_tokens = 'on',
$spdy = 'off',
$http2 = 'off',
$ssl_stapling = 'off',
$types_hash_bucket_size = '512',
$types_hash_max_size = '1024',
$worker_connections = '1024',
$worker_processes = '1',
$worker_rlimit_nofile = '1024',
$ssl_protocols = 'TLSv1 TLSv1.1 TLSv1.2',
$ssl_ciphers = 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS',
### END Nginx Configuration ###
) inherits ::nginx::params {

### Validations ###
if ($worker_processes != 'auto') and (!is_integer($worker_processes)) {
fail('$worker_processes must be an integer or have value "auto".')
}
if (!is_integer($worker_connections)) {
fail('$worker_connections must be an integer.')
}
if (!is_integer($worker_rlimit_nofile)) {
fail('$worker_rlimit_nofile must be an integer.')
}
if (!is_string($events_use)) and ($events_use != false) {
fail('$events_use must be a string or false.')
}
validate_string($multi_accept)
validate_array($proxy_set_header)
validate_array($proxy_hide_header)
validate_array($proxy_pass_header)
if ($proxy_http_version != undef) {
validate_string($proxy_http_version)
}
if ($proxy_conf_template != undef) {
warning('The $proxy_conf_template parameter is deprecated and has no effect.')
}
validate_bool($confd_only)
validate_bool($confd_purge)
validate_bool($vhost_purge)
if ( $proxy_cache_path != false) {
if ( is_string($proxy_cache_path) or is_hash($proxy_cache_path)) {}
else {
fail('proxy_cache_path must be a string or a hash')
}
}
validate_re($proxy_cache_levels, '^[12](:[12])*$')
validate_string($proxy_cache_keys_zone)
validate_string($proxy_cache_max_size)
validate_string($proxy_cache_inactive)

if ($proxy_use_temp_path != false) {
validate_re($proxy_use_temp_path, '^(on|off)$')
}

if ($fastcgi_cache_path != false) {
validate_string($fastcgi_cache_path)
}
validate_re($fastcgi_cache_levels, '^[12](:[12])*$')
validate_string($fastcgi_cache_keys_zone)
validate_string($fastcgi_cache_max_size)
validate_string($fastcgi_cache_inactive)
if ($fastcgi_cache_key != false) {
validate_string($fastcgi_cache_key)
}
if ($fastcgi_cache_use_stale != false) {
validate_string($fastcgi_cache_use_stale)
}

validate_bool($mail)
validate_bool($stream)
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.')
}
validate_string($proxy_buffers)
validate_string($proxy_buffer_size)
if ($http_cfg_prepend != false) {
if !(is_hash($http_cfg_prepend) or is_array($http_cfg_prepend)) {
fail('$http_cfg_prepend must be either a hash or array')
}
}

if ($http_cfg_append != false) {
if !(is_hash($http_cfg_append) or is_array($http_cfg_append)) {
fail('$http_cfg_append must be either a hash or array')
}
}

if ($nginx_cfg_prepend != false) {
if !(is_hash($nginx_cfg_prepend) or is_array($nginx_cfg_prepend)) {
fail('$nginx_cfg_prepend must be either a hash or array')
}
}

if !(is_string($http_access_log) or is_array($http_access_log)) {
fail('$http_access_log must be either a string or array')
}

if !(is_string($nginx_error_log) or is_array($nginx_error_log)) {
fail('$nginx_error_log must be either a string or array')
}

validate_re($nginx_error_log_severity,['debug','info','notice','warn','error','crit','alert','emerg'],'$nginx_error_log_severity must be debug, info, notice, warn, error, crit, alert or emerg')
validate_string($proxy_headers_hash_bucket_size)
validate_bool($super_user)
### END VALIDATIONS ###


### CONFIGURATION ###
File {
owner => $global_owner,
group => $global_group,
Expand Down
Loading

0 comments on commit 471ae97

Please sign in to comment.