Skip to content

Commit

Permalink
Merge pull request #314 from janorn/pull_269
Browse files Browse the repository at this point in the history
Pull request 269 revisited
  • Loading branch information
James Fryman committed Jun 23, 2014
2 parents 74855ff + 5b28d05 commit 09b42b9
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 21 deletions.
23 changes: 17 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# This class file is not called directly
class nginx::config(
$client_body_buffer_size = $nginx::params::nx_client_body_buffer_size,
$client_body_temp_path = $nginx::params::nx_client_body_temp_path,
$client_max_body_size = $nginx::params::nx_client_max_body_size,
$confd_purge = $nginx::params::nx_confd_purge,
$conf_dir = $nginx::params::nx_conf_dir,
Expand All @@ -31,10 +32,16 @@
$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,
$nginx_error_log = $nginx::params::nx_nginx_error_log,
$pid = $nginx::params::nx_pid,
$proxy_buffers = $nginx::params::nx_proxy_buffers,
$proxy_buffer_size = $nginx::params::nx_proxy_buffer_size,
$proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive,
Expand All @@ -50,15 +57,19 @@
$proxy_redirect = $nginx::params::nx_proxy_redirect,
$proxy_send_timeout = $nginx::params::nx_proxy_send_timeout,
$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,
$super_user = $nginx::params::nx_super_user,
$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,
$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,
$worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile
) inherits nginx::params {

File {
Expand Down Expand Up @@ -99,16 +110,16 @@
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 => $daemon_user,
}

file {$nginx::config::nx_proxy_temp_path:
file {$proxy_temp_path:
ensure => directory,
owner => $daemon_user,
}
Expand Down Expand Up @@ -157,14 +168,14 @@
ensure => absent,
}

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
25 changes: 25 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# }
class nginx (
$client_body_buffer_size = $nginx::params::nx_client_body_buffer_size,
$client_body_temp_path = $nginx::params::nx_client_body_temp_path,
$client_max_body_size = $nginx::params::nx_client_max_body_size,
$confd_purge = $nginx::params::nx_confd_purge,
$configtest_enable = $nginx::params::nx_configtest_enable,
Expand All @@ -47,6 +48,10 @@
$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,
$manage_repo = $nginx::params::manage_repo,
$multi_accept = $nginx::params::nx_multi_accept,
Expand All @@ -60,6 +65,7 @@
$package_ensure = $nginx::params::package_ensure,
$package_name = $nginx::params::package_name,
$package_source = $nginx::params::package_source,
$pid = $nginx::params::nx_pid,
$proxy_buffers = $nginx::params::nx_proxy_buffers,
$proxy_buffer_size = $nginx::params::nx_proxy_buffer_size,
$proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive,
Expand All @@ -75,11 +81,17 @@
$proxy_redirect = $nginx::params::nx_proxy_redirect,
$proxy_send_timeout = $nginx::params::nx_proxy_send_timeout,
$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_ensure = $nginx::params::nx_service_ensure,
$service_restart = $nginx::params::nx_service_restart,
$spdy = $nginx::params::nx_spdy,
$super_user = $nginx::params::nx_super_user,
$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,
$vhost_purge = $nginx::params::nx_vhost_purge,
$worker_connections = $nginx::params::nx_worker_connections,
$worker_processes = $nginx::params::nx_worker_processes,
Expand Down Expand Up @@ -175,6 +187,7 @@

class { 'nginx::config':
client_body_buffer_size => $client_body_buffer_size,
client_body_temp_path => $client_body_temp_path,
client_max_body_size => $client_max_body_size,
confd_purge => $confd_purge,
conf_dir => $conf_dir,
Expand All @@ -191,10 +204,16 @@
gzip => $gzip,
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,
nginx_error_log => $nginx_error_log,
pid => $pid,
proxy_buffers => $proxy_buffers,
proxy_buffer_size => $proxy_buffer_size,
proxy_cache_inactive => $proxy_cache_inactive,
Expand All @@ -210,9 +229,15 @@
proxy_redirect => $proxy_redirect,
proxy_send_timeout => $proxy_send_timeout,
proxy_set_header => $proxy_set_header,
proxy_temp_path => $proxy_temp_path,
run_dir => $run_dir,
sendfile => $sendfile,
server_tokens => $server_tokens,
spdy => $spdy,
super_user => $super_user,
temp_dir => $temp_dir,
types_hash_bucket_size => $types_hash_bucket_size,
types_hash_max_size => $types_hash_max_size,
vhost_purge => $vhost_purge,
worker_connections => $worker_connections,
worker_processes => $worker_processes,
Expand Down
3 changes: 2 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 = off
$nx_gzip = on
$nx_server_tokens = on
$nx_spdy = off
Expand Down
10 changes: 5 additions & 5 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
$ssl_stapling_responder = undef,
$ssl_stapling_verify = false,
$ssl_trusted_cert = undef,
$spdy = $nginx::params::nx_spdy,
$spdy = $nginx::config::spdy,
$proxy = undef,
$proxy_read_timeout = $nginx::config::proxy_read_timeout,
$proxy_connect_timeout = $nginx::config::proxy_connect_timeout,
Expand Down Expand Up @@ -377,7 +377,7 @@
# Also opted to add more logic here and keep template cleaner which
# unfortunately means resorting to the $varname_real thing
$access_log_tmp = $access_log ? {
undef => "${nginx::params::nx_logdir}/${name_sanitized}.access.log",
undef => "${nginx::config::logdir}/${name_sanitized}.access.log",
default => $access_log,
}

Expand All @@ -387,7 +387,7 @@
}

$error_log_real = $error_log ? {
undef => "${nginx::params::nx_logdir}/${name_sanitized}.error.log",
undef => "${nginx::config::logdir}/${name_sanitized}.error.log",
default => $error_log,
}

Expand Down Expand Up @@ -489,7 +489,7 @@
# Also opted to add more logic here and keep template cleaner which
# unfortunately means resorting to the $varname_real thing
$ssl_access_log_tmp = $access_log ? {
undef => "${nginx::params::nx_logdir}/ssl-${name_sanitized}.access.log",
undef => "${nginx::config::logdir}/ssl-${name_sanitized}.access.log",
default => $access_log,
}

Expand All @@ -499,7 +499,7 @@
}

$ssl_error_log_real = $error_log ? {
undef => "${nginx::params::nx_logdir}/ssl-${name_sanitized}.error.log",
undef => "${nginx::config::logdir}/ssl-${name_sanitized}.error.log",
default => $error_log,
}

Expand Down
25 changes: 16 additions & 9 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
user <%= @daemon_user %>;
<% end -%>
worker_processes <%= @worker_processes %>;
worker_rlimit_nofile <%= @worker_rlimit_nofile %>;
<% if @worker_rlimit_nofile %>worker_rlimit_nofile <%= @worker_rlimit_nofile %>;<% end -%>

error_log <%= @nginx_error_log %>;
<% if scope.lookupvar('nginx::params::nx_pid') != false %>pid <%= scope.lookupvar('nginx::params::nx_pid')%>;<% end -%>
<% if @pid -%>
pid <%= @pid %>;
<% end -%>

events {
worker_connections <%= @worker_connections -%>;
Expand All @@ -23,20 +25,25 @@ http {

access_log <%= @http_access_log %>;

sendfile <%= @sendfile %>;
<% if @sendfile == 'on' -%>
sendfile on;
<% if @http_tcp_nopush == 'on' -%>
tcp_nopush on;
<% end -%>
<% end -%>

server_tokens <%= @server_tokens %>;

types_hash_max_size <%= scope.lookupvar('nginx::params::nx_types_hash_max_size')%>;
types_hash_bucket_size <%= scope.lookupvar('nginx::params::nx_types_hash_bucket_size')%>;
types_hash_max_size <%= @types_hash_max_size %>;
types_hash_bucket_size <%= @types_hash_bucket_size %>;

server_names_hash_bucket_size <%= @names_hash_bucket_size %>;
server_names_hash_max_size <%= @names_hash_max_size %>;

keepalive_timeout <%= scope.lookupvar('nginx::params::nx_keepalive_timeout')%>;
tcp_nodelay <%= scope.lookupvar('nginx::params::nx_tcp_nodelay')%>;
keepalive_timeout <%= @keepalive_timeout %>;
tcp_nodelay <%= @http_tcp_nodelay %>;

<% if @gzip == 'on' %>
<% if @gzip == 'on' -%>
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
<% end -%>
Expand Down Expand Up @@ -64,7 +71,7 @@ http {
include <%= @conf_dir %>/sites-enabled/*;

}
<% if scope.lookupvar('nginx::mail') %>
<% if @mail -%>
mail {
include <%= @conf_dir %>/conf.mail.d/*.conf;
}
Expand Down

0 comments on commit 09b42b9

Please sign in to comment.