Access hiera array element in erb template
So, I have
check_command check_nrpe!check_ntp_drift!<%= env['ntpservers'] %>
in a template .erb file.
This gives the error
Function Call, Failed to parse template icinga/etc/icinga/COLLECT/icinga/base.cfg.erb: Filepath: /etc/puppetlabs/code/environments/prod/modules/icinga/templates/etc/icinga/COLLECT/icinga/base.cfg.erb Line: 50 Detail: undefined local variable or method `env' for #<Puppet::Parser::TemplateWrapper:0x16f3ce66>
during a puppet agent run.
'env' is defined in site.pp
$env = hiera_hash(env)
Can anyone provide the correct syntax please (this is on puppet 4, ported from working puppet 3 if that helps)
@lupin: y, funnily enough I just tried that (randomly) and it worked.
My prob is I'm new to puppet and know zero about Ruby. I'm not clear on the different syntax's of each lang and eg whether/when to differentiate between hash, array, element of hash/array and what syntax to use in each case.
I guess this is 'Solved' :)
PS: If you're good with hiera, can you take a look at https://ask.puppet.com/question/26713... ?