Bug 2107577

Summary: execution of roles with missing modules doesn't fail the execution
Product: Red Hat Satellite Reporter: Evgeni Golov <egolov>
Component: Ansible - Configuration ManagementAssignee: Adam Ruzicka <aruzicka>
Status: CLOSED ERRATA QA Contact: Sam Bible <sbible>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.11.0CC: aruzicka, gtalreja, jpasqual, lstejska, oezr, pcreech, pmendezh, rlavi, zhunting
Target Milestone: 6.12.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-smart_proxy_ansible-3.4.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-16 13:34:39 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 Evgeni Golov 2022-07-15 12:50:35 UTC
Description of problem:
Ohai,

given the following dummy role:
# cat /etc/ansible/roles/evgeni.test/tasks/main.yml
---
- name: this will fail
  nonexisting_module:

And assigning this role to a host, the resulting job invocation will not fail!

  89: TASK [Apply roles] *************************************************************
  90: ERROR! couldn't resolve module/action 'nonexisting_module'. This often indicates a misspelling, missing collection, or incorrect module path.
  91:
  92: The error appears to be in '/etc/ansible/roles/evgeni.test/tasks/main.yml': line 2, column 3, but may
  93: be elsewhere in the file depending on the exact syntax problem.
  94:
  95: The offending line appears to be:
  96:
  97: ---
  98: - name: this will fail
  99:   ^ here
 100: PLAY RECAP *********************************************************************
 101: centos8-stream-katello-4-5.tanso.example.com : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
 102: Exit status: 0

I think the problem is that there is actually no failed task reported from Ansible and we don't analyze the exit code of ansible-runner (which is 2 in this case).

Version-Release number of selected component (if applicable):
Satellite 6.11 GA
Also upstream Foreman 3.3/Katello 4.5

rubygem-smart_proxy_ansible-3.3.1-2.el8sat.noarch
rubygem-foreman_ansible-7.0.4.1-1.el8sat.noarch

rubygem-smart_proxy_ansible-3.4.0-1.fm3_3.el8.noarch
rubygem-foreman_ansible-7.1.0-3.fm3_3.el8.noarch

How reproducible:
100%

Steps to Reproduce:
1. create a role like above
2. assign it to a host
3. run

Actual results:
Job is marked as success in Satellite

Expected results:
Job is marked as failed

Additional info:

Comment 2 Bryan Kearney 2022-07-18 16:05:07 UTC
Upstream bug assigned to aruzicka

Comment 3 Bryan Kearney 2022-07-18 16:05:08 UTC
Upstream bug assigned to aruzicka

Comment 4 Ron Lavi 2022-07-27 06:24:48 UTC
Upstream PR got merged, moving to POST

Comment 5 Sam Bible 2022-08-16 19:46:20 UTC
Verified on 6.12.0 - 6.1

Steps to reproduce:
1. Create an ansible playbook as provided above by Evgeni
2. Assign it to a host, and run it

Expected results: The playbook errors, and the job also fails

Actual results: The playbook errors, and the Job is listed as a success

Additional Info:
I essentially got the same error as Evgeni did, listed below.

TASK [Apply roles] *************************************************************
ERROR! couldn't resolve module/action 'nonexisting_module'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/etc/ansible/roles/testy-2107577/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

 ---
 - name: this will fail
   ^ here
PLAY RECAP *********************************************************************
dhcp-3-58.vms.sat.rdu2.redhat.com : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
Exit status: 0

rubygem-smart_proxy_ansible.noarch                    3.4.0-1.el8sat
rubygem-foreman_ansible.noarch                        7.1.2-1.el8sat

Comment 6 Evgeni Golov 2022-08-17 07:06:07 UTC
I don't think smart_proxy_ansible 3.4.0 contains the fix for that?

cc @aruzicka

Comment 7 Adam Ruzicka 2022-08-17 07:58:55 UTC
It indeed does not. Afaik the fix was not released yet. cc @lstejskal

Comment 8 Joniel Pasqualetto 2022-08-17 15:09:57 UTC
*** Bug 2118459 has been marked as a duplicate of this bug. ***

Comment 10 Sam Bible 2022-09-12 15:18:19 UTC
Verified on 6.12.0 - 6.1

Steps to reproduce:
1. Create an ansible playbook as provided above by Evgeni
2. Assign it to a host, and run it

Expected results: The playbook errors, and the job also fails

Actual results: The playbook errors, and the Job fails as well.

Comment 11 Sam Bible 2022-09-12 15:19:09 UTC
Edit: Verified on 6.12.0 - 10

Comment 15 errata-xmlrpc 2022-11-16 13:34:39 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.12 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-2022:8506