Does foreman store facts as hash?

Because when i queried the node using api to gather facts, i see that the 
facts hash that i uploaded is now null:

            "kickstart_repos": null,
            "kickstart_repos::base": null, 

I see that it has created the child variables out of the hash. 

"kickstart_repos::base::baseurl": 
"http://10.230.1.106:8090/centos/7/os/x86_64/";,

This makes the template writing really difficult, because i will have to 
statically mention each key of the facts hash that i have uploaded, in the 
templates.

One of the advantages of hash is that it could be dynamic, and we should be 
able to iterate over whichever keys it contains.

How do i make foreman store the facts as a hash and not function as above?


On Tuesday, August 29, 2017 at 4:31:25 PM UTC-4, lohit....@gmail.com wrote:
>
> 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 foreman-users+unsubscr...@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
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