Jira (HI-614) "glob" matches are not sorted in alphanumerical order as documented, but in directory order instead

1 view
Skip to first unread message

Alexander Kurtz (JIRA)

unread,
Oct 28, 2019, 1:15:03 PM10/28/19
to puppe...@googlegroups.com
Alexander Kurtz created an issue
 
Hiera / Bug HI-614
"glob" matches are not sorted in alphanumerical order as documented, but in directory order instead
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2019/10/28 10:14 AM
Priority: Normal Normal
Reporter: Alexander Kurtz

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).

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages