| Puppet Version: 5.5.10 Puppet Server Version: 5.5.10 OS Name/Version: Debian GNU/Linux 10 (buster) The documentation for the glob keyword says the following:
glob String One shell-like glob pattern, which might match any number of files. If multiple files are found, Hiera searches all of them in alphanumerical order.
However, hiera actually seems to parse the files matching a glob in directory order instead: Consider this environment:
# puppet --version |
5.5.10 |
# hiera --version |
3.2.0 |
# head /etc/puppet/main.pp /etc/puppet/hiera.yaml /etc/puppet/data/* |
==> /etc/puppet/main.pp <== |
$myhash = lookup ('myhash', Hash[String, Any], 'hash', {}) |
|
notice("myhash=${myhash}") |
|
==> /etc/puppet/hiera.yaml <== |
version: 5 |
|
hierarchy: |
- name: Glob Hierarchy |
glob: "*" |
|
==> /etc/puppet/data/bar.yaml <== |
--- |
myhash: |
key: bar |
|
==> /etc/puppet/data/foo.yaml <== |
--- |
myhash: |
key: foo |
# ls -l /etc/puppet/data/ |
total 8 |
-rw-r--r-- 1 root root 22 Oct 28 17:43 bar.yaml |
-rw-r--r-- 1 root root 22 Oct 28 17:42 foo.yaml |
# ls -l --sort=none /etc/puppet/data/ |
total 8 |
-rw-r--r-- 1 root root 22 Oct 28 17:42 foo.yaml |
-rw-r--r-- 1 root root 22 Oct 28 17:43 bar.yaml |
#
|
The first ls output shows the alphanumerical order (bar first), while the second ls output shows the directory order (foo first). Now if we execute puppet...
# puppet apply --noop /etc/puppet/main.pp |
Notice: Scope(Class[main]): myhash={key => foo} |
Notice: Compiled catalog for shepard in environment production in 0.02 seconds |
Notice: Applied catalog in 0.07 seconds |
#
|
... we can see, that the hash merge took the value from foo.yaml (first in directory.yaml) instead of the value from bar.yaml (first in alphanumerical oder). |