Report Template - facts

How do you retrieve a particular host’s fact-value called os_patching?
Expected outcome:
Hostname and fact-value displayed in a report
Foreman and Proxy versions:
Foreman and Proxy plugin versions:

Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]
(for logs, surround with three back-ticks to get proper formatting, e.g.)



this should work

<%- load_hosts.each_record do |host| -%>
<%-   report_row(
        'Fact': host.facts_hash['os_patching']
      ) -%>
<%- end -%>
<%= report_render -%>

please note that this is probably not efficient as it loads all facts for every hosts as a separate SQL query. Perhaps facts could be preloaded, but that could consume also more memory.

1 Like

Thanks that solved it :slight_smile:

Hi all,
Do you know how to print nested facts?
For example:
Trying to use it within the report doesn’t throw any errors but is not populating it:

In the client “facter” works fine, but still coming out empty in the report.

Also, do you know any documentation about writing these templates?
I can’t find anything at all.


Try host.facts_hash["dmi"]["product"]["name"] it may work. Find the DSL docs under Administer -> About, see the “Templates DSL” link. Hope this helps.

1 Like