Fix for a caching traceback
When the user specified caching plugin doesn't initialize correctly, we were falling back to a dict. however, dicts do not have the same update() method as the FactCache. We use the update method when we update a cache with a subsequent value. So when that combination of things happened, the code would traceback. In devel, we made this change to fix things: https://github.com/ansible/ansible/pull/49516 but that involves several deprecations. So we're doing this smaller hack in 2.7 to fix the traceback without introducing those deprecations in a stable release.
This commit is contained in:
parent
dc9bb38d72
commit
ad45bd72c1
2 changed files with 17 additions and 4 deletions
2
changelogs/fragments/vm_fix.yml
Normal file
2
changelogs/fragments/vm_fix.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- Fix traceback when updating facts and the fact cache plugin was nonfunctional
|
|
@ -622,10 +622,21 @@ class VariableManager:
|
|||
if host.name not in self._fact_cache:
|
||||
self._fact_cache[host.name] = facts
|
||||
else:
|
||||
if isinstance(self._fact_cache, FactCache):
|
||||
try:
|
||||
self._fact_cache.update(host.name, facts)
|
||||
except KeyError:
|
||||
self._fact_cache[host.name] = facts
|
||||
else:
|
||||
# Dictionary fallback so we need to use a dictionary update.
|
||||
try:
|
||||
host_cache = self._fact_cache[host.name]
|
||||
except KeyError:
|
||||
host_cache = facts
|
||||
else:
|
||||
host_cache.update(facts)
|
||||
|
||||
self._fact_cache[host.name] = host_cache
|
||||
|
||||
def set_nonpersistent_facts(self, host, facts):
|
||||
'''
|
||||
|
|
Loading…
Reference in a new issue