@@ -21,11 +21,7 @@ class Facts(FactsArgs, FactsBase): #pylint: disable=R0903
21
21
""" The fact class for {{ network_os }}
22
22
"""
23
23
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' ]):
29
25
""" Collect the facts for {{ network_os }}
30
26
31
27
:param module: The module instance
@@ -34,25 +30,29 @@ class Facts(FactsArgs, FactsBase): #pylint: disable=R0903
34
30
:rtype: dict
35
31
:returns: the facts gathered
36
32
"""
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
+
37
37
runable_subsets = set ()
38
38
exclude_subsets = set ()
39
39
if not gather_subset :
40
40
gather_subset = ['all' ]
41
41
42
42
for subset in gather_subset :
43
43
if subset == 'all' :
44
- runable_subsets .update (self . VALID_SUBSETS )
44
+ runable_subsets .update (valid_subsets )
45
45
continue
46
46
if subset .startswith ('!' ):
47
47
subset = subset [1 :]
48
48
if subset == 'all' :
49
- exclude_subsets .update (self . VALID_SUBSETS )
49
+ exclude_subsets .update (valid_subsets )
50
50
continue
51
51
exclude = True
52
52
else :
53
53
exclude = False
54
54
55
- if subset not in self . VALID_SUBSETS :
55
+ if subset not in valid_subsets :
56
56
module .fail_json (msg = 'Bad subset' )
57
57
58
58
if exclude :
@@ -61,7 +61,7 @@ class Facts(FactsArgs, FactsBase): #pylint: disable=R0903
61
61
runable_subsets .add (subset )
62
62
63
63
if not runable_subsets :
64
- runable_subsets .update (self . VALID_SUBSETS )
64
+ runable_subsets .update (valid_subsets )
65
65
66
66
runable_subsets .difference_update (exclude_subsets )
67
67
self .ansible_facts ['gather_subset' ] = list (runable_subsets )
0 commit comments