Problem:
When using report templates - how does one return the environment?
Without safemode - host.environment.to_s works great
With safemode - that is “jailed”. There is no evidently named “environment” method on the host class (from the Report Help Tab)
With normal ERB snippets - i have no problem doing:
host_puppet_environment.name
However within a very simplified report:
<%- load_hosts(search: input(‘hosts’)).each_record do |host| -%>
<%- report_row({
‘Host FQDN’: host.name.to_s,
‘Environment’: host_puppet_environment.name,
}) -%>
I am given the error: There was an error rendering the TEST Patching template: undefined local variable or method host_puppet_environment' for #<Foreman::Renderer::Scope::Report:0x00007fbafaeffad0> Did you mean? host_puppet_classes Similarly trying with something like host.host_puppet_environment.name returns: There was an error rendering the TEST Patching template: undefined method
host_puppet_environment’ for #Host::Managed:0x000055a362367760 Did you mean? hosts_api_ansible_inventories_path
Expected outcome:
How do i return a host’s “Environment” when utilizing Safe Mode in a Report Template?
Foreman and Proxy versions:
Foreman 3.0.1
Foreman and Proxy plugin versions:
Foreman 3.0.1 Equivalents
Distribution and version:
RedHat 8.4