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

Various updates #1250

Closed
wants to merge 6 commits 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
20 changes: 12 additions & 8 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$global_group = $nginx::global_group
$global_mode = $nginx::global_mode
$log_dir = $nginx::log_dir
$log_user = $nginx::log_user
$log_group = $nginx::log_group
$log_mode = $nginx::log_mode
$http_access_log = $nginx::http_access_log
Expand Down Expand Up @@ -178,19 +179,22 @@
file { $log_dir:
ensure => directory,
mode => $log_mode,
owner => $daemon_user,
owner => $log_user,
group => $log_group,
}

file {$client_body_temp_path:
ensure => directory,
owner => $daemon_user,
if $client_body_temp_path {
file {$client_body_temp_path:
ensure => directory,
owner => $daemon_user,
}
}


file {$proxy_temp_path:
ensure => directory,
owner => $daemon_user,
if $proxy_temp_path {
file {$proxy_temp_path:
ensure => directory,
owner => $daemon_user,
}
}

unless $confd_only {
Expand Down
21 changes: 11 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# }
class nginx (
### START Nginx Configuration ###
$client_body_temp_path = $nginx::params::client_body_temp_path,
Variant[Stdlib::Absolutepath, Boolean] $client_body_temp_path = $nginx::params::client_body_temp_path,
Boolean $confd_only = false,
Boolean $confd_purge = false,
$conf_dir = $nginx::params::conf_dir,
Expand All @@ -37,15 +37,16 @@
$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',
Stdlib::Absolutepath $log_dir = $nginx::params::log_dir,
String $log_user = $nginx::params::log_user,
String $log_group = $nginx::params::log_group,
Stdlib::Filemode $log_mode = $nginx::params::log_mode,
Variant[String, Array[String]] $http_access_log = "${log_dir}/${nginx::params::http_access_log_file}",
$http_format_log = undef,
Variant[String, Array[String]] $nginx_error_log = "${log_dir}/${nginx::params::nginx_error_log_file}",
Nginx::ErrorLogSeverity $nginx_error_log_severity = 'error',
$pid = $nginx::params::pid,
$proxy_temp_path = $nginx::params::proxy_temp_path,
Variant[Stdlib::Absolutepath, Boolean] $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,
Expand Down Expand Up @@ -126,10 +127,10 @@
Array $proxy_hide_header = [],
Array $proxy_pass_header = [],
Array $proxy_ignore_header = [],
$sendfile = 'on',
String $server_tokens = 'on',
$spdy = 'off',
$http2 = 'off',
Enum['on', 'off'] $sendfile = 'on',
Enum['on', 'off'] $server_tokens = 'on',
Enum['on', 'off'] $spdy = 'off',
Enum['on', 'off'] $http2 = 'off',
$ssl_stapling = 'off',
$types_hash_bucket_size = '512',
$types_hash_max_size = '1024',
Expand All @@ -146,7 +147,7 @@
$package_name = $nginx::params::package_name,
$package_source = 'nginx',
$package_flavor = undef,
$manage_repo = $nginx::params::manage_repo,
Boolean $manage_repo = $nginx::params::manage_repo,
Hash[String[1], String[1]] $mime_types = $nginx::params::mime_types,
Optional[String] $repo_release = undef,
$passenger_package_ensure = 'present',
Expand Down
22 changes: 15 additions & 7 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
### Operating System Configuration
## This is my hacky... no hiera system. Oh well. :)
$_module_defaults = {
'conf_dir' => '/etc/nginx',
'daemon_user' => 'nginx',
'pid' => '/var/run/nginx.pid',
'root_group' => 'root',
'log_dir' => '/var/log/nginx',
'log_group' => 'root',
'run_dir' => '/var/nginx',
'conf_dir' => '/etc/nginx',
'daemon_user' => 'nginx',
'pid' => '/var/run/nginx.pid',
'root_group' => 'root',
'log_dir' => '/var/log/nginx',
'log_user' => 'nginx',
'log_group' => 'root',
'log_mode' => '0755',
'run_dir' => '/var/nginx',
'package_name' => 'nginx',
'manage_repo' => false,
'mime_types' => {
Expand Down Expand Up @@ -109,12 +111,16 @@
$_module_os_overrides = {
'manage_repo' => true,
'daemon_user' => 'www-data',
'log_user' => 'root',
'log_group' => 'adm',
'log_mode' => '0755',
}
} else {
$_module_os_overrides = {
'daemon_user' => 'www-data',
'log_user' => 'root',
'log_group' => 'adm',
'log_mode' => '0755',
}
}
}
Expand Down Expand Up @@ -178,7 +184,9 @@
### Referenced Variables
$conf_dir = $_module_parameters['conf_dir']
$log_dir = $_module_parameters['log_dir']
$log_user = $_module_parameters['log_user']
$log_group = $_module_parameters['log_group']
$log_mode = $_module_parameters['log_mode']
$run_dir = $_module_parameters['run_dir']
$temp_dir = '/tmp'
$pid = $_module_parameters['pid']
Expand Down
4 changes: 2 additions & 2 deletions manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
Variant[Array, String] $ipv6_listen_ip = '::',
Integer $ipv6_listen_port = 80,
String $ipv6_listen_options = 'default ipv6only=on',
Optional[Hash] $add_header = undef,
Hash $add_header = {},
Boolean $ssl = false,
Boolean $ssl_listen_option = true,
Optional[Variant[String, Boolean]] $ssl_cert = undef,
Expand Down Expand Up @@ -184,7 +184,7 @@
Optional[String] $ssl_trusted_cert = undef,
Optional[Integer] $ssl_verify_depth = undef,
String $spdy = $nginx::spdy,
$http2 = $nginx::http2,
Enum['on', 'off'] $http2 = $nginx::http2,
Optional[String] $proxy = undef,
Optional[String]$proxy_redirect = undef,
String $proxy_read_timeout = $nginx::proxy_read_timeout,
Expand Down
22 changes: 11 additions & 11 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,22 +433,22 @@
title: 'should set error_log',
attr: 'nginx_error_log',
value: '/path/to/error.log',
match: 'error_log /path/to/error.log error;'
match: ' error_log /path/to/error.log error;'
},
{
title: 'should set multiple error_logs',
attr: 'nginx_error_log',
value: ['/path/to/error.log', 'syslog:server=localhost'],
match: [
'error_log /path/to/error.log error;',
'error_log syslog:server=localhost error;'
' error_log /path/to/error.log error;',
' error_log syslog:server=localhost error;'
]
},
{
title: 'should set error_log severity level',
attr: 'nginx_error_log_severity',
value: 'warn',
match: 'error_log /var/log/nginx/error.log warn;'
match: ' error_log /var/log/nginx/error.log warn;'
},
{
title: 'should set pid',
Expand Down Expand Up @@ -544,22 +544,22 @@
title: 'should set access_log',
attr: 'http_access_log',
value: '/path/to/access.log',
match: ' access_log /path/to/access.log;'
match: ' access_log /path/to/access.log;'
},
{
title: 'should set multiple access_logs',
attr: 'http_access_log',
value: ['/path/to/access.log', 'syslog:server=localhost'],
match: [
' access_log /path/to/access.log;',
' access_log syslog:server=localhost;'
' access_log /path/to/access.log;',
' access_log syslog:server=localhost;'
]
},
{
title: 'should set custom log format',
attr: 'http_format_log',
value: 'mycustomformat',
match: ' access_log /var/log/nginx/access.log mycustomformat;'
match: ' access_log /var/log/nginx/access.log mycustomformat;'
},
{
title: 'should set sendfile',
Expand All @@ -570,7 +570,7 @@
{
title: 'should not set sendfile',
attr: 'sendfile',
value: false,
value: 'off',
notmatch: %r{sendfile}
},
{
Expand Down Expand Up @@ -1183,12 +1183,12 @@
it { is_expected.to contain_file('/foo/bar').with(ensure: 'directory') }
it do
is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(
%r{access_log /foo/bar/access.log;}
%r{access_log /foo/bar/access.log;}
)
end
it do
is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(
%r{error_log /foo/bar/error.log error;}
%r{error_log /foo/bar/error.log error;}
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions templates/conf.d/mime.types.epp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MANAGED BY PUPPET
types {
<% $nginx::mime_types.each |$key, $value| { %>
<% $nginx::mime_types.each |$key, $value| { -%>
<%= $key %> <%= $value %>;
<% } %>
<% } -%>
}
20 changes: 10 additions & 10 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ worker_rlimit_nofile <%= @worker_rlimit_nofile %>;
<% if @pid -%>
pid <%= @pid %>;
<% end -%>
<% if @nginx_error_log.is_a?(Array) -%>
<%- @nginx_error_log.each do |log_item| -%>
error_log <%= log_item %> <%= @nginx_error_log_severity %>;
<%- end -%>
<% else -%>
error_log <%= @nginx_error_log %> <%= @nginx_error_log_severity %>;
<% end -%>
<% if @nginx_cfg_prepend -%>

<%- field_width = @nginx_cfg_prepend.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
Expand Down Expand Up @@ -79,14 +72,21 @@ http {
<% end -%>
<% if @http_access_log.is_a?(Array) -%>
<%- @http_access_log.each do |log_item| -%>
access_log <%= log_item %><% if @http_format_log %> <%= @http_format_log%><% end %>;
access_log <%= log_item %><% if @http_format_log %> <%= @http_format_log%><% end %>;
<%- end -%>
<% else -%>
access_log <%= @http_access_log %><% if @http_format_log %> <%= @http_format_log%><% end %>;
<% end -%>
<% if @nginx_error_log.is_a?(Array) -%>
<%- @nginx_error_log.each do |log_item| -%>
error_log <%= log_item %> <%= @nginx_error_log_severity %>;
<%- end -%>
<% else -%>
access_log <%= @http_access_log %><% if @http_format_log %> <%= @http_format_log%><% end %>;
error_log <%= @nginx_error_log %> <%= @nginx_error_log_severity %>;
<% end -%>

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