I have a job template with type ansible playbook. This playbook gathers some data from hosts and formats it a bit and saves that as a fact. I also have a reporting template which then references that fact and prints it out in a row alongside the hostname. The problem I’m having is my preferred report output is HTML, however the fact portion generates in the HTML report as one long string of text. I’ve tried to format it both in the job playbook and the reporting end many times and just can’t seem to figure it out. I just need new lines!! I’ve tried inserting \n or html breaks but it seems to escape html. Does anyone have any suggestions? Find below my final set fact task, as well as my reporting ERB.
Set fact task:
- name: Set individual output fact for each host
set_fact:
validation_check: |
Rocky Release: {{ rocky_release.stdout }}
Uptime: {{ system_uptime.stdout }}
Kernel: {{ kernel_version.stdout }}
Host was patched within the last 5 hours: {{ patch_check.stdout }}
Kernel Check: {{ kernel_check.stdout }}
Reboot Check: {{ reboot_check.stdout }}
ERB snippet:
<%- report_headers ‘Hostname’, ‘Validation’ -%>
<%- load_hosts(search: “host_collection_id = #{input(‘host_collection_selector’)}”).each_record do |host| -%>
<%- report_row({
‘Hostname’: host.name,
‘Validation’: host.facts[‘validation_check’] || ‘N/A’,
}) -%>
<%- end -%>
<%= report_render -%>