@@ -21,11 +21,7 @@ class Facts(FactsArgs, FactsBase): #pylint: disable=R0903
2121 """ The fact class for {{ network_os }}
2222 """
2323
24- VALID_SUBSETS = [
25- 'net_configuration_{{ resource }}' ,
26- ]
27-
28- def get_facts (self , module , connection , gather_subset = None ):
24+ def get_facts (self , module , connection , gather_subset = ['all' ]):
2925 """ Collect the facts for {{ network_os }}
3026
3127 :param module: The module instance
@@ -34,25 +30,29 @@ class Facts(FactsArgs, FactsBase): #pylint: disable=R0903
3430 :rtype: dict
3531 :returns: the facts gathered
3632 """
33+ valid_subsets = self .argument_spec ['gather_subset' ].get ('choices' , [])
34+ if valid_subsets and 'all' in valid_subsets :
35+ valid_subsets .remove ('all' )
36+
3737 runable_subsets = set ()
3838 exclude_subsets = set ()
3939 if not gather_subset :
4040 gather_subset = ['all' ]
4141
4242 for subset in gather_subset :
4343 if subset == 'all' :
44- runable_subsets .update (self . VALID_SUBSETS )
44+ runable_subsets .update (valid_subsets )
4545 continue
4646 if subset .startswith ('!' ):
4747 subset = subset [1 :]
4848 if subset == 'all' :
49- exclude_subsets .update (self . VALID_SUBSETS )
49+ exclude_subsets .update (valid_subsets )
5050 continue
5151 exclude = True
5252 else :
5353 exclude = False
5454
55- if subset not in self . VALID_SUBSETS :
55+ if subset not in valid_subsets :
5656 module .fail_json (msg = 'Bad subset' )
5757
5858 if exclude :
@@ -61,7 +61,7 @@ class Facts(FactsArgs, FactsBase): #pylint: disable=R0903
6161 runable_subsets .add (subset )
6262
6363 if not runable_subsets :
64- runable_subsets .update (self . VALID_SUBSETS )
64+ runable_subsets .update (valid_subsets )
6565
6666 runable_subsets .difference_update (exclude_subsets )
6767 self .ansible_facts ['gather_subset' ] = list (runable_subsets )
0 commit comments