From 98cc29f9fd0f6c2a9c458e38cf7d8484e19f3910 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 18 Jul 2013 22:06:26 -0400 Subject: [PATCH] now returns fatal error if operation on selinux enabled target is attempted w/o selinux python bindings Signed-off-by: Brian Coca --- lib/ansible/module_common.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ansible/module_common.py b/lib/ansible/module_common.py index d61e2aa8d2..15de57c754 100644 --- a/lib/ansible/module_common.py +++ b/lib/ansible/module_common.py @@ -265,6 +265,11 @@ class AnsibleModule(object): def selinux_enabled(self): if not HAVE_SELINUX: + sestatus = get_bin_path('sestatus') + if sestatus is not None: + (rc,out,err) = run_command(sestatus) + if rc == 0 and re.search('enabled', out): + self.fail_json(msg="Aborting, target uses selinux but python bindings (python-selinux) aren't installed!") return False if selinux.is_selinux_enabled() == 1: return True