Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hierarchy interpolation seems to have changed. #108

Closed
rnelson0 opened this issue Jan 19, 2016 · 6 comments
Closed

Hierarchy interpolation seems to have changed. #108

rnelson0 opened this issue Jan 19, 2016 · 6 comments

Comments

@rnelson0
Copy link
Sponsor Member

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'
@BarnacleBob
Copy link

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.

@rnelson0
Copy link
Sponsor Member Author

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

@rnelson0
Copy link
Sponsor Member Author

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

@BarnacleBob
Copy link

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}

@rnelson0
Copy link
Sponsor Member Author

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!

@rnelson0
Copy link
Sponsor Member Author

I opened HI-494 since this is an upstream issue. Thanks for the workaround @BarnacleBob!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants