Skip to content

Commit

Permalink
Merge pull request voxpupuli#709 from Phil-Friderici/severity_level
Browse files Browse the repository at this point in the history
Add parameter to allow setting error_log severity level
  • Loading branch information
jfryman committed Nov 2, 2015
2 parents e40551f + 86801a1 commit 1b57f29
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$log_dir = $::nginx::params::log_dir,
$http_access_log = $::nginx::params::http_access_log,
$nginx_error_log = $::nginx::params::nginx_error_log,
$nginx_error_log_severity = 'error',
$pid = $::nginx::params::pid,
$proxy_temp_path = $::nginx::params::proxy_temp_path,
$root_group = $::nginx::params::root_group,
Expand Down Expand Up @@ -169,6 +170,7 @@
}

validate_string($nginx_error_log)
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($http_access_log)
validate_string($proxy_headers_hash_bucket_size)
validate_bool($super_user)
Expand Down
14 changes: 13 additions & 1 deletion spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@
:title => 'should set error_log',
:attr => 'nginx_error_log',
:value => '/path/to/error.log',
:match => 'error_log /path/to/error.log;',
:match => 'error_log /path/to/error.log error;',
},
{
:title => 'should set error_log severity level',
:attr => 'nginx_error_log_severity',
:value => 'warn',
:match => 'error_log /var/log/nginx/error.log warn;',
},
{
:title => 'should set pid',
Expand Down Expand Up @@ -560,5 +566,11 @@
it { is_expected.to contain_file("/var/nginx/proxy_temp").with(:owner => 'www-data')}
it { is_expected.to contain_file("/etc/nginx/nginx.conf").with_content %r{^user www-data;}}
end

context "when nginx_error_log_severity = invalid" do
let(:params) {{:nginx_error_log_severity => 'invalid'}}

it { expect { is_expected.to contain_class('nginx::config') }.to raise_error(Puppet::Error,/\$nginx_error_log_severity must be debug, info, notice, warn, error, crit, alert or emerg/) }
end
end
end
2 changes: 1 addition & 1 deletion templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ worker_rlimit_nofile <%= @worker_rlimit_nofile %>;
<% if @pid -%>
pid <%= @pid %>;
<% end -%>
error_log <%= @nginx_error_log %>;
error_log <%= @nginx_error_log %> <%= @nginx_error_log_severity %>;

<% if @nginx_cfg_prepend -%>
<%- field_width = @nginx_cfg_prepend.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
Expand Down

0 comments on commit 1b57f29

Please sign in to comment.