From e68541fa886bd209c5d57612df3349370e9de132 Mon Sep 17 00:00:00 2001 From: Josue David Hernandez Date: Wed, 9 Jan 2019 16:32:06 -0600 Subject: [PATCH] =?UTF-8?q?set=20ansible=5Fos=5Ffamily=20from=20name=20var?= =?UTF-8?q?iable=20in=20os-release=20for=20clearlinux=E2=80=A6=20(#49906)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * set ansible_os_family from name variable in os-release for clearlinux OS (#49639) * set ansible_os_family from name variable in os-release for clearlinux system Signed-off-by: Josue David Hernandez Gutierrez * Add os_family for clear linux and clear linux mixes Signed-off-by: Josue David Hernandez Gutierrez (cherry picked from commit 9202ef60b02053e5b5e6224cc4b5fc9c4c8786b0) * Adding Changelog fragment Signed-off-by: Josue David Hernandez Gutierrez --- .../fragments/os-family_distro_variable_clearlinux.yaml | 2 ++ lib/ansible/module_utils/facts/system/distribution.py | 6 +++++- test/units/module_utils/test_distribution_version.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/os-family_distro_variable_clearlinux.yaml diff --git a/changelogs/fragments/os-family_distro_variable_clearlinux.yaml b/changelogs/fragments/os-family_distro_variable_clearlinux.yaml new file mode 100644 index 0000000000..f773e26831 --- /dev/null +++ b/changelogs/fragments/os-family_distro_variable_clearlinux.yaml @@ -0,0 +1,2 @@ +minor_changes: +- set ansible_os_family from name variable in os-release diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py index 556b0a0ecc..a0dbf0d366 100644 --- a/lib/ansible/module_utils/facts/system/distribution.py +++ b/lib/ansible/module_utils/facts/system/distribution.py @@ -386,6 +386,9 @@ class DistributionFiles: release = re.search('ID=(.*)', data) if release: clear_facts['distribution_release'] = release.groups()[0] + pname = re.search('NAME="(.*)"', data) + if pname: + clear_facts['distribution'] = pname.groups()[0] return True, clear_facts @@ -450,7 +453,8 @@ class Distribution(object): 'AIX': ['AIX'], 'HP-UX': ['HPUX'], 'Darwin': ['MacOSX'], - 'FreeBSD': ['FreeBSD', 'TrueOS']} + 'FreeBSD': ['FreeBSD', 'TrueOS'], + 'ClearLinux': ['Clear Linux OS', 'Clear Linux Mix']} OS_FAMILY = {} for family, names in OS_FAMILY_MAP.items(): diff --git a/test/units/module_utils/test_distribution_version.py b/test/units/module_utils/test_distribution_version.py index 38ccf8d941..f475cb5bcc 100644 --- a/test/units/module_utils/test_distribution_version.py +++ b/test/units/module_utils/test_distribution_version.py @@ -949,7 +949,7 @@ PRIVACY_POLICY_URL="http://www.intel.com/privacy" "name": "ClearLinux 26580", "result": { "distribution_release": "clear-linux-os", - "distribution": "ClearLinux", + "distribution": "Clear Linux OS", "distribution_major_version": "26580", "os_family": "ClearLinux", "distribution_version": "26580"