mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
fixed caches (#30667)
This commit is contained in:
parent
0b8e38d022
commit
2ffe3c42bb
7 changed files with 27 additions and 22 deletions
|
@ -58,6 +58,7 @@ from collections import MutableMapping
|
|||
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleParserError
|
||||
from ansible.plugins.cache import FactCache
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.utils.vars import combine_vars
|
||||
|
@ -72,6 +73,8 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
|
||||
super(InventoryModule, self).__init__()
|
||||
|
||||
self._cache = FactCache()
|
||||
|
||||
def verify_file(self, path):
|
||||
|
||||
valid = False
|
||||
|
@ -86,7 +89,7 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
def parse(self, inventory, loader, path, cache=False):
|
||||
''' parses the inventory file '''
|
||||
|
||||
super(InventoryModule, self).parse(inventory, loader, path, cache=True)
|
||||
super(InventoryModule, self).parse(inventory, loader, path, cache=cache)
|
||||
|
||||
try:
|
||||
data = self.loader.load_from_file(path)
|
||||
|
@ -107,8 +110,8 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
|
||||
# get available variables to templar
|
||||
hostvars = inventory.hosts[host].get_vars()
|
||||
if host in inventory.cache: # adds facts if cache is active
|
||||
hostvars = combine_vars(hostvars, inventory.cache[host])
|
||||
if host in self._cache: # adds facts if cache is active
|
||||
hostvars = combine_vars(hostvars, self._cache[host])
|
||||
|
||||
# create composite vars
|
||||
self._set_composite_vars(data.get('compose'), hostvars, host, strict=strict)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue