From 039d207d2471df56c55fb2b1097a56aaab18da0a Mon Sep 17 00:00:00 2001 From: Vlad Glagolev Date: Tue, 31 Jan 2017 13:25:36 -0500 Subject: [PATCH] Add Source Mage GNU/Linux facts (#19671) * Add Source Mage GNU/Linux facts * Add unit test for OS-detection --- lib/ansible/module_utils/facts.py | 8 +++++++- .../module_utils/test_distribution_version.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 85fb068317..ca5120a888 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -157,6 +157,7 @@ class Facts(object): { 'path' : '/usr/bin/xbps-install','name' : 'xbps' }, { 'path' : '/usr/local/sbin/pkg', 'name' : 'pkgng' }, { 'path' : '/usr/bin/swupd', 'name' : 'swupd' }, + { 'path' : '/usr/sbin/sorcery', 'name' : 'sorcery' }, ] def __init__(self, module, load_on_init=True, cached_facts=None): @@ -653,6 +654,7 @@ class Distribution(object): {'path': '/etc/os-release', 'name': 'Debian'}, {'path': '/etc/lsb-release', 'name': 'Mandriva'}, {'path': '/etc/altlinux-release', 'name': 'Altlinux'}, + {'path': '/etc/sourcemage-release', 'name': 'SMGL'}, {'path': '/etc/os-release', 'name': 'NA'}, {'path': '/etc/coreos/update.conf', 'name': 'Coreos'}, {'path': '/usr/lib/os-release', 'name': 'ClearLinux'}, @@ -663,6 +665,7 @@ class Distribution(object): 'RedHat': 'Red Hat', 'Altlinux': 'ALT Linux', 'ClearLinux': 'Clear Linux Software for Intel Architecture', + 'SMGL': 'Source Mage GNU/Linux', } # A list with OS Family members @@ -672,7 +675,7 @@ class Distribution(object): OracleLinux = 'RedHat', OVS = 'RedHat', OEL = 'RedHat', Amazon = 'RedHat', XenServer = 'RedHat', Ubuntu = 'Debian', Debian = 'Debian', Raspbian = 'Debian', Slackware = 'Slackware', SLES = 'Suse', SLED = 'Suse', openSUSE = 'Suse', openSUSE_Tumbleweed = 'Suse', SuSE = 'Suse', SLES_SAP = 'Suse', SUSE_LINUX = 'Suse', Gentoo = 'Gentoo', Funtoo = 'Gentoo', - Archlinux = 'Archlinux', Manjaro = 'Archlinux', Mandriva = 'Mandrake', Mandrake = 'Mandrake', Altlinux = 'Altlinux', + Archlinux = 'Archlinux', Manjaro = 'Archlinux', Mandriva = 'Mandrake', Mandrake = 'Mandrake', Altlinux = 'Altlinux', SMGL = 'SMGL', Solaris = 'Solaris', Nexenta = 'Solaris', OmniOS = 'Solaris', OpenIndiana = 'Solaris', SmartOS = 'Solaris', AIX = 'AIX', Alpine = 'Alpine', MacOSX = 'Darwin', FreeBSD = 'FreeBSD', HPUX = 'HP-UX', openSUSE_Leap = 'Suse', Neon = 'Debian' @@ -834,6 +837,9 @@ class Distribution(object): self.facts['distribution'] = 'Alpine' self.facts['distribution_version'] = data + def get_distribution_SMGL(self): + self.facts['distribution'] = 'Source Mage GNU/Linux' + def get_distribution_SunOS(self): data = get_file_content('/etc/release').splitlines()[0] if 'Solaris' in data: diff --git a/test/units/module_utils/test_distribution_version.py b/test/units/module_utils/test_distribution_version.py index 52ca71ccc3..388c1d5ca3 100644 --- a/test/units/module_utils/test_distribution_version.py +++ b/test/units/module_utils/test_distribution_version.py @@ -683,6 +683,24 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" } }, + { + "platform.dist": [ + "", + "", + "" + ], + "input": { + "/etc/sourcemage-release": "Source Mage GNU/Linux x86_64-pc-linux-gnu\nInstalled from tarball using chroot image (Grimoire 0.61-rc) on Thu May 17 17:31:37 UTC 2012\n" + }, + "name": "SMGL NA", + "result": { + "distribution_release": "NA", + "distribution": "SMGL", + "distribution_major_version": "NA", + "os_family": "SMGL", + "distribution_version": "NA" + } + }, ]