|
Using a pre-release version of puppet-agent at SHA a18e3b containing puppet at SHA 137a1cd this passes manual validation.
Steps to reproduce
Create hiera config in production environment
The two data sets to be merged will be located in foo.yaml and common.yaml respectively
---
|
version: 5
|
defaults:
|
# The default value for "datadir" is "data" under the same directory as the hiera.yaml
|
# file (this file)
|
# When specifying a datadir, make sure the directory exists.
|
# See https://docs.puppet.com/puppet/latest/environments.html for further details on environments.
|
# datadir: data
|
# data_hash: yaml_data
|
hierarchy:
|
- name: "Per-node data (yaml version)"
|
path: "nodes/%{::trusted.certname}.yaml"
|
- name: "Other YAML hierarchy levels"
|
paths:
|
- "foo.yaml"
|
- "common.yaml"
|
Create 'foo' data file
[root@xw2egp8ua5rj5f3 ~]# cat /etc/puppetlabs/code/environments/production/data/foo.yaml
|
---
|
site_users:
|
jen:
|
uid: 503
|
shell: /bin/zsh
|
group: ops
|
bob:
|
uid: 1000
|
group: ops
|
Create 'common' data set with defined merge options
[root@xw2egp8ua5rj5f3 ~]# cat /etc/puppetlabs/code/environments/production/data/common.yaml
|
---
|
site_users:
|
bob:
|
uid: 501
|
shell: /bin/bash
|
ash:
|
uid: 502
|
shell: /bin/zsh
|
group: common
|
|
lookup_options:
|
site_users:
|
merge:
|
strategy: deep
|
knockout_prefix: --
|
sort_merged_arrays: true
|
Perform lookups
From lookup subcommand
[root@xw2egp8ua5rj5f3 ~]# puppet lookup site_users
|
---
|
bob:
|
uid: 1000
|
shell: "/bin/bash"
|
group: ops
|
ash:
|
uid: 502
|
shell: "/bin/zsh"
|
group: common
|
jen:
|
uid: 503
|
shell: "/bin/zsh"
|
group: ops
|
From lookup function
[root@xw2egp8ua5rj5f3 ~]# cat lookup.pp
|
class foo(
|
) {
|
$foo = lookup({
|
'name' => 'site_users',
|
'merge' => {
|
'strategy' => 'deep',
|
'sort_merged_arrays' => true,
|
},
|
})
|
notice($foo)
|
}
|
|
include foo
|
[root@xw2egp8ua5rj5f3 ~]# puppet apply lookup.pp
|
Notice: Scope(Class[Foo]): {bob => {uid => 1000, shell => /bin/bash, group => ops}, ash => {uid => 502, shell => /bin/zsh, group => common}, jen => {uid => 503, shell => /bin/zsh, group => ops}}
|
Notice: Compiled catalog for xw2egp8ua5rj5f3.delivery.puppetlabs.net in environment production in 0.04 seconds
|
Notice: Applied catalog in 0.02 seconds
|
|