diff options
author | Alvaro Aleman <alv2412@googlemail.com> | 2016-09-09 19:21:58 +0200 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2016-09-09 13:21:58 -0400 |
commit | e8897a9b917be47431df68141c3977f3ab57942e (patch) | |
tree | abcb27272b2ba6e6a583548c04dcb9fce9362297 | |
parent | ee080eddb5ec6cf716cd843e5c6d0bfe40d6dc35 (diff) | |
download | ansible-e8897a9b917be47431df68141c3977f3ab57942e.tar.gz |
Fix from_yaml for non-string_types. This resolves #17397 (#17398)
-rw-r--r-- | lib/ansible/plugins/filter/core.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index 2ec50f4980..79b6c22d78 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -193,6 +193,11 @@ def regex_escape(string): '''Escape all regular expressions special characters from STRING.''' return re.escape(string) +def from_yaml(data): + if isinstance(data, string_types): + return yaml.safe_load(data) + return data + @environmentfilter def rand(environment, end, start=None, step=None): r = SystemRandom() @@ -402,7 +407,7 @@ class FilterModule(object): # yaml 'to_yaml': to_yaml, 'to_nice_yaml': to_nice_yaml, - 'from_yaml': yaml.safe_load, + 'from_yaml': from_yaml, #date 'to_datetime': to_datetime, |