Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2155392

Summary: Host config report page raises "undefined method `[]' for nil:NilClass" error
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Ansible - Configuration ManagementAssignee: Hao Chang Yu <hyu>
Status: CLOSED ERRATA QA Contact: addubey
Severity: medium Docs Contact:
Priority: medium    
Version: 6.11.4CC: addubey, arsingh, nalfassi, pcreech, pmoravec
Target Milestone: 6.13.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-foreman_ansible-10.3.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-03 13:23:43 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 Hao Chang Yu 2022-12-21 05:07:14 UTC
Description of problem:
Host config report page raises "undefined method `[]' for nil:NilClass" error if an ansible task reported multiple results per module action. For example, copy multiple files using loop.

-----------------------
[I|app|ae69c14e] Processing by ConfigReportsController#show as HTML
[I|app|ae69c14e]   Parameters: {"id"=>"18694"}
[I|app|ae69c14e]   Rendering config_reports/show.html.erb within layouts/application
[I|app|ae69c14e]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb (Duration: 12.4ms | Allocations: 7413)
[I|app|ae69c14e]   Rendered config_reports/show.html.erb within layouts/application (Duration: 34.6ms | Allocations: 15873)
[W|app|ae69c14e] undefined method `[]' for nil:NilClass
[I|app|ae69c14e] Backtrace for 'undefined method `[]' for nil:NilClass' error (ActionView::Template::Error): undefined method `[]' for nil:NilClass
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/helpers/foreman_ansible/ansible_reports_helper.rb:47:in `ansible_module_message'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb:24:in `block in _8af412795d3bd4ecb65c84004fd343a7'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/delegation.rb:88:in `each'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/delegation.rb:88:in `each'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb:18:in `_8af412795d3bd4ecb65c84004fd343a7'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/base.rb:274:in `_run'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:185:in `block in render'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:182:in `instrument'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:385:in `instrument_render_template'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:183:in `render'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/partial_renderer.rb:357:in `block in render_partial'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `block in instrument'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `instrument'
-----------------------

How reproducible:
Easy

Steps to Reproduce:
1. Create a custom role which copy multiple files

mkdir /etc/ansible/roles/copy_ssh_keys/
mkdir /etc/ansible/roles/copy_ssh_keys/tasks

# Create this file
main.yml 
---
- name: Copy ssh keys
  copy:
    src: "/var/lib/foreman-proxy/ssh/{{ item }}"
    dest: "/root/.ssh"
    owner: root
    group: root
    mode: 0400
  with_items:
    - id_rsa_foreman_proxy
    - id_rsa_foreman_proxy.pub


2. Import the 'copy_ssh_keys' role to the Satellite and add it to a host
3. Trigger host ansible role job and wait until the job is finished successfully
4. Inspect the config report of this host job in Web UI -> Config Reports -> hostname

Actual results:
undefined method `[]' for nil:NilClass

Expected results:
Can show report without error.

Comment 1 Hao Chang Yu 2022-12-21 05:17:23 UTC
Create an upstream bug: https://projects.theforeman.org/issues/35885

Comment 3 Bryan Kearney 2023-01-16 12:03:15 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/35885 has been resolved.

Comment 9 Arzoo Singh 2023-04-14 17:22:24 UTC
Hi Team,

Can we have an update on below request from the customer   

Will a hotfix or patch be made available for Satellite 6.11.4.1?

If not, will the fix be added to a minor release for 6.11 or will we need to upgrade to a new major version?

Comment 11 errata-xmlrpc 2023-05-03 13:23:43 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

Comment 12 Red Hat Bugzilla 2023-11-30 04:25:05 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days