py2/py3 safer shas on hostvars (#31788)
* py2/py3 safer shas on hostvars * plain bytes
This commit is contained in:
parent
7acce3b958
commit
68f177d381
1 changed files with 2 additions and 1 deletions
|
@ -23,6 +23,7 @@ import collections
|
|||
|
||||
from jinja2.runtime import Undefined
|
||||
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.template import Templar
|
||||
|
||||
STATIC_VARS = [
|
||||
|
@ -85,7 +86,7 @@ class HostVars(collections.Mapping):
|
|||
|
||||
def __getitem__(self, host_name):
|
||||
data = self.raw_get(host_name)
|
||||
sha1_hash = sha1(str(data).encode('utf-8')).hexdigest()
|
||||
sha1_hash = sha1(to_bytes(data)).hexdigest()
|
||||
if sha1_hash not in self._cached_result:
|
||||
templar = Templar(variables=data, loader=self._loader)
|
||||
self._cached_result[sha1_hash] = templar.template(data, fail_on_undefined=False, static_vars=STATIC_VARS)
|
||||
|
|
Loading…
Reference in a new issue