Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py2/py3 safer shas on hostvars #31788

Merged
merged 2 commits into from
Oct 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ansible/vars/hostvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from jinja2.runtime import Undefined

from ansible.module_utils._text import to_bytes
from ansible.template import Templar

STATIC_VARS = [
Expand Down Expand Up @@ -85,7 +86,7 @@ def raw_get(self, host_name):

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)
Expand Down