Hierarchy interpolation seems to have changed.
Closed this issue · 6 comments
Using this yaml file and including the class ::hiera
...
---
classes:
role::puppet
hiera::hierarchy:
- 'clientcert/%%{}{clientcert}'
- 'puppet_role/%%{}{puppet_role}'
- 'global'
hiera::datadir: '/etc/puppetlabs/code/environments/%%{}{environment}/hiera'
Used to result in this file with Puppet 3.7 FOSS and Passenger or PE3.7/puppetserver:
# managed by puppet
---
:backends:
- yaml
:logger: console
:hierarchy:
- "clientcert/%{clientcert}"
- "puppet_role/%{puppet_role}"
- global
:yaml:
:datadir: /etc/puppetlabs/code/environments/%{environment}/hiera
Using puppet4/puppetserver results in this file instead:
# managed by puppet
---
:backends:
- yaml
:logger: console
:hierarchy:
- clientcert/%#<Hiera::Scope:0x8668515>{clientcert}
- puppet_role/%#<Hiera::Scope:0x584e63d>{puppet_role}
- global
:yaml:
:datadir: /etc/puppetlabs/code/environments/%#<Hiera::Scope:0x17a1410d>{environment}/hiera
Is there any known reason for why this behavior has changed? I was able to remedy this with the following changes, but it does not seem like the right solution:
#in site.pp
$percent = '%'
# in puppet.yaml
---
classes:
role::puppet
hiera::hierarchy:
- clientcert/%{percent}{clientcert}
- 'puppet_role/%{percent}{puppet_role}'
- 'global'
FYI i ran into this also and %%{::}{var} works. %{} seems to now resolve to all variables in scope in a hash as opposed to an invalid lookup like it was before. :: is invalid and no variable could be named that so i guess its a viable work around. Also i would suggest this be a bug against hiera not this module.
@BarnacleBob Can you help identify when you ran into this issue? Was it when moving to 4.x, and if so, what point release did you start with? I'll follow up with a PL ticket, just want to see if we can narrow the environment.
(I also wasn't sure if puppet was interpolating it before this module was generating the template content, or if the module was doing it - seems to be puppet)
I am using OS Puppet 3.x series in production with hiera 1.3.4 and setup puppet-enterprise-2015.3.1 on my personal stuff to start learning the differences. It has hiera 3.0.5.
If you test it on the cmdline you see that %{} returns the whole scope array.
root@ip-172-30-2-36:~# cat /etc/puppetlabs/code/environments/production/hieradata/common.yaml | grep -i iptest
iptest: 'testing "% % {} {::environment}": %%{}{::environment}'
iptest2: 'testing "% % {::} {::environment}": %%{::}{::environment}'
root@ip-172-30-2-36:~# hiera iptest ::environment=production ::somevar=foo ::someother=bar
testing "% % {} {::environment}": %{"::environment"=>"production", "::somevar"=>"foo", "::someother"=>"bar"}{::environment}
root@ip-172-30-2-36:~# hiera iptest2 ::environment=production ::somevar=foo ::someother=bar
testing "% % {::} {::environment}": %{::environment}
Interesting, looks like a Hiera 3 bug then. I can never tell when Puppet is handing things to hiera or doing it itself but at least it's a starting point. Thanks!
I opened HI-494 since this is an upstream issue. Thanks for the workaround @BarnacleBob!