Problem:
I need a way to make a report or search that contains partitions::/dev/%/%luks%::uuid . Works as expected if I write the full fact: partitions::/dev/mapper/something-luks::uuid
Expected outcome:
partitions::/dev/mapper/something-luks::uuid w/ uuid
Foreman and Proxy versions:
2.3
Distribution and version:
Centos 7
dont know if its possible at hosts tab to use % . At facts tab, I can use % without issues. Any hint/ ideas?
If I understand it correctly, partitions::/dev/mapper/something-luks::uuid
is a name of a fact. On the facts page you are looking at a list of facts and in there you can search by name of the facts, so wildcards work in there.
On the hosts index, you’re looking at hosts and although you can search them by facts, you are allowed only by facts’ values there.
I’m not 100% what exactly is the information you want to obtain. Do you want a list of hosts which have encrypted partitions? UUIDs of encrypted partitions? Both? Depending on what you want to do it might be doable by talking to the api and doing a little processing on the data you get back.
Hi, Im looking a simple method to get a report for systems in a hostgroup without encrypted partitions.
Foreman 2.3 is rather old, if you were on newer, you could leverage report templates to craft a report like that. On 2.3 I don’t think there’s any sensible solution apart from rolling your own script that would hit the api and process the results.
I dont get what you mean, there’s report templates at 2.3 as well
In that case, a report like this could work
<%#
name: Host - No encrypted partitions
snippet: false
template_inputs:
- name: hosts
required: false
input_type: user
description: Limit the report only on hosts found by this search query. Keep empty
for report on all available hosts.
advanced: false
value_type: search
resource_type: Host
hidden_value: false
model: ReportTemplate
-%>
<%- report_headers 'Name' -%>
<%- load_hosts(search: input('hosts')).each_record do |host| -%>
<%- facts = host.facts_hash -%>
<%- unless facts.keys.any? { |fact| fact.match(/partitions::\/dev\/[^\/]+\/.*luks.*::uuid/) } -%>
<%- report_row({
'Name': host.name,
}) -%>
<%- end -%>
<%- end -%>
<%= report_render -%>
And then when rendering the template you would provide hostgroup = mygroup
to scope it to a specific hostgroup (mygroup
in this case_
1 Like
Thanks Adam, that gave me an idea on how to search for wildcard facts, and I understood the overall process. I appreciate your help!