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 1807677 - Ansible facts disappear immediately after role is run
Summary: Ansible facts disappear immediately after role is run
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible - Configuration Management
Version: 6.6.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: 6.10.0
Assignee: satellite6-bugs
QA Contact: Danny Synk
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-26 22:23 UTC by mithun kalyat
Modified: 2021-11-16 14:09 UTC (History)
2 users (show)

Fixed In Version: ansible-collection-redhat-satellite-2.1.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 14:09:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 30095 0 Normal New Ansible facts disappear immediately after role is run 2021-01-26 18:37:30 UTC
Red Hat Product Errata RHSA-2021:4702 0 None None None 2021-11-16 14:09:18 UTC

Description mithun kalyat 2020-02-26 22:23:30 UTC
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:

Comment 3 Dominik Matoulek 2020-06-10 11:51:45 UTC
Created redmine issue https://projects.theforeman.org/issues/30095 from this bug

Comment 4 Bryan Kearney 2021-05-09 16:19:12 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/30095 has been resolved.

Comment 5 Danny Synk 2021-07-12 20:07:53 UTC
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).

Comment 8 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


Note You need to log in before you can comment on or make changes to this bug.