mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 07:01:22 -07:00
less code
(cherry picked from commit 20d9f79a5250e764ffeddb046aeb82b7824ed952)
This commit is contained in:
parent
eb887b8062
commit
79b9c585ea
1 changed files with 3 additions and 6 deletions
|
@ -80,13 +80,10 @@ class HostVars(collections.Mapping):
|
||||||
def __getitem__(self, host_name):
|
def __getitem__(self, host_name):
|
||||||
data = self.raw_get(host_name)
|
data = self.raw_get(host_name)
|
||||||
sha1_hash = sha1(str(data).encode('utf-8')).hexdigest()
|
sha1_hash = sha1(str(data).encode('utf-8')).hexdigest()
|
||||||
if sha1_hash in self._cached_result:
|
if sha1_hash not in self._cached_result:
|
||||||
result = self._cached_result[sha1_hash]
|
|
||||||
else:
|
|
||||||
templar = Templar(variables=data, loader=self._loader)
|
templar = Templar(variables=data, loader=self._loader)
|
||||||
result = templar.template(data, fail_on_undefined=False, static_vars=STATIC_VARS)
|
self._cached_result[sha1_hash] = templar.template(data, fail_on_undefined=False, static_vars=STATIC_VARS)
|
||||||
self._cached_result[sha1_hash] = result
|
return self._cached_result[sha1_hash]
|
||||||
return result
|
|
||||||
|
|
||||||
def set_host_variable(self, host, varname, value):
|
def set_host_variable(self, host, varname, value):
|
||||||
self._variable_manager.set_host_variable(host, varname, value)
|
self._variable_manager.set_host_variable(host, varname, value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue