Last active
May 24, 2018 09:19
-
-
Save stefanandres/ecd23b81a3f47ae8f3955252ed299aaf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../hiera.yaml | |
| --- | |
| version: 5 | |
| defaults: | |
| hierarchy: | |
| - name: "node" | |
| path: node.yaml | |
| - name: "roles" | |
| mapped_paths: | |
| - roles | |
| - role | |
| - "%{role}.yaml" | |
| - name: "Other YAML hierarchy levels" | |
| paths: | |
| - "common.yaml" | |
| root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../data/common.yaml | |
| myhash: | |
| key1: value1 | |
| key2: value2 | |
| root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../data/firstrole.yaml | |
| lookup_options: | |
| myhash: | |
| merge: | |
| strategy: deep | |
| myhash: | |
| role1: value1 | |
| role2: value2 | |
| role1: role1 | |
| root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../data/secondrole.yaml | |
| myhash: | |
| role1: value1 | |
| role3: value3 | |
| role2: role2 | |
| root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat site.pp | |
| $roles = lookup( 'roles', Array[String], 'unique', [], ) | |
| notice("roles: $roles") | |
| $ret = lookup('myhash') | |
| notice("myhash: $ret") | |
| $role1 = lookup('role1') | |
| $role2 = lookup('role2') | |
| notice("role1 var: $role1") | |
| notice("role2 var: $role2") | |
| puppet-agent-5.3.5: | |
| root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# puppet apply site.pp | |
| Warning: Undefined variable 'roles'; \n (file & line not available) | |
| Notice: Scope(Class[main]): roles: [firstrole, secondrole] | |
| Notice: Scope(Class[main]): myhash: {key1 => value1, key2 => value2, role1 => value1, role3 => value3, role2 => value2} | |
| Notice: Scope(Class[main]): role1 var: role1 | |
| Notice: Scope(Class[main]): role2 var: role2 | |
| Notice: Compiled catalog for c312a1b640ef in environment production in 0.03 seconds | |
| Notice: Applied catalog in 0.01 seconds | |
| puppet-agent-5.5.1 | |
| root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# puppet apply site.pp | |
| Warning: Undefined variable 'roles'; \n (file & line not available) | |
| Notice: Scope(Class[main]): roles: [firstrole, secondrole] | |
| Notice: Scope(Class[main]): myhash: {role1 => value1, role2 => value2} | |
| Notice: Scope(Class[main]): role1 var: role1 | |
| Notice: Scope(Class[main]): role2 var: role2 | |
| Notice: Compiled catalog for c312a1b640ef in environment production in 0.02 seconds | |
| Notice: Applied catalog in 0.02 seconds | |
| When putting the lookup_options in the common.yaml, the deep merge will happen also. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment