diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index d8deaf9a60..79174d2df4 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -427,7 +427,7 @@ class Facts(object): self.facts['selinux']['status'] = 'enabled' try: self.facts['selinux']['policyvers'] = selinux.security_policyvers() - except OSError: + except (AttributeError,OSError): self.facts['selinux']['policyvers'] = 'unknown' try: (rc, configmode) = selinux.selinux_getenforcemode() @@ -435,12 +435,12 @@ class Facts(object): self.facts['selinux']['config_mode'] = Facts.SELINUX_MODE_DICT.get(configmode, 'unknown') else: self.facts['selinux']['config_mode'] = 'unknown' - except OSError: + except (AttributeError,OSError): self.facts['selinux']['config_mode'] = 'unknown' try: mode = selinux.security_getenforce() self.facts['selinux']['mode'] = Facts.SELINUX_MODE_DICT.get(mode, 'unknown') - except OSError: + except (AttributeError,OSError): self.facts['selinux']['mode'] = 'unknown' try: (rc, policytype) = selinux.selinux_getpolicytype() @@ -448,7 +448,7 @@ class Facts(object): self.facts['selinux']['type'] = policytype else: self.facts['selinux']['type'] = 'unknown' - except OSError: + except (AttributeError,OSError): self.facts['selinux']['type'] = 'unknown' def get_caps_facts(self):