diff --git a/lib/ansible/runner/action_plugins/unarchive.py b/lib/ansible/runner/action_plugins/unarchive.py index cfcaf454bd1..8ce7a724769 100644 --- a/lib/ansible/runner/action_plugins/unarchive.py +++ b/lib/ansible/runner/action_plugins/unarchive.py @@ -65,7 +65,7 @@ class ActionModule(object): stat = module_return.result.get('stat', None) if stat and stat.get('exists', False): return ReturnData( - conn=conn, + conn=conn, comm_ok=True, result=dict( skipped=True, diff --git a/lib/ansible/runner/filter_plugins/core.py b/lib/ansible/runner/filter_plugins/core.py index 966d3876d85..b82120ec8d9 100644 --- a/lib/ansible/runner/filter_plugins/core.py +++ b/lib/ansible/runner/filter_plugins/core.py @@ -15,21 +15,24 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +import sys import base64 import json import os.path -import yaml import types import pipes import glob import re import collections import operator as py_operator -from ansible import errors -from ansible.utils import md5s, checksum_s -from distutils.version import LooseVersion, StrictVersion from random import SystemRandom, shuffle + +import yaml from jinja2.filters import environmentfilter +from distutils.version import LooseVersion, StrictVersion + +from ansible import errors +from ansible.utils import md5s, checksum_s def to_nice_yaml(*a, **kw): @@ -42,6 +45,22 @@ def to_json(a, *args, **kw): def to_nice_json(a, *args, **kw): '''Make verbose, human readable JSON''' + # python-2.6's json encoder is buggy (can't encode hostvars) + if sys.version_info < (2, 7): + try: + import simplejson + except ImportError: + pass + else: + try: + major = int(simplejson.__version__.split('.')[0]) + except: + pass + else: + if major >= 2: + return simplejson.dumps(a, indent=4, sort_keys=True, *args, **kw) + # Fallback to the to_json filter + return to_json(a, *args, **kw) return json.dumps(a, indent=4, sort_keys=True, *args, **kw) def failed(*a, **kw):