Skip to content

Commit fd022ad

Browse files
authored
Merge pull request #550 from sigv/536
Do a `deep` merge on `fpm` lookup
2 parents 7b760a8 + debfa56 commit fd022ad

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,24 @@ php::fpm::pools:
240240
241241
## Notes
242242
243+
### Inheriting configuration across mutliple Hiera sources
244+
245+
Configuration from Hiera such as `php::fpm::pools` is automatically
246+
lookup up using the "first" merge method. This means that the first
247+
value found is used. If you instead want to merge the hash keys
248+
across multiple Hiera sources, you can use [`lookup_options`] to
249+
set [`hash` or `deep` behaviors] such as in the example
250+
[data/default.yaml](data/default.yaml):
251+
252+
```yaml
253+
lookup_options:
254+
php::fpm::pools:
255+
merge: hash
256+
```
257+
258+
[`lookup_options`]: https://puppet.com/docs/puppet/6.4/hiera_merging.html#concept-2997
259+
[`hash` or `deep` behaviors]: https://puppet.com/docs/puppet/6.4/hiera_merging.html#merge-behaviors
260+
243261
### Debian squeeze & Ubuntu precise come with PHP 5.3
244262

245263
On Debian-based systems, we use `php5enmod` to enable extension-specific

data/default.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
2-
php::fpm_pools:
2+
3+
lookup_options:
4+
php::fpm::pools:
5+
merge: first
6+
7+
php::fpm::pools:
38
www:
49
catch_workers_output: 'no'
510
listen: '127.0.0.1:9000'

manifests/fpm.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
warning('php::fpm is private')
7171
}
7272

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

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

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

102-
$real_global_pool_settings = lookup('php::fpm::global_pool_settings', Hash, {'strategy' => 'unique'}, $global_pool_settings)
103-
$real_pools = lookup('php::fpm::pools', Hash, {'strategy' => 'unique'}, $pools)
102+
$real_global_pool_settings = $global_pool_settings
103+
$real_pools = $pools
104104
create_resources(::php::fpm::pool, $real_pools, $real_global_pool_settings)
105105

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

0 commit comments

Comments
 (0)