diff --git a/lib/ansible/module_utils/network/common/facts/facts.py b/lib/ansible/module_utils/network/common/facts/facts.py index 0914bbbc5b106c..b46299437a5a74 100644 --- a/lib/ansible/module_utils/network/common/facts/facts.py +++ b/lib/ansible/module_utils/network/common/facts/facts.py @@ -90,28 +90,30 @@ def get_network_resources_facts(self, facts_resource_obj_map, resource_facts_typ if not resource_facts_type: resource_facts_type = self._gather_network_resources - restorun_subsets = self.gen_runable(resource_facts_type, frozenset(facts_resource_obj_map.keys()), resource_facts=True) - if restorun_subsets: - self.ansible_facts['ansible_net_gather_network_resources'] = list(restorun_subsets) - instances = list() - for key in restorun_subsets: - fact_cls_obj = facts_resource_obj_map.get(key) - if fact_cls_obj: - instances.append(fact_cls_obj(self._module)) - else: - self._warnings.extend(["network resource fact gathering for '%s' is not supported" % key]) - - for inst in instances: - inst.populate_facts(self._connection, self.ansible_facts, data) + restorun_subsets = self.gen_runable(resource_facts_type, frozenset(facts_resource_obj_map.keys()), resource_facts=True) + if restorun_subsets: + self.ansible_facts['ansible_net_gather_network_resources'] = list(restorun_subsets) + instances = list() + for key in restorun_subsets: + fact_cls_obj = facts_resource_obj_map.get(key) + if fact_cls_obj: + instances.append(fact_cls_obj(self._module)) + else: + self._warnings.extend(["network resource fact gathering for '%s' is not supported" % key]) + + for inst in instances: + inst.populate_facts(self._connection, self.ansible_facts, data) def get_network_legacy_facts(self, fact_legacy_obj_map, legacy_facts_type=None): if not legacy_facts_type: legacy_facts_type = self._gather_subset runable_subsets = self.gen_runable(legacy_facts_type, frozenset(fact_legacy_obj_map.keys())) - runable_subsets.add('default') if runable_subsets: facts = dict() + # default subset should always returned be with legacy facts subsets + if 'default' not in runable_subsets: + runable_subsets.add('default') self.ansible_facts['ansible_net_gather_subset'] = list(runable_subsets) instances = list() diff --git a/lib/ansible/module_utils/network/exos/argspec/facts/facts.py b/lib/ansible/module_utils/network/exos/argspec/facts/facts.py index 684c093097d791..4ab2e934ea63bc 100644 --- a/lib/ansible/module_utils/network/exos/argspec/facts/facts.py +++ b/lib/ansible/module_utils/network/exos/argspec/facts/facts.py @@ -17,15 +17,7 @@ class FactsArgs(object): # pylint: disable=R0903 def __init__(self, **kwargs): pass - choices = [ - 'all', - '!all', - 'lldp_global', - '!lldp_global' - ] - argument_spec = { 'gather_subset': dict(default=['!config'], type='list'), - 'gather_network_resources': dict(choices=choices, - type='list'), + 'gather_network_resources': dict(type='list'), } diff --git a/lib/ansible/module_utils/network/exos/facts/facts.py b/lib/ansible/module_utils/network/exos/facts/facts.py index d9a8d4fdba659d..04c08ea78d36de 100644 --- a/lib/ansible/module_utils/network/exos/facts/facts.py +++ b/lib/ansible/module_utils/network/exos/facts/facts.py @@ -46,9 +46,8 @@ def get_facts(self, legacy_facts_type=None, resource_facts_type=None, data=None) :rtype: dict :return: the facts gathered """ - netres_choices = FactsArgs.argument_spec['gather_network_resources'].get('choices', []) if self.VALID_RESOURCE_SUBSETS: - self.get_network_resources_facts(netres_choices, FACT_RESOURCE_SUBSETS, resource_facts_type, data) + self.get_network_resources_facts(FACT_RESOURCE_SUBSETS, resource_facts_type, data) if self.VALID_LEGACY_GATHER_SUBSETS: self.get_network_legacy_facts(FACT_LEGACY_SUBSETS, legacy_facts_type) diff --git a/lib/ansible/module_utils/network/iosxr/facts/facts.py b/lib/ansible/module_utils/network/iosxr/facts/facts.py index b3bae0d360009b..cc7629baff4da4 100644 --- a/lib/ansible/module_utils/network/iosxr/facts/facts.py +++ b/lib/ansible/module_utils/network/iosxr/facts/facts.py @@ -64,7 +64,7 @@ def get_facts(self, legacy_facts_type=None, resource_facts_type=None, data=None) :return: the facts gathered """ if self.VALID_RESOURCE_SUBSETS: - self.get_network_resources_facts( FACT_RESOURCE_SUBSETS, resource_facts_type, data) + self.get_network_resources_facts(FACT_RESOURCE_SUBSETS, resource_facts_type, data) if self.VALID_LEGACY_GATHER_SUBSETS: self.get_network_legacy_facts(FACT_LEGACY_SUBSETS, legacy_facts_type) diff --git a/lib/ansible/module_utils/network/junos/argspec/facts/facts.py b/lib/ansible/module_utils/network/junos/argspec/facts/facts.py index 83e49b6f8f48f5..5b90f847e9a2af 100644 --- a/lib/ansible/module_utils/network/junos/argspec/facts/facts.py +++ b/lib/ansible/module_utils/network/junos/argspec/facts/facts.py @@ -7,6 +7,7 @@ The arg spec for the junos facts module. """ + class FactsArgs(object): """ The arg spec for the junos facts module """ diff --git a/lib/ansible/modules/network/exos/exos_facts.py b/lib/ansible/modules/network/exos/exos_facts.py index b3c713f4182a3b..6672310c98fbfb 100644 --- a/lib/ansible/modules/network/exos/exos_facts.py +++ b/lib/ansible/modules/network/exos/exos_facts.py @@ -60,7 +60,9 @@ to a given subset. Possible values for this argument include all and the resources like interfaces, vlans etc. Can specify a list of values to include a larger subset. - choices: ['all', '!all', 'lldp_global', '!lldp_global'] + Values can also be used with an initial C(M(!)) to specify that + a specific subset should not be collected. + Valid subsets are 'all', 'lldp_global'. type: list version_added: "2.9" """