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

Allow specifying error_log severity for servers #1594

Merged
merged 1 commit into from
Jun 7, 2024
Merged
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
12 changes: 10 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3322,6 +3322,7 @@ The following parameters are available in the `nginx::resource::server` defined
* [`include_files`](#-nginx--resource--server--include_files)
* [`access_log`](#-nginx--resource--server--access_log)
* [`error_log`](#-nginx--resource--server--error_log)
* [`error_log_severity`](#-nginx--resource--server--error_log_severity)
* [`passenger_cgi_param`](#-nginx--resource--server--passenger_cgi_param)
* [`passenger_set_header`](#-nginx--resource--server--passenger_set_header)
* [`passenger_env_var`](#-nginx--resource--server--passenger_env_var)
Expand Down Expand Up @@ -4177,12 +4178,19 @@ Default value: `undef`

Data type: `Optional[Variant[String, Array]]`
TheMeier marked this conversation as resolved.
Show resolved Hide resolved

Where to write error log. May add additional options like error level to
the end. May set to 'absent', in which case it will be omitted in this
Where to write error log. May be set to 'absent', in which case it will be omitted in this
server stanza (and default to nginx.conf setting)

Default value: `undef`

##### <a name="-nginx--resource--server--error_log_severity"></a>`error_log_severity`

Data type: `Optional[Nginx::ErrorLogSeverity]`

Optional error level

Default value: `undef`

##### <a name="-nginx--resource--server--passenger_cgi_param"></a>`passenger_cgi_param`

Data type: `Optional[Hash]`
Expand Down
6 changes: 4 additions & 2 deletions manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@
# server stanza, rather than setting a default. Can also be disabled for this
# server with the string 'off'.
# @param error_log
# Where to write error log. May add additional options like error level to
# the end. May set to 'absent', in which case it will be omitted in this
# Where to write error log. May be set to 'absent', in which case it will be omitted in this
# server stanza (and default to nginx.conf setting)
# @param error_log_severity
# Optional error level
# @param passenger_cgi_param
# Allows one to define additional CGI environment variables to pass to the backend application
# @param passenger_set_header
Expand Down Expand Up @@ -399,6 +400,7 @@
Optional[Array[String]] $include_files = undef,
Optional[Variant[String, Array]] $access_log = undef,
Optional[Variant[String, Array]] $error_log = undef,
Optional[Nginx::ErrorLogSeverity] $error_log_severity = undef,
Optional[String] $format_log = $nginx::http_format_log,
Optional[Hash] $passenger_cgi_param = undef,
Optional[Hash] $passenger_set_header = undef,
Expand Down
24 changes: 24 additions & 0 deletions spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,18 @@
' error_log syslog:server=localhost;'
]
},
{
title: 'should set error_log severity level',
attr: 'error_log_severity',
value: 'warn',
match: ' error_log /var/log/nginx/www.rspec.example.com.error.log warn;'
},
{
title: 'should not set error_log severity level',
attr: 'error_log_severity',
value: :undef,
match: ' error_log /var/log/nginx/www.rspec.example.com.error.log;'
},
{
title: 'should not include error_log in server when set to absent',
attr: 'error_log',
Expand Down Expand Up @@ -1017,6 +1029,18 @@
' error_log syslog:server=localhost;'
]
},
{
title: 'should set error_log severity level',
attr: 'error_log_severity',
value: 'warn',
match: ' error_log /var/log/nginx/ssl-www.rspec.example.com.error.log warn;'
},
{
title: 'should not set error_log severity level',
attr: 'error_log_severity',
value: :undef,
match: ' error_log /var/log/nginx/ssl-www.rspec.example.com.error.log;'
},
{
title: 'should not include error_log in server when set to absent',
attr: 'error_log',
Expand Down Expand Up @@ -1448,7 +1472,7 @@

# TODO: implement test after this can be tested
# msg = %r{nginx: ssl must be true if listen_port is the same as ssl_port}
it 'Testing for warnings not yet implemented in classes'

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on almalinux-8-x86_64 with Facter 4.2.14 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on almalinux-9-x86_64 with Facter 4.2.14 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on archlinux-rolling-x86_64 with Facter 4.2.9 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on centos-9-x86_64 with Facter 4.2.14 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on debian-11-x86_64 with Facter 4.2.14 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on debian-12-x86_64 with Facter 4.2.14 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on oraclelinux-8-x86_64 with Facter 4.2.2 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on oraclelinux-9-x86_64 with Facter 4.2.2 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on redhat-8-x86_64 with Facter 4.2.14 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

nginx::resource::server on redhat-9-x86_64 with Facter 4.2.14 and Puppet 8.6.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on almalinux-8-x86_64 with Facter 4.2.14 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on almalinux-9-x86_64 with Facter 4.2.14 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on archlinux-rolling-x86_64 with Facter 4.2.9 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on centos-9-x86_64 with Facter 4.2.14 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on debian-11-x86_64 with Facter 4.2.14 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on debian-12-x86_64 with Facter 4.2.14 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on oraclelinux-8-x86_64 with Facter 4.2.2 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on oraclelinux-9-x86_64 with Facter 4.2.2 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on redhat-8-x86_64 with Facter 4.2.14 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented

Check warning on line 1475 in spec/defines/resource_server_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

nginx::resource::server on redhat-9-x86_64 with Facter 4.2.14 and Puppet 7.30.0 os-independent items attribute resources when listen_port == ssl_port but ssl = false Testing for warnings not yet implemented in classes Skipped: Not yet implemented
end

context 'when listen_port != ssl_port' do
Expand Down
12 changes: 6 additions & 6 deletions templates/server/server_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ server {
<% end -%>
<% if @error_log.is_a?(Array) -%>
<%- @error_log.each do |log_item| -%>
error_log <%= log_item %>;
error_log <%= log_item %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<%- end -%>
<% elsif @error_log == 'absent' -%>
<% elsif not @error_log -%>
error_log <%= scope['nginx::config::log_dir'] %>/<%= @name_sanitized %>.error.log;
error_log <%= scope['nginx::config::log_dir'] %>/<%= @name_sanitized %>.error.log<% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% else -%>
error_log <%= @error_log %>;
error_log <%= @error_log %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% end -%>
}

Expand Down Expand Up @@ -200,13 +200,13 @@ server {
<% end -%>
<% if @error_log.is_a?(Array) -%>
<%- @error_log.each do |log_item| -%>
error_log <%= log_item %>;
error_log <%= log_item %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<%- end -%>
<% elsif @error_log == 'absent' -%>
<% elsif not @error_log -%>
error_log <%= scope['nginx::config::log_dir'] %>/<%= @name_sanitized %>.error.log;
error_log <%= scope['nginx::config::log_dir'] %>/<%= @name_sanitized %>.error.log<% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% else -%>
error_log <%= @error_log %>;
error_log <%= @error_log %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% end -%>
<% if @error_pages -%>

Expand Down
12 changes: 6 additions & 6 deletions templates/server/server_ssl_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ server {
<% end -%>
<% if @error_log.is_a?(Array) -%>
<%- @error_log.each do |log_item| -%>
error_log <%= log_item %>;
error_log <%= log_item %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<%- end -%>
<% elsif @error_log == 'absent' -%>
<% elsif not @error_log -%>
error_log <%= scope['nginx::config::log_dir'] %>/ssl-<%= @name_sanitized %>.error.log;
error_log <%= scope['nginx::config::log_dir'] %>/ssl-<%= @name_sanitized %>.error.log<% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% else -%>
error_log <%= @error_log %>;
error_log <%= @error_log %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% end -%>
<%= scope.function_template(["nginx/server/server_ssl_settings.erb"]) %>

Expand Down Expand Up @@ -129,13 +129,13 @@ server {
<% end -%>
<% if @error_log.is_a?(Array) -%>
<%- @error_log.each do |log_item| -%>
error_log <%= log_item %>;
error_log <%= log_item %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<%- end -%>
<% elsif @error_log == 'absent' -%>
<% elsif not @error_log -%>
error_log <%= scope['nginx::config::log_dir'] %>/ssl-<%= @name_sanitized %>.error.log;
error_log <%= scope['nginx::config::log_dir'] %>/ssl-<%= @name_sanitized %>.error.log<% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% else -%>
error_log <%= @error_log %>;
error_log <%= @error_log %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% end -%>
<% if @error_pages -%>

Expand Down