Skip to content

Commit

Permalink
Merge pull request voxpupuli#1396 from juokelis/debug_connection
Browse files Browse the repository at this point in the history
Add debug_connection events option
  • Loading branch information
alexjfisher committed Aug 30, 2020
2 parents 4d9ba8a + 780e47c commit c9033fb
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
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') }
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:']]

0 comments on commit c9033fb

Please sign in to comment.