From 5da7f2aff47fe47cf65143b3911314a38b6c7ff2 Mon Sep 17 00:00:00 2001 From: Wes Johnson Date: Mon, 14 May 2012 14:31:53 -0700 Subject: [PATCH] starting fresh, doing it 'right' Lost commit history, but this way I'm not introducing crappy commit history in RP --- library/setup | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/library/setup b/library/setup index 1cf06b3f2d3..6e6f0c3e761 100755 --- a/library/setup +++ b/library/setup @@ -267,8 +267,32 @@ def get_public_ssh_host_keys(facts): else: facts['ssh_host_key_rsa_public'] = rsa.split()[1] +def get_selinux_facts(facts): + if os.path.exists("/usr/sbin/sestatus"): + cmd = subprocess.Popen("/usr/sbin/sestatus", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = cmd.communicate() + if err == '': + facts['selinux'] = {} + list = out.split("\n") + status = re.search("(enabled|disabled)", list[0]) + if status.group() == "enabled": + mode = re.search("(enforcing|disabled|permissive)", list[2]) + config_mode = re.search("(enforcing|disabled|permissive)", list[3]) + policyvers = re.search("\d+", list[4]) + type = re.search("(targeted|strict|mls)", list[5]) + facts['selinux']['status'] = status.group() + facts['selinux']['mode'] = mode.group() + facts['selinux']['config_mode'] = config_mode.group() + facts['selinux']['policyvers'] = policyvers.group() + facts['selinux']['type'] = type.group() + elif status.group() == "disabled": + facts['selinux']['status'] = status.group() + else: + facts['selinux'] = False + def get_service_facts(facts): get_public_ssh_host_keys(facts) + get_selinux_facts(facts) def ansible_facts(): facts = {}