summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRene Moser <mail@renemoser.net>2015-05-27 20:54:26 +0200
committerRene Moser <mail@renemoser.net>2015-05-27 20:54:26 +0200
commit141dda9978a197801a503347c8bd611cb368dda8 (patch)
tree9917b71adba84764fca35d38d1fbcb27414ed165
parentb2e4f31bebfec49380659b9d65b5828f1c1ed8d9 (diff)
downloadansible-modules-extras-141dda9978a197801a503347c8bd611cb368dda8.tar.gz
firewalld: remove BabyJSON
See https://github.com/ansible/ansible-modules-extras/issues/430
-rw-r--r--system/firewalld.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/system/firewalld.py b/system/firewalld.py
index 77cfc4b6..e16e4e4a 100644
--- a/system/firewalld.py
+++ b/system/firewalld.py
@@ -67,8 +67,8 @@ options:
required: false
default: 0
notes:
- - Not tested on any debian based system.
-requirements: [ firewalld >= 0.2.11 ]
+ - Not tested on any Debian based system.
+requirements: [ 'firewalld >= 0.2.11' ]
author: '"Adam Miller (@maxamillion)" <maxamillion@fedoraproject.org>'
'''
@@ -82,7 +82,6 @@ EXAMPLES = '''
import os
import re
-import sys
try:
import firewall.config
@@ -90,14 +89,9 @@ try:
from firewall.client import FirewallClient
fw = FirewallClient()
- if not fw.connected:
- raise Exception('failed to connect to the firewalld daemon')
+ HAS_FIREWALLD = True
except ImportError:
- print "failed=True msg='firewalld required for this module'"
- sys.exit(1)
-except Exception, e:
- print "failed=True msg='%s'" % str(e)
- sys.exit(1)
+ HAS_FIREWALLD = False
################
# port handling
@@ -223,6 +217,9 @@ def main():
supports_check_mode=True
)
+ if not HAS_FIREWALLD:
+ module.fail_json(msg='firewalld required for this module')
+
## Pre-run version checking
if FW_VERSION < "0.2.11":
module.fail_json(msg='unsupported version of firewalld, requires >= 2.0.11')
@@ -400,6 +397,4 @@ def main():
#################################################
# import module snippets
from ansible.module_utils.basic import *
-
main()
-