needed intesect, not difference (#84839) (#84860)

fixes #84750

Added tests to verify output when using smart + others

(cherry picked from commit 0d4f00f5c8)
pull/84958/head
Brian Coca 8 months ago committed by GitHub
parent 0c6bad800e
commit 73189a7a8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- gather_facts action, will now add setup when 'smart' appears with other modules in the FACTS_MODULES setting (#84750).

@ -95,7 +95,7 @@ class ActionModule(ActionBase):
self._display.warning("Detected 'setup' module and a network OS is set, the output when running it will reflect 'localhost'"
" and not the target when a netwoking connection plugin is used.")
elif not set(modules).difference(set(C._ACTION_SETUP)):
elif not set(modules).intersection(set(C._ACTION_SETUP)):
# no network OS and setup not in list, add setup by default since 'smart'
modules.append('ansible.legacy.setup')

@ -45,4 +45,7 @@ ANSIBLE_FACTS_MODULES='smart' ansible -m gather_facts localhost -e 'ansible_netw
# ensure we warn on setup + network OS
ANSIBLE_FACTS_MODULES='smart, setup' ansible -m gather_facts localhost -e 'ansible_network_os="N/A"' "$@" 2>&1 | grep "Detected 'setup' module and a network OS is set"
# ensure run setup when smart+ and no network OS
ANSIBLE_FACTS_MODULES='smart, facts_one' ansible-playbook smart_added.yml -i inventory "$@"
rm "${OUTPUT_DIR}/canary.txt"

@ -0,0 +1,11 @@
- hosts: facthost0
tasks:
- name: ensure we ran custom module AND setup.py/smart
assert:
that:
- >-
'factsone' in ansible_facts
- >-
ansible_facts['factsone'] == "from facts_one module"
- >-
'os_family' in ansible_facts
Loading…
Cancel
Save