Bug 1810600

Summary: [RFE] Ansible Role execution reports are not exactly human readable
Product: Red Hat Satellite Reporter: Jan Jansky <jjansky>
Component: Ansible - Configuration ManagementAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Danny Synk <dsynk>
Severity: medium Docs Contact:
Priority: high    
Version: 6.6.0CC: ahumbe, avroy, dsinglet, dsynk, egolov, ktordeur, ldixon, mkalyat, mmccune, nikhjain, pcreech, sigbjorn.lie, smallamp, zhunting
Target Milestone: 6.10.0Keywords: FutureFeature, Patch
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: ansible-collection-redhat-satellite-2.1.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-16 14:09:07 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 Jan Jansky 2020-03-05 14:53:43 UTC
Description of problem: When Ansible Roles are executed Ansible report is create, but it is marked in reports with origin N/A instead of Ansible, also output in Ansible report is in json, which is not exactly human readable output


Version-Release number of selected component (if applicable):
tfm-rubygem-foreman_ansible-3.0.7.1-1.el7sat.noarch
ansible-2.8.8-1.el7ae.noarch


How reproducible: Always


Steps to Reproduce:
1. Create host with attached ansible roles
2. WebUI -> All Hosts -> Select Host -> Select Action -> Play Ansible roles
3. Wait until finished
4. WebUI -> Monitor -> Config Management
5. remove filter
6. select Ansible report

Actual results:
in step 5. you see N/A origin instead of Ansible origin
in step 6. you see json output

for example:

{"foreman": {"owner_name": "Admin User", "foreman_host_collections": [], "content_view_info": {"published": "2020-03-05T13:33:55.111Z", "version": "2.0", "latest-version": "2.0", "components": {}, "label": "RHEL8"}, "ssh_authorized_keys": [], "domainname": "x.example.com", "owner_email": "root.com", "root_pw": "example", "location_title": "LOCATION", "foreman_users": {"admin": {"name": "admin", "ssh_authorized_keys": [], "mail": "root.com", "firstname": "Admin", "lastname": "User", "fullname": "Admin User", "description": null}}, "lifecycle_environment": "LE", "kt_cv": "CV", "foreman_env": "common", "puppet_ca": "ca.x.example.com", "foreman_subnets": [{"dns_primary": "127.0.0.1", "network_type": "IPv4", "from": "192.168.1.2", "description": "", "name": "192.168.1.254", "ipam": "DHCP", "mask": "255.255.255.0", "vlanid": null, "mtu": 1500, "to": "192.168.1.10", "dns_secondary": "", "gateway": "192.168.1.1", "network": "192.168.1.10", "boot_mode": "DHCP"}], "foreman_config_groups": [], "foreman_domain_description": "", "content_view": "CV", "hostgroup": "CV/CV-prod", "kickstart_repository": "Red_Hat_Enterprise_Linux_8_for_x86_64_-_BaseOS_Kickstart_x86_64_8_1", "organization_title": "ORG", "puppetmaster": "sat.x.example.com", "kt_env": "common", "location": "LOC", "foreman_interfaces": [{"managed": true, "ip": "192.168.1.10", "primary": true, "mac": "AA:BB:CC:DD:EE:FF", "tag": null, "ip6": null, "attrs": {"netmask6": "ffff:ffff:ffff:ffff::", "network": "192.168.1.10", "bindings6": [{"netmask": "ffff:ffff:ffff:ffff::", "network": "fe80::", "address": "fe80::5054:ff:fe9b:ef84"}], "mtu": 1500, "netmask": "255.255.255.0", "network6": "fe80::", "dhcp": "192.168.1.10", "bindings": [{"netmask": "255.255.255.0", "network": "192.168.1.10", "address": "192.168.1.10"}]}, "subnet6": null, "provision": true, "subnet": {"dns_primary": "127.0.0.1", "network_type": "IPv4", "from": "192.168.1.2", "description": "", "name": "192.168.1.10", "ipam": "DHCP", "mask": "255.255.255.0", "vlanid": null, "mtu": 1500, "to": "192.168.1.254", "dns_secondary": "", "gateway": "192.168.1.1", "network": "192.168.1.10", "boot_mode": "DHCP"}, "attached_to": null, "name": "host.x.example.com", "virtual": false, "link": true, "identifier": "ens3", "type": "Interface"}], "organization": "ORG"}, "changed": false, "_ansible_verbose_always": true, "_ansible_no_log": false}

Expected results:
Icon for Ansible report.
Human readable output

Comment 8 Shira Maximov 2020-04-20 07:51:41 UTC
In this bug, we have to separate issue: 
1. An RFE to present the logs in a different way. 
2. A BZ -> reports do not show Ansible Icon 

so I'm splitting those two issues:
I've created another issue for BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1825761 and I'm changing this one to be an RFE.

Comment 10 Shira Maximov 2020-04-20 07:53:37 UTC
Created redmine issue https://projects.theforeman.org/issues/29572 from this bug

Comment 11 Marek Hulan 2021-02-16 10:45:55 UTC
Regarding the N/A origin, the problem is in the foreman.py callback that is shipped in the latest Ansible release. In order to fix that, the foreman.py from the satellite ansible collection is required. The most straightforward way to fix that is this:

wget https://raw.githubusercontent.com/RedHatSatellite/satellite-ansible-collection/develop/plugins/callback/foreman.py -O /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py

I tested this with Ansible 2.9.16 and it fixes the problem. Once the report is correctly recognized as Ansible, the JSONs are parsed and you can interactively navigate through their structure. Longer term, it's planned to create a textual representation of these JSONs.

Comment 12 Marek Hulan 2021-02-16 12:31:51 UTC
Or actually better, install the RPM from Satellite repos and reconfigure Capsule to use this callback instead

foreman-maintain packages unlock
yum install ansible-collection-redhat-satellite
foreman-maintain packages lock

edit the /etc/foreman-proxy/ansible.cfg and change the line

> callback_whitelist = foreman
to
> callback_whitelist = redhat.satellite.foreman

The origin is then recognized (at least with 6.9 beta) and JSONs properly clickable.

Comment 15 Bryan Kearney 2021-05-28 10:16:01 UTC
Upstream bug assigned to ymakias

Comment 16 Bryan Kearney 2021-05-28 10:16:04 UTC
Upstream bug assigned to ymakias

Comment 17 Bryan Kearney 2021-06-08 08:00:43 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/32189 has been resolved.

Comment 22 Danny Synk 2021-09-27 15:39:11 UTC
Verified on Satellite 6.10, snap 20 (tfm-rubygem-foreman_ansible-6.3.4-1.el7sat.noarch).

Steps to Test:

1. Register a RHEL host to Satellite 6.10.
2. Assign Ansible roles to the host.
3. On the Hosts > All Hosts > [hostname] page, select the "Run Ansible Roles" option.
4. When the job completes, navigate to Monitor > Config Management, and open the report for the job.

Expected Results:
The report is in a more readable format than the equivalent report on Satellite 6.9 and earlier, which presents the outcome of the job in a single line of unformatted JSON.

Actual Results:
The report table now has four columns (Level, Module, Arguments, and Message) in contrast to the old report's 3 columns (Level, Resource, and Message). The Arguments and Message column still display JSON, but each key/value pair is now separated by line breaks. Lists of keys can be expanded or collapsed. Keys are color coded blue, and different data types are color coded as well (my report shows string data in light green and boolean values in red).

Comment 25 errata-xmlrpc 2021-11-16 14:09:07 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 (Moderate: Satellite 6.10 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-2021:4702

Comment 26 Red Hat Bugzilla 2024-04-14 04:25:27 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days