1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix an issue where cache plugins weren't updated

The first call to persisting facts would work due to the assignment of a
MutableMapping calling __setitem__ but subsequent module fact data would
not be propogated to the fact cache plugins because update() doesn't
invoke __setitem__.  This changes the behavior a little bit and ensures
set() is called on cache plugins.
This commit is contained in:
Matthew Jones 2015-10-09 11:16:41 -04:00
parent d1b98ec776
commit 7da478a4f4
2 changed files with 6 additions and 1 deletions

View file

@ -68,3 +68,8 @@ class FactCache(MutableMapping):
def flush(self):
""" Flush the fact cache of all keys. """
self._plugin.flush()
def update(self, key, value):
host_cache = self._plugin.get(key)
host_cache.update(value)
self._plugin.set(key, host_cache)

View file

@ -546,7 +546,7 @@ class VariableManager:
self._fact_cache[host.name] = facts
else:
try:
self._fact_cache[host.name].update(facts)
self._fact_cache.update(host.name, facts)
except KeyError:
self._fact_cache[host.name] = facts