diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index 747029a4551..88934e179ac 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -274,7 +274,7 @@ class Templar: def _clean_data(self, orig_data): ''' remove jinja2 template tags from a string ''' - if not isinstance(orig_data, string_types) or hasattr(orig_data, '__UNSAFE__'): + if not isinstance(orig_data, string_types): return orig_data with contextlib.closing(StringIO(orig_data)) as data: @@ -383,6 +383,7 @@ class Templar: overrides=overrides, disable_lookups=disable_lookups, ) + unsafe = hasattr(result, '__UNSAFE__') if convert_data and not self._no_type_regex.match(variable): # if this looks like a dictionary or list, convert it to such using the safe_eval method