Skip to content

Commit d1e5365

Browse files
committed
make directory mode configurable for X_tmp_path
nginx manages the directory permissions on its own, so the default value is undef to avoid conflicts.
1 parent acc64e3 commit d1e5365

File tree

4 files changed

+89
-11
lines changed

4 files changed

+89
-11
lines changed

REFERENCE.md

+27-9
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ The following parameters are available in the `nginx` class:
8282
* [`reset_timedout_connection`](#-nginx--reset_timedout_connection)
8383
* [`nginx_snippets`](#-nginx--nginx_snippets)
8484
* [`nginx_snippets_defaults`](#-nginx--nginx_snippets_defaults)
85+
* [`proxy_temp_mode`](#-nginx--proxy_temp_mode)
86+
* [`proxy_temp_path`](#-nginx--proxy_temp_path)
8587
* [`client_body_temp_path`](#-nginx--client_body_temp_path)
88+
* [`client_body_temp_mode`](#-nginx--client_body_temp_mode)
8689
* [`confd_only`](#-nginx--confd_only)
8790
* [`confd_purge`](#-nginx--confd_purge)
8891
* [`conf_dir`](#-nginx--conf_dir)
@@ -104,7 +107,6 @@ The following parameters are available in the `nginx` class:
104107
* [`nginx_error_log`](#-nginx--nginx_error_log)
105108
* [`nginx_error_log_severity`](#-nginx--nginx_error_log_severity)
106109
* [`pid`](#-nginx--pid)
107-
* [`proxy_temp_path`](#-nginx--proxy_temp_path)
108110
* [`root_group`](#-nginx--root_group)
109111
* [`sites_available_owner`](#-nginx--sites_available_owner)
110112
* [`sites_available_group`](#-nginx--sites_available_group)
@@ -326,11 +328,35 @@ Can be used to define default values for the parameter `nginx_snippets`.
326328

327329
Default value: `{}`
328330

331+
##### <a name="-nginx--proxy_temp_mode"></a>`proxy_temp_mode`
332+
333+
Data type: `Optional[Stdlib::Filemode]`
334+
335+
Permissions for the $proxy_temp_path file resource.
336+
337+
Default value: `undef`
338+
339+
##### <a name="-nginx--proxy_temp_path"></a>`proxy_temp_path`
340+
341+
Data type: `Optional[Stdlib::Absolutepath]`
342+
343+
Directory for storing temporary files with data received from proxied servers.
344+
345+
Default value: `undef`
346+
329347
##### <a name="-nginx--client_body_temp_path"></a>`client_body_temp_path`
330348

331349
Data type: `Optional[Stdlib::Absolutepath]`
332350

351+
Directory for storing temporary files holding client request bodies.
352+
353+
Default value: `undef`
354+
355+
##### <a name="-nginx--client_body_temp_mode"></a>`client_body_temp_mode`
333356

357+
Data type: `Optional[Stdlib::Filemode]`
358+
359+
Permissions for the $client_body_temp_path file resource.
334360

335361
Default value: `undef`
336362

@@ -502,14 +528,6 @@ Data type: `Any`
502528

503529
Default value: `$nginx::params::pid`
504530

505-
##### <a name="-nginx--proxy_temp_path"></a>`proxy_temp_path`
506-
507-
Data type: `Optional[Stdlib::Absolutepath]`
508-
509-
510-
511-
Default value: `undef`
512-
513531
##### <a name="-nginx--root_group"></a>`root_group`
514532

515533
Data type: `Any`

manifests/config.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@
206206
file { $client_body_temp_path:
207207
ensure => directory,
208208
owner => $daemon_user,
209-
mode => '0700',
209+
mode => $nginx::client_body_temp_mode,
210210
}
211211
}
212212

213213
if $proxy_temp_path {
214214
file { $proxy_temp_path:
215215
ensure => directory,
216216
owner => $daemon_user,
217-
mode => '0700',
217+
mode => $nginx::proxy_temp_mode,
218218
}
219219
}
220220

manifests/init.pp

+14
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,22 @@
4444
# @param nginx_snippets_defaults
4545
# Can be used to define default values for the parameter `nginx_snippets`.
4646
#
47+
# @param proxy_temp_mode
48+
# Permissions for the $proxy_temp_path file resource.
49+
#
50+
# @param proxy_temp_path
51+
# Directory for storing temporary files with data received from proxied servers.
52+
#
53+
# @param client_body_temp_path
54+
# Directory for storing temporary files holding client request bodies.
55+
#
56+
# @param client_body_temp_mode
57+
# Permissions for the $client_body_temp_path file resource.
58+
#
4759
class nginx (
4860
### START Nginx Configuration ###
4961
Optional[Stdlib::Absolutepath] $client_body_temp_path = undef,
62+
Optional[Stdlib::Filemode] $client_body_temp_mode = undef,
5063
Boolean $confd_only = false,
5164
Boolean $confd_purge = false,
5265
$conf_dir = $nginx::params::conf_dir,
@@ -69,6 +82,7 @@
6982
Nginx::ErrorLogSeverity $nginx_error_log_severity = 'error',
7083
$pid = $nginx::params::pid,
7184
Optional[Stdlib::Absolutepath] $proxy_temp_path = undef,
85+
Optional[Stdlib::Filemode] $proxy_temp_mode = undef,
7286
$root_group = $nginx::params::root_group,
7387
$sites_available_owner = $nginx::params::sites_available_owner,
7488
$sites_available_group = $nginx::params::sites_available_group,

spec/classes/nginx_spec.rb

+46
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,52 @@
14271427
it { is_expected.to contain_file('/var/log/nginx').with(mode: '0771') }
14281428
end
14291429

1430+
context 'when proxy_temp_path is non-default' do
1431+
let(:params) { { proxy_temp_path: '/tmp/nginx_proxy' } }
1432+
1433+
it do
1434+
is_expected.to contain_file('/tmp/nginx_proxy').
1435+
without('mode')
1436+
end
1437+
end
1438+
1439+
context 'when proxy_temp_mode is non-default' do
1440+
let(:params) do
1441+
{
1442+
proxy_temp_path: '/tmp/nginx_proxy',
1443+
proxy_temp_mode: '0771',
1444+
}
1445+
end
1446+
1447+
it do
1448+
is_expected.to contain_file('/tmp/nginx_proxy').
1449+
with_mode('0771')
1450+
end
1451+
end
1452+
1453+
context 'when client_body_temp_path is non-default' do
1454+
let(:params) { { client_body_temp_path: '/tmp/nginx_client' } }
1455+
1456+
it do
1457+
is_expected.to contain_file('/tmp/nginx_client').
1458+
without('mode')
1459+
end
1460+
end
1461+
1462+
context 'when client_body_temp_mode is non-default' do
1463+
let(:params) do
1464+
{
1465+
client_body_temp_path: '/tmp/nginx_client',
1466+
client_body_temp_mode: '0771',
1467+
}
1468+
end
1469+
1470+
it do
1471+
is_expected.to contain_file('/tmp/nginx_client').
1472+
with_mode('0771')
1473+
end
1474+
end
1475+
14301476
context 'when gzip is non-default (on) test gzip defaults' do
14311477
let(:params) { { gzip: 'on' } }
14321478

0 commit comments

Comments
 (0)