mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Avoid duplicate system related fact calls. (#15716)
* Avoid duplicate system related fact calls. Addresses #1461
This commit is contained in:
parent
b41b6b2ec5
commit
5bb4ee0c1e
1 changed files with 8 additions and 3 deletions
|
@ -170,10 +170,13 @@ class Facts(object):
|
|||
{ 'path' : '/usr/local/sbin/pkg', 'name' : 'pkgng' },
|
||||
]
|
||||
|
||||
def __init__(self, module, load_on_init=True):
|
||||
def __init__(self, module, load_on_init=True, cached_facts=None):
|
||||
|
||||
self.module = module
|
||||
if not cached_facts:
|
||||
self.facts = {}
|
||||
else:
|
||||
self.facts = cached_facts
|
||||
### TODO: Eventually, these should all get moved to populate(). But
|
||||
# some of the values are currently being used by other subclasses (for
|
||||
# instance, os_family and distribution). Have to sort out what to do
|
||||
|
@ -3180,7 +3183,9 @@ def ansible_facts(module, gather_subset):
|
|||
facts['gather_subset'] = list(gather_subset)
|
||||
facts.update(Facts(module).populate())
|
||||
for subset in gather_subset:
|
||||
facts.update(FACT_SUBSETS[subset](module).populate())
|
||||
facts.update(FACT_SUBSETS[subset](module,
|
||||
load_on_init=False,
|
||||
cached_facts=facts).populate())
|
||||
return facts
|
||||
|
||||
def get_all_facts(module):
|
||||
|
|
Loading…
Reference in a new issue