Bug 1826648

Summary: [RFE] new report template to list all the installed packages
Product: Red Hat Satellite Reporter: Waldirio M Pinheiro <wpinheir>
Component: ReportingAssignee: Waldirio M Pinheiro <wpinheir>
Status: CLOSED ERRATA QA Contact: Cole Higgins <chiggins>
Severity: high Docs Contact:
Priority: high    
Version: 6.7.0CC: afeferku, bkearney, mhulan, pcreech, vsedmik
Target Milestone: 6.13.0Keywords: EasyFix, FutureFeature, Patch, Triaged
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: foreman-3.5.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-03 13:20:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Waldirio M Pinheiro 2020-04-22 08:44:08 UTC
Description of problem:
The customer would like to generate a list of the installed packages for a system or all of them.

Version-Release number of selected component (if applicable):
6.7

How reproducible:
100%

Steps to Reproduce:
1. Install satellite 6.7
2. Create the report template
3. Copy/paste the code below

Actual results:
We don't ship this report on Satellite 6.7

Expected results:
Be able to run this report template and generate the list when necessary

Additional info:

Comment 3 Waldirio M Pinheiro 2020-04-22 08:46:05 UTC
Hi

Below the code

---
$ cat host_-_all_installed_packages.erb 
<%#
name: Host - All Installed Packages
snippet: false
template_inputs:
- name: hosts
  required: false
  input_type: user
  advanced: false
  value_type: plain
  resource_type: Katello::ActivationKey
  hidden_value: false
model: ReportTemplate
%>
<%  load_hosts(search: input('hosts')).each_record do |host| -%>
<%    host.installed_packages.each do |pkg| -%>
<%-   report_row(
        'Host': host.name,
        'Package Name': pkg.name,
        'Package NVRA': pkg.nvra,
        'Package NVREA': pkg.nvrea
      )-%>
<%    end -%>
<%  end -%>
<%= report_render -%>
---

Ps.: This is running fine on Satellite 6.7, however, in 6.6 it's necessary to change the safemode to "No". Checking the backport possibility.

Thank you!
Waldirio

Comment 5 Waldirio M Pinheiro 2020-04-22 19:32:02 UTC
Hello,

Below the workaround, if the customer is looking for this kind of report

There we are, now, let's automate this process to generate the same kind of information to all of your content hosts
 
---
#!/bin/bash
 
for b in $(hammer --csv --no-headers host list --thin 1 --search 'name !~ virt-who*' | cut -d, -f2)
do
 for i in $(hammer --csv --no-headers host package list --host $b --search 'nvra ~ iptraf or yum or zlib')
 do
echo "$b,$i"
 done
done
---
 
 
Cool, with the script above, we will get the output as below
 
---
[root@wallsat66 installed_packages]# ./installed_packages.sh
dhcp-8-29-139.lab.eng.rdu2.redhat.com,yum-3.4.3-158.el7.noarch
dhcp-8-29-139.lab.eng.rdu2.redhat.com,yum-metadata-parser-1.1.4-10.el7.x86_64
dhcp-8-29-139.lab.eng.rdu2.redhat.com,yum-rhn-plugin-2.0.1-10.el7.noarch
dhcp-8-29-139.lab.eng.rdu2.redhat.com,zlib-1.2.7-17.el7.x86_64
...
---

Comment 7 Bryan Kearney 2020-05-11 16:05:25 UTC
Upstream bug assigned to wpinheir

Comment 9 Bryan Kearney 2022-11-01 16:01:30 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/29590 has been resolved.

Comment 16 errata-xmlrpc 2023-05-03 13:20:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.13 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2097