Created
September 6, 2016 23:48
-
-
Save tbielawa/535f3f7d26e00226f768616de5f60eb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 3f5e97c3a2d1321cae918ec18ef5645bef4744cc Mon Sep 17 00:00:00 2001 | |
From: Tim Bielawa <[email protected]> | |
Date: Tue, 6 Sep 2016 16:41:08 -0700 | |
Subject: [PATCH] Fix for objects which can't be converted by the YAML parser | |
* Ansible parsed vars into special Ansible helper objects | |
* Manually cast each var into a normal string as applicable | |
--- | |
filter_plugins/oo_filters.py | 16 ++++++++++++++-- | |
1 file changed, 14 insertions(+), 2 deletions(-) | |
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py | |
index 053de77..576e23b 100644 | |
--- a/filter_plugins/oo_filters.py | |
+++ b/filter_plugins/oo_filters.py | |
@@ -621,11 +621,23 @@ class FilterModule(object): | |
return "" | |
try: | |
- transformed = yaml.safe_dump(data, indent=indent, allow_unicode=True, default_flow_style=False, **kw) | |
+ if isinstance(data, list): | |
+ _data = [] | |
+ for d in data: | |
+ _data.append(unicode(d)) | |
+ elif isinstance(data, dict): | |
+ # Assumes all values are simple strings | |
+ _data = {} | |
+ for k, v in data.iteritems(): | |
+ _data[unicode(k)] = unicode(v) | |
+ else: | |
+ _data = data | |
+ | |
+ transformed = yaml.safe_dump(_data, indent=indent, allow_unicode=True, default_flow_style=False, **kw) | |
padded = "\n".join([" " * level * indent + line for line in transformed.splitlines()]) | |
return to_unicode("\n{0}".format(padded)) | |
except Exception as my_e: | |
- raise errors.AnsibleFilterError('Failed to convert: %s' % my_e) | |
+ raise errors.AnsibleFilterError('Failed to convert: %s (type: %s; val: %s)' % (my_e, type(data), data)) | |
@staticmethod | |
def oo_openshift_env(hostvars): | |
-- | |
2.5.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment