I am trying to find a way to iterate over facts hash with 'each' function. 
But i get this error:

' There was an error rendering the CentOS_test1 template: undefined method 
`each' for nil:NilClass' 

Safe mode rendering is off.

How do i iterate over nested structured facts/facts hash in provision 
templates in foreman?

For example - the following does not work.

<% @host.facts_hash['kickstart_repos::base'].each do |k| %>
<%= k %>: <%= @host.facts_hash[k] %>
<% end %>

Is there a restriction on what ruby methods i can use inside templates? The 
same template works fine in puppet/with ruby.

I tried searching for examples but could not find any.
The documentation mentions that :

@host.facts: Contains a hash of facts from Facter/Ohai etc. (1.7.2+)
@host.facts_hash : Contains a hash of facts from Facter/Ohai etc. (only 
works if safemode_render=false)

I assume the above means, that both those variables are hashes and can be 
iterated?

-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to