diff --git a/manifests/config.pp b/manifests/config.pp index 9c04b0182..16a638963 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -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 diff --git a/manifests/init.pp b/manifests/init.pp index 3836e46d7..c75bd2e69 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, @@ -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', diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 02478e1b6..91ecb3bb2 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -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 diff --git a/spec/type_aliases/debugconnection_spec.rb b/spec/type_aliases/debugconnection_spec.rb new file mode 100644 index 000000000..d9d4cb4cd --- /dev/null +++ b/spec/type_aliases/debugconnection_spec.rb @@ -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 diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index a6605c283..5bcbc7958 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -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 -%> } diff --git a/types/debugconnection.pp b/types/debugconnection.pp new file mode 100644 index 000000000..399fc4bb5 --- /dev/null +++ b/types/debugconnection.pp @@ -0,0 +1 @@ +type Nginx::DebugConnection = Variant[Stdlib::Host, Stdlib::IP::Address, Enum['unix:']]