diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 6b817d4ebcc..a9f1b17e5bd 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -99,7 +99,8 @@ class Facts(object): ('/etc/os-release', 'SuSE'), ('/etc/gentoo-release', 'Gentoo'), ('/etc/os-release', 'Debian'), - ('/etc/lsb-release', 'Mandriva') ) + ('/etc/lsb-release', 'Mandriva'), + ('/etc/os-release', 'NA') ) SELINUX_MODE_DICT = { 1: 'enforcing', 0: 'permissive', -1: 'disabled' } # A list of dicts. If there is a platform with more than one @@ -427,6 +428,20 @@ class Facts(object): self.facts['distribution_release'] = release.groups()[0] self.facts['distribution'] = name break + elif name == 'NA': + data = get_file_content(path) + for line in data.splitlines(): + distribution = re.search("^NAME=(.*)", line) + if distribution: + self.facts['distribution'] = distribution.group(1).strip('"') + version = re.search("^VERSION=(.*)", line) + if version: + self.facts['distribution_version'] = version.group(1).strip('"') + if self.facts['distribution'].lower() == 'coreos': + data = get_file_content('/etc/coreos/update.conf') + release = re.search("^GROUP=(.*)", data) + if release: + self.facts['distribution_release'] = release.group(1).strip('"') else: self.facts['distribution'] = name machine_id = get_file_content("/var/lib/dbus/machine-id") or get_file_content("/etc/machine-id") diff --git a/v2/ansible/module_utils/facts.py b/v2/ansible/module_utils/facts.py index ae1a3094b60..5844c4f6787 100644 --- a/v2/ansible/module_utils/facts.py +++ b/v2/ansible/module_utils/facts.py @@ -98,7 +98,8 @@ class Facts(object): ('/etc/os-release', 'SuSE'), ('/etc/gentoo-release', 'Gentoo'), ('/etc/os-release', 'Debian'), - ('/etc/lsb-release', 'Mandriva') ) + ('/etc/lsb-release', 'Mandriva'), + ('/etc/os-release', 'NA') ) SELINUX_MODE_DICT = { 1: 'enforcing', 0: 'permissive', -1: 'disabled' } # A list of dicts. If there is a platform with more than one @@ -386,6 +387,20 @@ class Facts(object): self.facts['distribution_release'] = release.groups()[0] self.facts['distribution'] = name break + elif name == 'NA': + data = get_file_content(path) + for line in data.splitlines(): + distribution = re.search("^NAME=(.*)", line) + if distribution: + self.facts['distribution'] = distribution.group(1).strip('"') + version = re.search("^VERSION=(.*)", line) + if version: + self.facts['distribution_version'] = version.group(1).strip('"') + if self.facts['distribution'].lower() == 'coreos': + data = get_file_content('/etc/coreos/update.conf') + release = re.search("^GROUP=(.*)", data) + if release: + self.facts['distribution_release'] = release.group(1).strip('"') else: self.facts['distribution'] = name