I have defined in hiera.yaml something like this:
:backends:
- yaml
:hierarchy:
- "%{::fqdn}"
- "%{fqdn}"
- global
:yaml:
:datadir: "/etc/puppet/hieradata"
(I dont know which one is correct, so that's why I have both...)
but when I run hiera -c ../hiera.yaml allowUsers --debug
this is the output
DEBUG: 2016-04-07 22:07:02 +0200: Hiera YAML backend starting
DEBUG: 2016-04-07 22:07:02 +0200: Looking up allowUsers in YAML backend
DEBUG: 2016-04-07 22:07:02 +0200: Looking for data source global
DEBUG: 2016-04-07 22:07:02 +0200: Found allowUsers in global
["vagrant", "root"]
All is in this same directory
[root@localhost hieradata]# ll
total 16
-rw-r--r--. 1 root root 28 Apr 7 20:14 centos-puppet.yaml
-rw-r--r--. 1 root root 45 Apr 7 20:39 facts.yaml
-rw-r--r--. 1 root root 83 Apr 7 20:42 global.yaml
-rw-r--r--. 1 root root 28 Apr 7 20:15 production.yaml
also
[root@localhost hieradata]# facter fqdn
centos-puppet
So even in hierarchy fqdn name is higher, it looks like hiera is not even trying to resolv fqdn variables. I have no idea why.
[root@localhost hieradata]# puppet -V
3.8.6
[root@localhost hieradata]# hiera -v
1.3.4
When you run hiera
on the command line, you need to manually specify any facts you want it to recognize. There are several options for that, but for one-offs, the easiest is to specify them directly in the command:
hiera allowUsers -c ../hiera.yaml --debug fqdn=centos-puppet
When facts are passed in this way the fact name must match any interpolation tokens exactly in order to be recognized. Thus, the above form should trigger make the "%{fqdn}"
hierarchy level being recognized. If you instead specified ::fqdn=centos-puppet
then it would make the "%{::fqdn}"
level be recognized. Note, however, that these two are not so distinct when Hiera is invoked by Puppet -- in that case, %{fqdn}
resolves fqdn
against the current scope, with very likely (but not necessarily) the same result as "%{::fqdn}"
.
All this is covered in much greater detail in the Hiera documentation, which seems to have gotten a significant and long-overdue update recently.