Satellite 6.12 - Report to show host, package name, and installed version

Posted on

As far as I can tell, there is very little documentation on what Satellite makes available for reports. There's clearly a Ruby backend that lets you define what you want to see in a report, but there's nothing I can find that tells you what objects are available to use.
I'm reading about Ruby syntax right now to try to figure out how to use this. Can anyone tell me what objects to look at for host name, package name, and version installed?

This is what I have:

<%#
name: Host - compare content hosts packages
snippet: false
template_inputs:
- name: Host name
  required: false
  input_type: user
  advanced: false
  value_type: plain
  resource_type: Katello::ActivationKey
- name: package name
  required: false
  input_type: user
  advanced: false
  value_type: plain
  resource_type: Katello::ActivationKey
model: ReportTemplate
require:
- plugin: katello
  version: 3.16.1
-%>
<%- hosts = load_hosts(search: "name ^ #{input('Host name')}, installed_package_name = #{input('Package name')}").to_a.flatten -%>
<%- if hosts.length == 0 -%>
<%-   raise _("No hosts found") -%>
<%- else -%>
<%-   report_headers 'Host Name', 'Host IP', 'Package Name', 'Installed Version' -%>

<%- end -%>
<%= report_render -%>

I've seen references to something called host.installed_packages that sounds like what I need, but how do I get from this to the name and version?

Responses