From 5bddecb048aae0a7fc84e38e086ac90445c4edb4 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 7 Feb 2022 09:57:38 -0500 Subject: [PATCH] gather_facts sees collection networking connection (#76954) needed to properly propagate some arguments by convention: subset, filter Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> --- changelogs/fragments/gather_facts_collections.yml | 2 ++ lib/ansible/plugins/action/gather_facts.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/gather_facts_collections.yml diff --git a/changelogs/fragments/gather_facts_collections.yml b/changelogs/fragments/gather_facts_collections.yml new file mode 100644 index 00000000000..2b6feae4d7c --- /dev/null +++ b/changelogs/fragments/gather_facts_collections.yml @@ -0,0 +1,2 @@ +bugfixes: + - gather_facts action now handles the move of base connection plugin types into collections to add/prevent subset argument correctly diff --git a/lib/ansible/plugins/action/gather_facts.py b/lib/ansible/plugins/action/gather_facts.py index 45802ea26a8..50e13b660bb 100644 --- a/lib/ansible/plugins/action/gather_facts.py +++ b/lib/ansible/plugins/action/gather_facts.py @@ -22,8 +22,13 @@ class ActionModule(ActionBase): # deal with 'setup specific arguments' if fact_module not in C._ACTION_SETUP: + # TODO: remove in favor of controller side argspec detecing valid arguments # network facts modules must support gather_subset - if self._connection._load_name not in ('network_cli', 'httpapi', 'netconf'): + try: + name = self._connection.redirected_names[-1].replace('ansible.netcommon.', '', 1) + except (IndexError, AttributeError): + name = self._connection._load_name.split('.')[-1] + if name not in ('network_cli', 'httpapi', 'netconf'): subset = mod_args.pop('gather_subset', None) if subset not in ('all', ['all']): self._display.warning('Ignoring subset(%s) for %s' % (subset, fact_module))