Bug 1694014 - Custom fact file /etc/ansible/facts.d/openshift.fact not updated with inventory changes
Summary: Custom fact file /etc/ansible/facts.d/openshift.fact not updated with invento...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Installer
Version: 3.11.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 3.11.z
Assignee: Vadim Rutkovsky
QA Contact: Gaoyun Pei
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-29 10:15 UTC by Ravi Trivedi
Modified: 2019-11-18 14:52 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-18 14:52:08 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift openshift-ansible pull 11965 0 'None' closed Bug 1694014: add more vars to json facts list 2021-01-12 03:21:37 UTC
Red Hat Product Errata RHBA-2019:3817 0 None None None 2019-11-18 14:52:18 UTC

Description Ravi Trivedi 2019-03-29 10:15:31 UTC
Description of problem:

/etc/ansible/facts.d/openshift.fact is not populated with updated values on Openshift Cluster unless it is manually deleted. 

Version-Release number of the following components:

$ ansible --version
ansible 2.6.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/arctst/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, May  3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]

$ rpm -qi ansible
Name        : ansible
Version     : 2.6.6
Release     : 1.el7ae
Architecture: noarch
Install Date: Fri 01 Feb 2019 11:02:42 GMT
Group       : Development/Libraries
Size        : 54376616
License     : GPLv3+
Signature   : RSA/SHA256, Mon 22 Oct 2018 06:47:48 BST, Key ID 199e2f91fd431d51
Source RPM  : ansible-2.6.6-1.el7ae.src.rpm
Build Date  : Sat 20 Oct 2018 00:09:16 BST
Build Host  : ppc-048.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
URL         : http://ansible.com
Summary     : SSH-based configuration management, deployment, and task execution system
Description :

How reproducible:

Always

Steps to Reproduce:
1. Check for existing /etc/ansible/facts.d/openshift.fact configuration and verify the existing values:

# cat /etc/ansible/facts.d/openshift.fact | python -m json.tool

2. Change a single associated variable in inventory file (Eg. maximumFileRetentionDays) which is present in /etc/ansible/facts.d/openshift.fact file. Example,

BEFORE:
"audit_config": {
            "auditFilePath": "/var/lib/origin/openshift-audit.log",
            "enabled": true,
            "maximumFileRetentionDays": 7,
            "maximumFileSizeMegabytes": 10,
            "maximumRetainedFiles": 3
},

EXPECTED CHANGE:
"audit_config": {
            "auditFilePath": "/var/lib/origin/openshift-audit.log",
            "enabled": true,
            "maximumFileRetentionDays": 11,		=============> Value to be changed here after playbook run
            "maximumFileSizeMegabytes": 10,
            "maximumRetainedFiles": 3
},

3. Inventory file has updated value before running playbook:

openshift_master_audit_config={"enabled": true, "auditFilePath": "/var/lib/origin/openshift-audit.log", "maximumFileRetentionDays": 11, "maximumFileSizeMegabytes": 10, "maximumRetainedFiles": 3}

4. I ran following playbook to test if the change is reflected in /etc/ansible/facts.d/openshift.fact or not:

$ ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/byo/openshift_facts.yml -vv


5. After running the playbook, there was NO CHANGE done to /etc/ansible/facts.d/openshift.fact file at all. Infact, none of the hosts had any 'changed' tasks at all.


Expected results:

The python script /usr/share/ansible/openshift-ansible/roles/openshift_facts/library/openshift_facts.py should ideally show same behavior that any idempotent module of Ansible would (i.e, re-run of playbooks should reflect the changes from inventory in the custom facts file at /etc/ansible/facts.d/openshift.fact).

Each playbook run should reflect the change in inventory file.

Currently, removal logic resides in 
/usr/share/ansible/openshift-ansible/playbooks/adhoc/uninstall_openshift.yml which would require to uninstall the cluster and install it again for a small change.

Comment 1 Vadim Rutkovsky 2019-04-02 14:04:57 UTC
Fact caching is controlled by Ansible settings, see https://docs.ansible.com/ansible/latest/plugins/cache.html

Are you using default ansible.cfg from Ansible, a custom one or the one included in the repo?
What does "ansible-config view" show? If you're using a custom ansible.cfg please add '-c <path to config>' switch

Comment 4 Ravi Trivedi 2019-04-18 10:46:34 UTC
Created attachment 1556122 [details]
ansible-config-c_ansible.cfg

Comment 22 Gaoyun Pei 2019-11-08 05:57:39 UTC
Verify this bug using openshift-ansible-3.11.154-1.git.0.7a11cbe.el7.noarch.rpm

1. Spin up a 3.11 cluster with setting the following openshift_master_audit_config in ansible inventory file
openshift_master_audit_config={"enabled": true, "auditFilePath": "/var/lib/origin/openshift-audit.log", "maximumFileRetentionDays": 10, "maximumFileSizeMegabytes": 10, "maximumRetainedFiles": 3}

2. Check the generated /etc/ansible/facts.d/openshift.fact
# cat /etc/ansible/facts.d/openshift.fact | python -m json.tool
{
...
        "audit_config": {
            "auditFilePath": "/var/lib/origin/openshift-audit.log",
            "enabled": true,
            "maximumFileRetentionDays": 10,
            "maximumFileSizeMegabytes": 10,
            "maximumRetainedFiles": 3
        },

3. Change openshift_master_audit_config in inventory file to:
openshift_master_audit_config={"enabled": true, "auditFilePath": "/var/lib/origin/openshift-audit.log", "maximumFileRetentionDays": 11, "maximumFileSizeMegabytes": 10, "maximumRetainedFiles": 3}

4. Run playbook playbooks/openshift-master/config.yml

5. Check the generated /etc/ansible/facts.d/openshift.fact again
# cat /etc/ansible/facts.d/openshift.fact | python -m json.tool
{
...

        "audit_config": {
            "auditFilePath": "/var/lib/origin/openshift-audit.log",
            "enabled": true,
            "maximumFileRetentionDays": 11,
            "maximumFileSizeMegabytes": 10,
            "maximumRetainedFiles": 3
        },

Comment 24 errata-xmlrpc 2019-11-18 14:52:08 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, 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/RHBA-2019:3817


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