From 46c913f7a6a05752d16b5e655ef9c1043444d542 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 1 Mar 2013 19:03:59 -0500 Subject: [PATCH] now ansible shows nice message about missing json instead of traceback Signed-off-by: Brian Coca --- lib/ansible/module_common.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ansible/module_common.py b/lib/ansible/module_common.py index 635c87925f..0d425078f1 100644 --- a/lib/ansible/module_common.py +++ b/lib/ansible/module_common.py @@ -51,11 +51,6 @@ BOOLEANS = BOOLEANS_TRUE + BOOLEANS_FALSE # of an ansible module. The source of this common code lives # in lib/ansible/module_common.py -try: - import json -except ImportError: - import simplejson as json -import base64 import os import re import shlex @@ -72,6 +67,15 @@ import pwd import platform import errno +try: + import json +except ImportError: + try: + import simplejson as json + except ImportError: + sys.stderr.write('Error: ansible requires a json module, none found!') + sys.exit(1) + HAVE_SELINUX=False try: import selinux