Using 'setroubleshoot' module located at: https://github.com/treydock/puppet-module-setroubleshoot, I have been having trouble getting Puppet 4 to do a 'for each' loop in the template file against the hash (of hashes?).
When running on Puppet 4, the methods "keys.sort.each" fail for the hash @email_recipients in the template file:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: {"message":"Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse template setroubleshoot/email_alert_recipients.erb:
Filepath: /etc/puppetlabs/code/environments/setroubleshoot/modules/setroubleshoot/templates/email_alert_recipients.erb Line: 1 ** Detail: undefined methodkeys' for nil:NilClass ** at /etc/puppetlabs/code/environments/setroubleshoot/modules/setroubleshoot/manifests/config.pp:22:18 on node ltstd001.healthplan.com","issue_kind":"RUNTIME_ERROR"}
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Using the puppet site.pp file:
class { 'setroubleshoot':
email_recipients => { 'foo@example.com' => { 'filter_type' => 'after_first' } }
}
Here's the template:
<% @email_recipients.keys.sort.each do |recipient| -%><% filter_type = @email_recipients[recipient]['filter_type'] || 'after_first' -%><%= recipient %> filter_type=<%= filter_type %><% end -%>
For the life of me I can't figure out why .keys.sort.each is failing. There's no issue with Puppet 3.x and I've not found any reason why the .keys, .each and .sort methods would have been deprecated (which wouldn't make any sense anyway).
↧