mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Restoring templating of hostvars returned by __getitem__
This commit is contained in:
parent
9f31c073fe
commit
f10d2c57c8
1 changed files with 8 additions and 17 deletions
|
@ -70,23 +70,14 @@ class HostVars(collections.Mapping):
|
|||
|
||||
data = self._variable_manager.get_vars(loader=self._loader, host=host, play=self._play, include_hostvars=False)
|
||||
|
||||
#****************************************************
|
||||
# TESTING REMOVAL OF THIS
|
||||
#****************************************************
|
||||
# Since we template much later now in 2.0, it may be completely unrequired to do
|
||||
# a full template of the vars returned above, which is quite costly in time when
|
||||
# the result is large.
|
||||
# Using cache in order to avoid template call
|
||||
#sha1_hash = sha1(str(data).encode('utf-8')).hexdigest()
|
||||
#if sha1_hash in self._cached_result:
|
||||
# result = self._cached_result[sha1_hash]
|
||||
#else:
|
||||
# templar = Templar(variables=data, loader=self._loader)
|
||||
# result = templar.template(data, fail_on_undefined=False, static_vars=STATIC_VARS)
|
||||
# self._cached_result[sha1_hash] = result
|
||||
#return result
|
||||
#****************************************************
|
||||
return data
|
||||
sha1_hash = sha1(str(data).encode('utf-8')).hexdigest()
|
||||
if sha1_hash in self._cached_result:
|
||||
result = self._cached_result[sha1_hash]
|
||||
else:
|
||||
templar = Templar(variables=data, loader=self._loader)
|
||||
result = templar.template(data, fail_on_undefined=False, static_vars=STATIC_VARS)
|
||||
self._cached_result[sha1_hash] = result
|
||||
return result
|
||||
|
||||
def __contains__(self, host_name):
|
||||
return self._find_host(host_name) is not None
|
||||
|
|
Loading…
Reference in a new issue