Skip to content

Commit 332e3bc

Browse files
authored
Merge pull request #524 from simondeziel/apparmor
Add apparmor_hat support to php::fpm::pool
2 parents 5df630b + 4c20c7b commit 332e3bc

4 files changed

Lines changed: 51 additions & 0 deletions

File tree

REFERENCE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,9 @@ documented here: http://php.net/manual/en/install.fpm.configuration.php.
22482248
[*group*]
22492249
The group that php-fpm should run as
22502250

2251+
[*apparmor_hat*]
2252+
The Apparmor hat to use
2253+
22512254
[*pm*]
22522255

22532256
[*pm_max_children*]

manifests/fpm/pool.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
# [*group*]
3131
# The group that php-fpm should run as
3232
#
33+
# [*apparmor_hat*]
34+
# The Apparmor hat to use
35+
#
3336
# [*pm*]
3437
#
3538
# [*pm_max_children*]
@@ -127,6 +130,7 @@
127130
$listen_mode = undef,
128131
$user = $php::fpm::config::user,
129132
$group = $php::fpm::config::group,
133+
Optional[String[1]] $apparmor_hat = undef,
130134
$pm = 'dynamic',
131135
$pm_max_children = '50',
132136
$pm_start_servers = '5',

spec/classes/php_spec.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,46 @@
239239
it { is_expected.to contain_file(dstfile).with_content(%r{group = nginx}) }
240240
end
241241

242+
describe 'when configured with a pool with apparmor_hat parameter' do
243+
let(:params) { { fpm_pools: { 'www' => { 'apparmor_hat' => 'www' } } } }
244+
245+
it { is_expected.to contain_php__fpm__pool('www').with(apparmor_hat: 'www') }
246+
247+
dstfile = case facts[:osfamily]
248+
when 'Debian'
249+
case facts[:os]['name']
250+
when 'Debian'
251+
case facts[:os]['release']['major']
252+
when '10'
253+
'/etc/php/7.3/fpm/pool.d/www.conf'
254+
when '9'
255+
'/etc/php/7.0/fpm/pool.d/www.conf'
256+
else
257+
'/etc/php5/fpm/pool.d/www.conf'
258+
end
259+
when 'Ubuntu'
260+
case facts[:os]['release']['major']
261+
when '18.04'
262+
'/etc/php/7.2/fpm/pool.d/www.conf'
263+
when '16.04'
264+
'/etc/php/7.0/fpm/pool.d/www.conf'
265+
else
266+
'/etc/php5/fpm/pool.d/www.conf'
267+
end
268+
end
269+
when 'Archlinux'
270+
'/etc/php/php-fpm.d/www.conf'
271+
when 'Suse'
272+
'/etc/php5/fpm/pool.d/www.conf'
273+
when 'RedHat'
274+
'/etc/php-fpm.d/www.conf'
275+
when 'FreeBSD'
276+
'/usr/local/etc/php-fpm.d/www.conf'
277+
end
278+
279+
it { is_expected.to contain_file(dstfile).with_content(%r{apparmor_hat = www}) }
280+
end
281+
242282
describe 'when fpm is disabled' do
243283
let(:params) { { fpm: false } }
244284

templates/fpm/pool.conf.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ listen.mode = <%= @listen_mode %>
4646
user = <%= @user %>
4747
; RPM: Keep a group allowed to write in log dir.
4848
group = <%= @group_final %>
49+
<% if @apparmor_hat -%>
50+
; Apparmor hat to change to
51+
apparmor_hat = <%= @apparmor_hat %>
52+
<% end -%>
4953

5054
; Choose how the process manager will control the number of child processes.
5155
; Possible Values:

0 commit comments

Comments
 (0)