Bug 1807677
| Summary: | Ansible facts disappear immediately after role is run | ||
|---|---|---|---|
| Product: | Red Hat Satellite | Reporter: | mithun kalyat <mkalyat> |
| Component: | Ansible - Configuration Management | Assignee: | satellite6-bugs <satellite6-bugs> |
| Status: | CLOSED ERRATA | QA Contact: | Danny Synk <dsynk> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 6.6.0 | CC: | dmatoule, egolov |
| Target Milestone: | 6.10.0 | Keywords: | Triaged |
| Target Release: | Unused | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | ansible-collection-redhat-satellite-2.1.0 | 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: | |||
Created redmine issue https://projects.theforeman.org/issues/30095 from this bug Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/30095 has been resolved. Steps to Test: 1. Register host to Satellite 6.10, snap 8 and configure it for remote execution using the Global Registration Template. 2. Create a new role on the Satellite: # ansible-galaxy init /usr/share/ansible/roles/bz1807677.test 3. Modify tasks/main.yml to match the content provided in the description of this bug: ~~~ - name: Set OS-dependent variables include_vars: "{{ role_path }}/vars/{{ ansible_facts.os_family }}.yml" failed_when: false - debug: msg: "{{ testvar }}" ~~~ 4. Assign the bz1807677.test role to the host registered in step 1. 5. Select "Run Ansible roles" on the Hosts > All Hosts > [hostname] page for the host. 6. When the run completes, check the Hosts > All Hosts > [hostname] > Facts page for the host and /var/log/foreman/production.log for changes to that host's facts. Expected Results: Facts for the host are persistently populated in the Satellite webUI. /var/log/foreman/production.log shows that facts have been added for the host but that no facts have been deleted for the host. Actual results: Facts for the host are persistently populated in the Satellite webUI. /var/log/foreman/production.log shows that facts have been added for the host but that no facts have been deleted for the host: ~~~ # fgrep "Import facts for 'host.example.com" /var/log/foreman/production.log 2021-07-12T15:48:02 [I|app|6251f23a] Import facts for 'host.example.com' completed. Added: 170, Updated: 0, Deleted 0 facts 2021-07-12T15:52:30 [I|app|58b18da3] Import facts for 'host.example.com' completed. Added: 316, Updated: 0, Deleted 0 facts ~~~ Verified on Satellite 6.10, snap 8 (ansible-collection-redhat-satellite-2.1.1-1.el7sat.noarch). 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 |
Description of problem: Ansible facts disappear immediately after role is run Version-Release number of selected component (if applicable): Red Hat Satellite 6.6 How reproducible: Assign a role to a host, run playbook and watch the facts page. Will see a number of Ansible facts getting populated. However, as soon as the playbook is finished, all those Ansible facts disappear (except for one custom fact). Steps to Reproduce: Create the role: cat tasks/main.yml --> Not working - name: Set OS-dependent variables include_vars: "{{ role_path }}/vars/{{ ansible_facts.os_family }}.yml" failed_when: false - debug: msg: "{{ testvar }}" cat tasks/main.yml --> Working - name: Set OS-dependent variables include_vars: "{{ item }}" failed_when: false loop: - "{{ role_path }}/vars/{{ ansible_facts.os_family }}.yml" cat vars/RedHat.yml testvar: Red Hat var Actual results: The issue is caused by include_vars directive - but only when not using the loop directive. See both examples above, one is working fine, the other one causes all facts to be deleted from Satellite and adding that one variable/fact coming from RedHat.yml. You should be able to observe this issue in /var/log/foreman/production.log. First non-working example, then working (look at timestamps). # grep "Import facts" production.log 2020-02-21T09:20:09 [I|app|8185609a] Import facts for 'host.example.com' completed. Added: 496, Updated: 0, Deleted 1 facts 2020-02-21T09:20:13 [I|app|a6569bb4] Import facts for 'host.example.com' completed. Added: 1, Updated: 0, Deleted 496 facts 2020-02-21T09:21:51 [I|app|e70b6bec] Import facts for 'host.example.com' completed. Added: 496, Updated: 0, Deleted 1 facts Expected results: Facts should not disappear Additional info: