Skip to content

Commit

Permalink
Expose fpm user and group (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacepants authored and roidelapluie committed Mar 16, 2017
1 parent f370c2b commit 3fb3602
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ by default. Specify additional pools like so:
For an overview of all possible parameters for `php::fpm::pool` resources
please see [its documention](http://php.puppet.mayflower.de/php/fpm/pool.html).

### Overriding php-fpm user

By default, php-fpm is set up to run as Apache. If you need to customize that user, you can do that like so:

```puppet
class { '::php':
fpm_user => 'nginx',
fpm_group => 'nginx',
}
```

### Alternative examples using Hiera
Alternative to the Puppet DSL code examples above, you may optionally define your PHP configuration using Hiera.

Expand All @@ -139,6 +150,8 @@ Below are all the examples you see above, but defined in YAML format for use wit
php::ensure: latest
php::manage_repos: true
php::fpm: true
php::fpm_user: 'nginx'
php::fpm_group: 'nginx'
php::dev: true
php::composer: true
php::pear: true
Expand Down
4 changes: 4 additions & 0 deletions manifests/fpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#
class php::fpm (
$ensure = $::php::ensure,
$user = $::php::fpm_user,
$group = $::php::fpm_group,
$service_ensure = $::php::fpm_service_ensure,
$service_enable = $::php::fpm_service_enable,
$service_name = $::php::fpm_service_name,
Expand Down Expand Up @@ -83,6 +85,8 @@
}

class { '::php::fpm::config':
user => $user,
group => $group,
inifile => $inifile,
settings => $real_settings,
log_owner => $log_owner,
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
$fpm_global_pool_settings = {},
$fpm_inifile = $::php::params::fpm_inifile,
$fpm_package = undef,
$fpm_user = $::php::params::fpm_user,
$fpm_group = $::php::params::fpm_group,
$embedded = false,
$dev = true,
$composer = true,
Expand Down
36 changes: 36 additions & 0 deletions spec/classes/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,42 @@
end
end

describe 'when called with fpm_user parameter' do
let(:params) { { fpm_user: 'nginx' } }
it { is_expected.to contain_class('php::fpm').with(user: 'nginx') }
it { is_expected.to contain_php__fpm__pool('www').with(user: 'nginx') }

dstfile = case facts[:osfamily]
when 'Debian'
'/etc/php5/fpm/pool.d/www.conf'
when 'Suse'
'/etc/php5/fpm/pool.d/www.conf'
when 'RedHat'
'/etc/php-fpm.d/www.conf'
when 'FreeBSD'
'/usr/local/etc/php-fpm.d/www.conf'
end

it { is_expected.to contain_file(dstfile).with_content(%r{user = nginx}) }
end
describe 'when called with fpm_group parameter' do
let(:params) { { fpm_group: 'nginx' } }
it { is_expected.to contain_class('php::fpm').with(group: 'nginx') }
it { is_expected.to contain_php__fpm__pool('www').with(group: 'nginx') }
dstfile = case facts[:osfamily]
when 'Debian'
'/etc/php5/fpm/pool.d/www.conf'
when 'Suse'
'/etc/php5/fpm/pool.d/www.conf'
when 'RedHat'
'/etc/php-fpm.d/www.conf'
when 'FreeBSD'
'/usr/local/etc/php-fpm.d/www.conf'
end

it { is_expected.to contain_file(dstfile).with_content(%r{group = nginx}) }
end

describe 'when fpm is disabled' do
let(:params) { { fpm: false } }
it { is_expected.not_to contain_class('php::fpm') }
Expand Down

0 comments on commit 3fb3602

Please sign in to comment.