Skip to content

Commit

Permalink
Merge pull request #550 from sigv/536
Browse files Browse the repository at this point in the history
Do a `deep` merge on `fpm` lookup
  • Loading branch information
bastelfreak authored Nov 18, 2019
2 parents 7b760a8 + debfa56 commit fd022ad
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,24 @@ php::fpm::pools:
## Notes
### Inheriting configuration across mutliple Hiera sources
Configuration from Hiera such as `php::fpm::pools` is automatically
lookup up using the "first" merge method. This means that the first
value found is used. If you instead want to merge the hash keys
across multiple Hiera sources, you can use [`lookup_options`] to
set [`hash` or `deep` behaviors] such as in the example
[data/default.yaml](data/default.yaml):

```yaml
lookup_options:
php::fpm::pools:
merge: hash
```

[`lookup_options`]: https://puppet.com/docs/puppet/6.4/hiera_merging.html#concept-2997
[`hash` or `deep` behaviors]: https://puppet.com/docs/puppet/6.4/hiera_merging.html#merge-behaviors

### Debian squeeze & Ubuntu precise come with PHP 5.3

On Debian-based systems, we use `php5enmod` to enable extension-specific
Expand Down
7 changes: 6 additions & 1 deletion data/default.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
php::fpm_pools:

lookup_options:
php::fpm::pools:
merge: first

php::fpm::pools:
www:
catch_workers_output: 'no'
listen: '127.0.0.1:9000'
Expand Down
6 changes: 3 additions & 3 deletions manifests/fpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
warning('php::fpm is private')
}

$real_settings = lookup('php::fpm::settings', Hash, {'strategy' => 'deep', 'merge_hash_arrays' => true}, $settings)
$real_settings = $settings

# On FreeBSD fpm is not a separate package, but included in the 'php' package.
# Implies that the option SET+=FPM was set when building the port.
Expand Down Expand Up @@ -99,8 +99,8 @@

Class['php::fpm::config'] ~> Class['php::fpm::service']

$real_global_pool_settings = lookup('php::fpm::global_pool_settings', Hash, {'strategy' => 'unique'}, $global_pool_settings)
$real_pools = lookup('php::fpm::pools', Hash, {'strategy' => 'unique'}, $pools)
$real_global_pool_settings = $global_pool_settings
$real_pools = $pools
create_resources(::php::fpm::pool, $real_pools, $real_global_pool_settings)

# Create an override to use a reload signal as trusty and utopic's
Expand Down

0 comments on commit fd022ad

Please sign in to comment.