diff --git a/REFERENCE.md b/REFERENCE.md
index a9b38b42a..8188c1057 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -629,7 +629,7 @@ Default value: `'on'`
##### `accept_mutex_delay`
-Data type: `Any`
+Data type: `Nginx::Time`
@@ -637,7 +637,7 @@ Default value: `'500ms'`
##### `client_body_buffer_size`
-Data type: `Any`
+Data type: `Nginx::Size`
@@ -645,7 +645,7 @@ Default value: `'128k'`
##### `client_max_body_size`
-Data type: `String`
+Data type: `Nginx::Size`
@@ -653,7 +653,7 @@ Default value: `'10m'`
##### `client_body_timeout`
-Data type: `Any`
+Data type: `Nginx::Time`
@@ -661,7 +661,7 @@ Default value: `'60s'`
##### `send_timeout`
-Data type: `Any`
+Data type: `Nginx::Time`
@@ -669,7 +669,7 @@ Default value: `'60s'`
##### `lingering_timeout`
-Data type: `Any`
+Data type: `Nginx::Time`
@@ -709,7 +709,7 @@ Default value: `undef`
##### `fastcgi_cache_inactive`
-Data type: `String`
+Data type: `Nginx::Time`
@@ -741,7 +741,7 @@ Default value: `'1'`
##### `fastcgi_cache_max_size`
-Data type: `String`
+Data type: `Nginx::Size`
@@ -773,7 +773,7 @@ Default value: `'off'`
##### `gzip_buffers`
-Data type: `Any`
+Data type: `Optional[String]`
@@ -781,7 +781,7 @@ Default value: `undef`
##### `gzip_comp_level`
-Data type: `Any`
+Data type: `Integer`
@@ -789,7 +789,7 @@ Default value: `1`
##### `gzip_disable`
-Data type: `Any`
+Data type: `String`
@@ -797,7 +797,7 @@ Default value: `'msie6'`
##### `gzip_min_length`
-Data type: `Any`
+Data type: `Integer`
@@ -805,11 +805,11 @@ Default value: `20`
##### `gzip_http_version`
-Data type: `Any`
+Data type: `Variant[Enum['1.0','1.1'], Float]`
-Default value: `1.1`
+Default value: `'1.1'`
##### `gzip_proxied`
@@ -821,7 +821,7 @@ Default value: `'off'`
##### `gzip_types`
-Data type: `Any`
+Data type: `Optional[Variant[String[1],Array[String[1]]]]`
@@ -893,7 +893,7 @@ Default value: `'off'`
##### `keepalive_timeout`
-Data type: `Any`
+Data type: `Nginx::Time`
@@ -901,11 +901,11 @@ Default value: `'65s'`
##### `keepalive_requests`
-Data type: `Any`
+Data type: `Variant[Integer, String]`
-Default value: `'100'`
+Default value: `100`
##### `log_format`
@@ -989,7 +989,7 @@ Default value: `512`
##### `nginx_cfg_prepend`
-Data type: `Any`
+Data type: `Variant[Boolean,Array,Hash]`
@@ -1005,7 +1005,7 @@ Default value: `'32 4k'`
##### `proxy_buffer_size`
-Data type: `String`
+Data type: `Nginx::Size`
@@ -1013,7 +1013,7 @@ Default value: `'8k'`
##### `proxy_cache_inactive`
-Data type: `String`
+Data type: `Nginx::Time`
@@ -1037,7 +1037,7 @@ Default value: `'1'`
##### `proxy_cache_max_size`
-Data type: `String`
+Data type: `Nginx::Size`
@@ -1085,7 +1085,7 @@ Default value: `undef`
##### `proxy_connect_timeout`
-Data type: `Any`
+Data type: `Nginx::Time`
@@ -1109,7 +1109,7 @@ Default value: `undef`
##### `proxy_read_timeout`
-Data type: `Any`
+Data type: `Nginx::Time`
@@ -1117,7 +1117,7 @@ Default value: `'90s'`
##### `proxy_redirect`
-Data type: `Any`
+Data type: `Optional[String]`
@@ -1125,7 +1125,7 @@ Default value: `undef`
##### `proxy_send_timeout`
-Data type: `Any`
+Data type: `Nginx::Time`
@@ -1256,7 +1256,7 @@ Default value: `true`
##### `types_hash_bucket_size`
-Data type: `Any`
+Data type: `Variant[Integer,String]`
@@ -1264,7 +1264,7 @@ Default value: `'512'`
##### `types_hash_max_size`
-Data type: `Any`
+Data type: `Variant[Integer,String]`
@@ -1352,7 +1352,7 @@ Default value: `'shared:SSL:10m'`
##### `ssl_session_timeout`
-Data type: `String`
+Data type: `Nginx::Time`
@@ -1432,7 +1432,7 @@ Default value: `undef`
##### `package_ensure`
-Data type: `Any`
+Data type: `String`
@@ -1440,7 +1440,7 @@ Default value: `installed`
##### `package_name`
-Data type: `Any`
+Data type: `String`
@@ -1448,7 +1448,7 @@ Default value: `$nginx::params::package_name`
##### `package_source`
-Data type: `Any`
+Data type: `String`
@@ -1456,7 +1456,7 @@ Default value: `'nginx'`
##### `package_flavor`
-Data type: `Any`
+Data type: `Optional[String]`
@@ -1496,7 +1496,7 @@ Default value: `undef`
##### `passenger_package_ensure`
-Data type: `Any`
+Data type: `String`
@@ -1528,7 +1528,7 @@ Default value: `true`
##### `service_flags`
-Data type: `Any`
+Data type: `Optional[String]`
@@ -1536,7 +1536,7 @@ Default value: `undef`
##### `service_restart`
-Data type: `Any`
+Data type: `Optional[String]`
@@ -1544,7 +1544,7 @@ Default value: `undef`
##### `service_name`
-Data type: `Any`
+Data type: `String`
@@ -1552,7 +1552,7 @@ Default value: `'nginx'`
##### `service_manage`
-Data type: `Any`
+Data type: `Boolean`
@@ -5171,13 +5171,13 @@ Variant[String[1], Struct[{
The Nginx::Size data type.
-Alias of `Pattern[/^\d+[k|K|m|M]?$/]`
+Alias of `Variant[Integer[0], Pattern[/\A\d+[k|K|m|M]?\z/]]`
### `Nginx::Time`
The Nginx::Time data type.
-Alias of `Pattern[/^\d+(ms|s|m|h|d|w|M|y)?$/]`
+Alias of `Variant[Integer[0], Pattern[/^(?!$)((\d+y *)?(\d+M *)?(\d+w *)?(\d+d *)?(\d+h *)?(\d+m *)?(\d+s *)?(\d+ms)?|\d+)$/]]`
### `Nginx::UpstreamCustomParameters`
diff --git a/manifests/init.pp b/manifests/init.pp
index b8e46dc4c..f78afd2e5 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -88,32 +88,32 @@
### START Nginx Configuration ###
Optional[Enum['on', 'off']] $absolute_redirect = undef,
Enum['on', 'off'] $accept_mutex = 'on',
- $accept_mutex_delay = '500ms',
- $client_body_buffer_size = '128k',
- String $client_max_body_size = '10m',
- $client_body_timeout = '60s',
- $send_timeout = '60s',
- $lingering_timeout = '5s',
+ Nginx::Time $accept_mutex_delay = '500ms',
+ Nginx::Size $client_body_buffer_size = '128k',
+ Nginx::Size $client_max_body_size = '10m',
+ Nginx::Time $client_body_timeout = '60s',
+ Nginx::Time $send_timeout = '60s',
+ Nginx::Time $lingering_timeout = '5s',
Optional[Enum['on','off','always']] $lingering_close = undef,
Optional[String[1]] $lingering_time = undef,
Optional[Enum['on', 'off']] $etag = undef,
Optional[String] $events_use = undef,
Array[Nginx::DebugConnection] $debug_connections = [],
- String $fastcgi_cache_inactive = '20m',
+ Nginx::Time $fastcgi_cache_inactive = '20m',
Optional[String] $fastcgi_cache_key = undef,
String $fastcgi_cache_keys_zone = 'd3:100m',
String $fastcgi_cache_levels = '1',
- String $fastcgi_cache_max_size = '500m',
+ Nginx::Size $fastcgi_cache_max_size = '500m',
Optional[String] $fastcgi_cache_path = undef,
Optional[String] $fastcgi_cache_use_stale = undef,
Enum['on', 'off'] $gzip = 'off',
- $gzip_buffers = undef,
- $gzip_comp_level = 1,
- $gzip_disable = 'msie6',
- $gzip_min_length = 20,
- $gzip_http_version = 1.1,
+ Optional[String] $gzip_buffers = undef,
+ Integer $gzip_comp_level = 1,
+ String $gzip_disable = 'msie6',
+ Integer $gzip_min_length = 20,
+ Variant[Enum['1.0','1.1'], Float] $gzip_http_version = '1.1',
Nginx::GzipProxied $gzip_proxied = 'off',
- $gzip_types = undef,
+ Optional[Variant[String[1],Array[String[1]]]] $gzip_types = undef,
Enum['on', 'off'] $gzip_vary = 'off',
Optional[Enum['on', 'off', 'always']] $gzip_static = undef,
Optional[Variant[Hash, Array]] $http_cfg_prepend = undef,
@@ -122,8 +122,8 @@
Optional[Variant[Array[String], String]] $http_raw_append = undef,
Enum['on', 'off'] $http_tcp_nodelay = 'on',
Enum['on', 'off'] $http_tcp_nopush = 'off',
- $keepalive_timeout = '65s',
- $keepalive_requests = '100',
+ Nginx::Time $keepalive_timeout = '65s',
+ Variant[Integer, String] $keepalive_requests = 100,
Hash[String[1], Nginx::LogFormat] $log_format = {},
Hash[String[1], Nginx::LogFormat] $stream_log_format = {},
Boolean $mail = false,
@@ -134,24 +134,24 @@
String $multi_accept = 'off',
Integer $names_hash_bucket_size = 64,
Integer $names_hash_max_size = 512,
- $nginx_cfg_prepend = false,
+ Variant[Boolean,Array,Hash] $nginx_cfg_prepend = false,
String $proxy_buffers = '32 4k',
- String $proxy_buffer_size = '8k',
- String $proxy_cache_inactive = '20m',
+ Nginx::Size $proxy_buffer_size = '8k',
+ Nginx::Time $proxy_cache_inactive = '20m',
String $proxy_cache_keys_zone = 'd2:100m',
String $proxy_cache_levels = '1',
- String $proxy_cache_max_size = '500m',
+ Nginx::Size $proxy_cache_max_size = '500m',
Optional[Variant[Hash, String]] $proxy_cache_path = undef,
Optional[Integer] $proxy_cache_loader_files = undef,
Optional[String] $proxy_cache_loader_sleep = undef,
Optional[String] $proxy_cache_loader_threshold = undef,
Optional[Enum['on', 'off']] $proxy_use_temp_path = undef,
- $proxy_connect_timeout = '90s',
+ Nginx::Time $proxy_connect_timeout = '90s',
Integer $proxy_headers_hash_bucket_size = 64,
Optional[String] $proxy_http_version = undef,
- $proxy_read_timeout = '90s',
- $proxy_redirect = undef,
- $proxy_send_timeout = '90s',
+ Nginx::Time $proxy_read_timeout = '90s',
+ Optional[String] $proxy_redirect = undef,
+ Nginx::Time $proxy_send_timeout = '90s',
Array $proxy_set_header = [
'Host $host',
'X-Real-IP $remote_addr',
@@ -173,8 +173,8 @@
Enum['on', 'off'] $ssl_stapling_verify = 'off',
Stdlib::Absolutepath $snippets_dir = $nginx::params::snippets_dir,
Boolean $manage_snippets_dir = true,
- $types_hash_bucket_size = '512',
- $types_hash_max_size = '1024',
+ Variant[Integer,String] $types_hash_bucket_size = '512',
+ Variant[Integer,String] $types_hash_max_size = '1024',
Integer $worker_connections = 1024,
Enum['on', 'off'] $ssl_prefer_server_ciphers = 'on',
Variant[Integer, Enum['auto']] $worker_processes = 'auto',
@@ -185,7 +185,7 @@
Optional[Stdlib::Unixpath] $ssl_dhparam = undef,
Optional[String] $ssl_ecdh_curve = undef,
String $ssl_session_cache = 'shared:SSL:10m',
- String $ssl_session_timeout = '5m',
+ Nginx::Time $ssl_session_timeout = '5m',
Optional[Enum['on', 'off']] $ssl_session_tickets = undef,
Optional[Stdlib::Absolutepath] $ssl_session_ticket_key = undef,
Optional[String] $ssl_buffer_size = undef,
@@ -198,15 +198,15 @@
Optional[Enum['on', 'off']] $reset_timedout_connection = undef,
### START Package Configuration ###
- $package_ensure = installed,
- $package_name = $nginx::params::package_name,
- $package_source = 'nginx',
- $package_flavor = undef,
+ String $package_ensure = installed,
+ String $package_name = $nginx::params::package_name,
+ String $package_source = 'nginx',
+ Optional[String] $package_flavor = undef,
Boolean $manage_repo = $nginx::params::manage_repo,
Hash[String[1], String[1]] $mime_types = $nginx::params::mime_types,
Boolean $mime_types_preserve_defaults = false,
Optional[String] $repo_release = undef,
- $passenger_package_ensure = installed,
+ String $passenger_package_ensure = installed,
String[1] $passenger_package_name = $nginx::params::passenger_package_name,
Optional[Stdlib::HTTPUrl] $repo_source = undef,
### END Package Configuration ###
@@ -214,10 +214,10 @@
### START Service Configuation ###
Stdlib::Ensure::Service $service_ensure = 'running',
Boolean $service_enable = true,
- $service_flags = undef,
- $service_restart = undef,
- $service_name = 'nginx',
- $service_manage = true,
+ Optional[String] $service_flags = undef,
+ Optional[String] $service_restart = undef,
+ String $service_name = 'nginx',
+ Boolean $service_manage = true,
Boolean $service_config_check = false,
String $service_config_check_command = 'nginx -t',
### END Service Configuration ###
@@ -244,6 +244,13 @@
### END Hiera Lookups ###
) inherits nginx::params {
+ if $gzip_http_version =~ Float {
+ deprecation('gzip_http_version', 'Passing a Float is deprecated, please pass a String')
+ }
+ if $keepalive_requests =~ String {
+ deprecation('keepalive_requests', 'Passing a String is deprecated, please pass a Integer')
+ }
+
contain 'nginx::package'
contain 'nginx::config'
contain 'nginx::service'
diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb
index dd9aec234..ae70a3f08 100644
--- a/spec/classes/nginx_spec.rb
+++ b/spec/classes/nginx_spec.rb
@@ -674,7 +674,7 @@
{
title: 'should set keepalive_requests',
attr: 'keepalive_requests',
- value: '345',
+ value: 345,
match: ' keepalive_requests 345;'
},
{
diff --git a/spec/type_aliases/size_spec.rb b/spec/type_aliases/size_spec.rb
index ea04586d2..daccca492 100644
--- a/spec/type_aliases/size_spec.rb
+++ b/spec/type_aliases/size_spec.rb
@@ -7,11 +7,17 @@
it { is_expected.to allow_value('1024K') }
it { is_expected.to allow_value('1m') }
it { is_expected.to allow_value('1M') }
+ it { is_expected.to allow_value(1) }
+ it { is_expected.to allow_value(1024) }
+ it { is_expected.to allow_value('1') }
+ it { is_expected.to allow_value('1024') }
it { is_expected.not_to allow_value(:undef) }
- it { is_expected.not_to allow_value(1) }
- it { is_expected.not_to allow_value(1024) }
it { is_expected.not_to allow_value('') }
+ it { is_expected.not_to allow_value(-1) }
+ it { is_expected.not_to allow_value(-1024) }
+ it { is_expected.not_to allow_value('-1') }
+ it { is_expected.not_to allow_value('-1024') }
it { is_expected.not_to allow_value('0.1k') }
it { is_expected.not_to allow_value('0.1K') }
it { is_expected.not_to allow_value('0.1m') }
diff --git a/spec/type_aliases/time_spec.rb b/spec/type_aliases/time_spec.rb
index e2ac85b0f..210dd489a 100644
--- a/spec/type_aliases/time_spec.rb
+++ b/spec/type_aliases/time_spec.rb
@@ -10,10 +10,17 @@
it { is_expected.to allow_value('1d') }
it { is_expected.to allow_value('1M') }
it { is_expected.to allow_value('1y') }
+ it { is_expected.to allow_value('1y 2M 3w 4d 5h 6m 7ms') }
+ it { is_expected.to allow_value(1) }
+ it { is_expected.to allow_value(10) }
+ it { is_expected.to allow_value('1') }
+ it { is_expected.to allow_value('10') }
it { is_expected.not_to allow_value(:undef) }
- it { is_expected.not_to allow_value(1) }
- it { is_expected.not_to allow_value(10) }
+ it { is_expected.not_to allow_value(-1) }
+ it { is_expected.not_to allow_value(-10) }
+ it { is_expected.not_to allow_value('-1') }
+ it { is_expected.not_to allow_value('-10') }
it { is_expected.not_to allow_value('') }
it { is_expected.not_to allow_value('10S') }
it { is_expected.not_to allow_value('10.0s') }
diff --git a/types/size.pp b/types/size.pp
index 580476686..3a1b421f2 100644
--- a/types/size.pp
+++ b/types/size.pp
@@ -1 +1,4 @@
-type Nginx::Size = Pattern[/^\d+[k|K|m|M]?$/]
+type Nginx::Size = Variant[
+ Integer[0],
+ Pattern[/\A\d+[k|K|m|M]?\z/],
+]
diff --git a/types/time.pp b/types/time.pp
index f6c24edc8..7b68b950d 100644
--- a/types/time.pp
+++ b/types/time.pp
@@ -1 +1,4 @@
-type Nginx::Time = Pattern[/^\d+(ms|s|m|h|d|w|M|y)?$/]
+type Nginx::Time = Variant[
+ Integer[0],
+ Pattern[/^(?!$)((\d+y *)?(\d+M *)?(\d+w *)?(\d+d *)?(\d+h *)?(\d+m *)?(\d+s *)?(\d+ms)?|\d+)$/],
+]