From 16def8050a38510fe3e477a943a90a47a1bf3c8a Mon Sep 17 00:00:00 2001 From: Jaromaz Date: Wed, 5 Jan 2022 05:27:29 +0100 Subject: [PATCH] facts - Set correct OS family for EuroLinux (#76624) Co-authored-by: Abhijeet Kasurde --- changelogs/fragments/support_eurolinux.yml | 2 + .../module_utils/facts/system/distribution.py | 3 +- lib/ansible/modules/hostname.py | 6 +++ .../distribution/fixtures/eurolinux_8.5.json | 46 +++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/support_eurolinux.yml create mode 100644 test/units/module_utils/facts/system/distribution/fixtures/eurolinux_8.5.json diff --git a/changelogs/fragments/support_eurolinux.yml b/changelogs/fragments/support_eurolinux.yml new file mode 100644 index 00000000000..325b70bc81c --- /dev/null +++ b/changelogs/fragments/support_eurolinux.yml @@ -0,0 +1,2 @@ +bugfixes: + - distribution - add EuroLinux to fact gathering (https://github.com/ansible/ansible/pull/76624). diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py index df20a56967c..c829fc2901f 100644 --- a/lib/ansible/module_utils/facts/system/distribution.py +++ b/lib/ansible/module_utils/facts/system/distribution.py @@ -484,7 +484,8 @@ class Distribution(object): OS_FAMILY_MAP = {'RedHat': ['RedHat', 'Fedora', 'CentOS', 'Scientific', 'SLC', 'Ascendos', 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS', 'OEL', 'Amazon', 'Virtuozzo', 'XenServer', 'Alibaba', - 'EulerOS', 'openEuler', 'AlmaLinux', 'Rocky', 'TencentOS'], + 'EulerOS', 'openEuler', 'AlmaLinux', 'Rocky', 'TencentOS', + 'EuroLinux'], 'Debian': ['Debian', 'Ubuntu', 'Raspbian', 'Neon', 'KDE neon', 'Linux Mint', 'SteamOS', 'Devuan', 'Kali', 'Cumulus Linux', 'Pop!_OS', 'Parrot', 'Pardus GNU/Linux'], diff --git a/lib/ansible/modules/hostname.py b/lib/ansible/modules/hostname.py index 7ccc7a81cfa..3efee724b8d 100644 --- a/lib/ansible/modules/hostname.py +++ b/lib/ansible/modules/hostname.py @@ -946,6 +946,12 @@ class RedosHostname(Hostname): strategy_class = SystemdStrategy +class EurolinuxHostname(Hostname): + platform = 'Linux' + distribution = 'Eurolinux' + strategy_class = RedHatStrategy + + def main(): module = AnsibleModule( argument_spec=dict( diff --git a/test/units/module_utils/facts/system/distribution/fixtures/eurolinux_8.5.json b/test/units/module_utils/facts/system/distribution/fixtures/eurolinux_8.5.json new file mode 100644 index 00000000000..add1b731ddd --- /dev/null +++ b/test/units/module_utils/facts/system/distribution/fixtures/eurolinux_8.5.json @@ -0,0 +1,46 @@ +{ + "name": "EuroLinux 8.5", + "distro": { + "codename": "Tirana", + "id": "eurolinux", + "name": "EuroLinux", + "version": "8.5", + "version_best": "8.5", + "lsb_release_info": {}, + "os_release_info": { + "name": "EuroLinux", + "version": "8.5 (Tirana)", + "id": "eurolinux", + "id_like": "rhel fedora centos", + "version_id": "8.5", + "platform_id": "platform:el8", + "pretty_name": "EuroLinux 8.5 (Tirana)", + "ansi_color": "0;34", + "cpe_name": "cpe:/o:eurolinux:eurolinux:8", + "home_url": "https://www.euro-linux.com/", + "bug_report_url": "https://github.com/EuroLinux/eurolinux-distro-bugs-and-rfc/", + "redhat_support_product": "EuroLinux", + "redhat_support_product_version": "8", + "codename": "Tirana" + } + }, + "input": { + "/etc/redhat-release": "EuroLinux release 8.5 (Tirana) \n", + "/etc/system-release": "EuroLinux release 8.5 (Tirana) \n", + "/etc/os-release": "NAME=\"EuroLinux\"\nVERSION=\"8.5 (Tirana)\"\nID=\"eurolinux\"\nID_LIKE=\"rhel fedora centos\"\nVERSION_ID=\"8.5\"\nPLATFORM_ID=\"platform:el8\"\nPRETTY_NAME=\"EuroLinux 8.5 (Tirana)\"\nANSI_COLOR=\"0;34\"\nCPE_NAME=\"cpe:/o:eurolinux:eurolinux:8\"\nHOME_URL=\"https://www.euro-linux.com/\"\nBUG_REPORT_URL=\"https://github.com/EuroLinux/eurolinux-distro-bugs-and-rfc/\"\nREDHAT_SUPPORT_PRODUCT=\"EuroLinux\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"8\"\n", + "/usr/lib/os-release": "NAME=\"EuroLinux\"\nVERSION=\"8.5 (Tirana)\"\nID=\"eurolinux\"\nID_LIKE=\"rhel fedora centos\"\nVERSION_ID=\"8.5\"\nPLATFORM_ID=\"platform:el8\"\nPRETTY_NAME=\"EuroLinux 8.5 (Tirana)\"\nANSI_COLOR=\"0;34\"\nCPE_NAME=\"cpe:/o:eurolinux:eurolinux:8\"\nHOME_URL=\"https://www.euro-linux.com/\"\nBUG_REPORT_URL=\"https://github.com/EuroLinux/eurolinux-distro-bugs-and-rfc/\"\nREDHAT_SUPPORT_PRODUCT=\"EuroLinux\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"8\"\n" + }, + "platform.dist": [ + "eurolinux", + "8.5", + "Tirana" + ], + "result": { + "distribution": "EuroLinux", + "distribution_version": "8.5", + "distribution_release": "Tirana", + "distribution_major_version": "8", + "os_family": "RedHat" + }, + "platform.release": "4.18.0-348.2.1.el8_5.x86_64" +}