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

Add debug_connection events option #1396

Merged
merged 2 commits into from
Aug 30, 2020
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
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
$lingering_timeout = $nginx::lingering_timeout
$etag = $nginx::etag
$events_use = $nginx::events_use
$debug_connections = $nginx::debug_connections
$fastcgi_cache_inactive = $nginx::fastcgi_cache_inactive
$fastcgi_cache_key = $nginx::fastcgi_cache_key
$fastcgi_cache_keys_zone = $nginx::fastcgi_cache_keys_zone
Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
# already installed. If the fact is unavailable, it defaults to '1.6.0'.
# You may need to set this manually to get a working and idempotent
# configuration.
#
# @param debug_connections
# Configures nginx `debug_connection` lines in the `events` section of the nginx config.
# See http://nginx.org/en/docs/ngx_core_module.html#debug_connection
class nginx (
### START Nginx Configuration ###
Variant[Stdlib::Absolutepath, Boolean] $client_body_temp_path = $nginx::params::client_body_temp_path,
Expand Down Expand Up @@ -88,6 +92,7 @@
$lingering_timeout = '5s',
Optional[Enum['on', 'off']] $etag = undef,
Optional[String] $events_use = undef,
Array[Nginx::DebugConnection] $debug_connections = [],
String $fastcgi_cache_inactive = '20m',
Optional[String] $fastcgi_cache_key = undef,
String $fastcgi_cache_keys_zone = 'd3:100m',
Expand Down
9 changes: 9 additions & 0 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,15 @@
attr: 'ssl_password_file',
value: '/path/to/password_file',
match: ' ssl_password_file /path/to/password_file;'
},
{
title: 'should contain debug_connection directives',
attr: 'debug_connections',
value: %w[127.0.0.1 unix:],
match: [
' debug_connection 127.0.0.1;',
' debug_connection unix:;'
]
}
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
Expand Down
10 changes: 10 additions & 0 deletions spec/type_aliases/debugconnection_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'spec_helper'

describe 'Nginx::DebugConnection' do
it { is_expected.to allow_value('127.0.0.1') }
it { is_expected.to allow_value('localhost') }
it { is_expected.to allow_value('192.0.2.0/24') }
it { is_expected.to allow_value('::1') }
it { is_expected.to allow_value('2001:0db8::/32') }
juokelis marked this conversation as resolved.
Show resolved Hide resolved
it { is_expected.to allow_value('unix:') }
end
7 changes: 5 additions & 2 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ events {
<%- end -%>
worker_connections <%= @worker_connections -%>;
<%- if @multi_accept == 'on' -%>
multi_accept on;
multi_accept on;
<%- end -%>
<%- if @events_use -%>
use <%= @events_use %>;
use <%= @events_use %>;
<%- end -%>
<%- @debug_connections.each do |address| -%>
debug_connection <%= address %>;
<%- end -%>
}

Expand Down
1 change: 1 addition & 0 deletions types/debugconnection.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Nginx::DebugConnection = Variant[Stdlib::Host, Stdlib::IP::Address, Enum['unix:']]