Fixing up fact_cache use in VariableManager
This commit is contained in:
parent
932d1e57f7
commit
d977da5b41
2 changed files with 11 additions and 6 deletions
2
lib/ansible/plugins/cache/jsonfile.py
vendored
2
lib/ansible/plugins/cache/jsonfile.py
vendored
|
@ -73,7 +73,7 @@ class CacheModule(BaseCacheModule):
|
|||
except ValueError:
|
||||
# FIXME: this is in display now, but cache plugins don't have that
|
||||
#utils.warning("error while trying to write to %s : %s" % (cachefile, str(e)))
|
||||
return dict()
|
||||
raise KeyError
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
|
|
|
@ -181,7 +181,10 @@ class VariableManager:
|
|||
all_vars = self._combine_vars(all_vars, host.get_vars())
|
||||
|
||||
# next comes the facts cache and the vars cache, respectively
|
||||
all_vars = self._combine_vars(all_vars, self._fact_cache.get(host.get_name(), dict()))
|
||||
try:
|
||||
all_vars = self._combine_vars(all_vars, self._fact_cache.get(host.name, dict()))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if play:
|
||||
all_vars = self._combine_vars(all_vars, play.get_vars())
|
||||
|
@ -345,11 +348,13 @@ class VariableManager:
|
|||
|
||||
assert isinstance(facts, dict)
|
||||
|
||||
host_name = host.get_name()
|
||||
if host_name not in self._fact_cache:
|
||||
self._fact_cache[host_name] = facts
|
||||
if host.name not in self._fact_cache:
|
||||
self._fact_cache[host.name] = facts
|
||||
else:
|
||||
self._fact_cache[host_name].update(facts)
|
||||
try:
|
||||
self._fact_cache[host.name].update(facts)
|
||||
except KeyError:
|
||||
self._fact_cache[host.name] = facts
|
||||
|
||||
def set_host_variable(self, host, varname, value):
|
||||
'''
|
||||
|
|
Loading…
Reference in a new issue