Skip to content

Commit

Permalink
make directory mode configurable for X_tmp_path
Browse files Browse the repository at this point in the history
nginx manages the directory permissions on its own, so the default
value is undef to avoid conflicts.
  • Loading branch information
UiP9AV6Y committed Oct 7, 2021
1 parent fa6254d commit bf5e198
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 10 deletions.
18 changes: 18 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The following parameters are available in the `nginx` class:
* [`service_config_check_command`](#service_config_check_command)
* [`reset_timedout_connection`](#reset_timedout_connection)
* [`client_body_temp_path`](#client_body_temp_path)
* [`client_body_temp_mode`](#client_body_temp_mode)
* [`confd_only`](#confd_only)
* [`confd_purge`](#confd_purge)
* [`conf_dir`](#conf_dir)
Expand All @@ -100,6 +101,7 @@ The following parameters are available in the `nginx` class:
* [`nginx_error_log_severity`](#nginx_error_log_severity)
* [`pid`](#pid)
* [`proxy_temp_path`](#proxy_temp_path)
* [`proxy_temp_mode`](#proxy_temp_mode)
* [`root_group`](#root_group)
* [`run_dir`](#run_dir)
* [`sites_available_owner`](#sites_available_owner)
Expand Down Expand Up @@ -314,6 +316,14 @@ Data type: `Variant[Stdlib::Absolutepath, Boolean]`

Default value: `$nginx::params::client_body_temp_path`

##### <a name="client_body_temp_mode"></a>`client_body_temp_mode`

Data type: `Optional[Stdlib::Filemode]`



Default value: ``undef``

##### <a name="confd_only"></a>`confd_only`

Data type: `Boolean`
Expand Down Expand Up @@ -482,6 +492,14 @@ Data type: `Variant[Stdlib::Absolutepath, Boolean]`

Default value: `$nginx::params::proxy_temp_path`

##### <a name="proxy_temp_mode"></a>`proxy_temp_mode`

Data type: `Optional[Stdlib::Filemode]`



Default value: ``undef``

##### <a name="root_group"></a>`root_group`

Data type: `Any`
Expand Down
4 changes: 2 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@
file { $client_body_temp_path:
ensure => directory,
owner => $daemon_user,
mode => '0700',
mode => $nginx::client_body_temp_mode,
}
}

if $proxy_temp_path {
file { $proxy_temp_path:
ensure => directory,
owner => $daemon_user,
mode => '0700',
mode => $nginx::proxy_temp_mode,
}
}

Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
class nginx (
### START Nginx Configuration ###
Variant[Stdlib::Absolutepath, Boolean] $client_body_temp_path = $nginx::params::client_body_temp_path,
Optional[Stdlib::Filemode] $client_body_temp_mode = undef,
Boolean $confd_only = false,
Boolean $confd_purge = false,
$conf_dir = $nginx::params::conf_dir,
Expand All @@ -62,6 +63,7 @@
Nginx::ErrorLogSeverity $nginx_error_log_severity = 'error',
$pid = $nginx::params::pid,
Variant[Stdlib::Absolutepath, Boolean] $proxy_temp_path = $nginx::params::proxy_temp_path,
Optional[Stdlib::Filemode] $proxy_temp_mode = undef,
$root_group = $nginx::params::root_group,
$run_dir = $nginx::params::run_dir,
$sites_available_owner = $nginx::params::sites_available_owner,
Expand Down
54 changes: 46 additions & 8 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,12 @@
when 'Debian'
is_expected.to contain_file('/run/nginx/client_body_temp').with(
ensure: 'directory',
group: 'root',
mode: '0700'
group: 'root'
)
else
is_expected.to contain_file('/var/nginx/client_body_temp').with(
ensure: 'directory',
group: 'root',
mode: '0700'
group: 'root'
)
end
end
Expand All @@ -340,14 +338,12 @@
when 'Debian'
is_expected.to contain_file('/run/nginx/proxy_temp').with(
ensure: 'directory',
group: 'root',
mode: '0700'
group: 'root'
)
else
is_expected.to contain_file('/var/nginx/proxy_temp').with(
ensure: 'directory',
group: 'root',
mode: '0700'
group: 'root'
)
end
end
Expand Down Expand Up @@ -1515,6 +1511,48 @@
)
end
end

context 'when proxy_temp_mode is non-default' do
let(:params) { { proxy_temp_mode: '0771' } }
let(:run_dir) do
case facts[:os]['family']
when 'Debian'
'/run/nginx'
when 'OpenBSD'
'/var/www'
when 'AIX'
'/opt/freeware/share/nginx/html'
else
'/var/nginx'
end
end

it do
is_expected.to contain_file("#{run_dir}/proxy_temp").
with_mode('0771')
end
end

context 'when client_body_temp_mode is non-default' do
let(:params) { { client_body_temp_mode: '0771' } }
let(:run_dir) do
case facts[:os]['family']
when 'Debian'
'/run/nginx'
when 'OpenBSD'
'/var/www'
when 'AIX'
'/opt/freeware/share/nginx/html'
else
'/var/nginx'
end
end

it do
is_expected.to contain_file("#{run_dir}/client_body_temp").
with_mode('0771')
end
end
end
end
end
Expand Down

0 comments on commit bf5e198

Please sign in to comment.