From 4cbbb738e63215cd69ba93993733eb7e02891dea Mon Sep 17 00:00:00 2001 From: James Livulpi Date: Fri, 3 Dec 2021 16:02:31 -0500 Subject: [PATCH 1/3] add tencentos fact distro --- changelogs/fragments/76343-tencentos-dnf.yml | 2 ++ lib/ansible/module_utils/facts/system/distribution.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/76343-tencentos-dnf.yml diff --git a/changelogs/fragments/76343-tencentos-dnf.yml b/changelogs/fragments/76343-tencentos-dnf.yml new file mode 100644 index 00000000000000..1bf8f310b1cd92 --- /dev/null +++ b/changelogs/fragments/76343-tencentos-dnf.yml @@ -0,0 +1,2 @@ +bugfixes: +- distribution - detect tencentos and gather correct fact on distro diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py index 604e9d96ad7598..03ed83ee6398a7 100644 --- a/lib/ansible/module_utils/facts/system/distribution.py +++ b/lib/ansible/module_utils/facts/system/distribution.py @@ -464,6 +464,10 @@ def parse_distribution_file_CentOS(self, name, data, path, collected_facts): centos_facts['distribution_release'] = 'Stream' return True, centos_facts + if "TencentOS Server" in data: + centos_facts['distribution'] = 'TencentOS' + return True, centos_facts + return False, centos_facts From 372edec832cf640fe9b0cd37f49a430c078b7d9d Mon Sep 17 00:00:00 2001 From: James Livulpi Date: Sun, 5 Dec 2021 22:30:05 -0500 Subject: [PATCH 2/3] Update changelogs/fragments/76343-tencentos-dnf.yml Co-authored-by: Abhijeet Kasurde --- changelogs/fragments/76343-tencentos-dnf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/76343-tencentos-dnf.yml b/changelogs/fragments/76343-tencentos-dnf.yml index 1bf8f310b1cd92..3f957d738a5cee 100644 --- a/changelogs/fragments/76343-tencentos-dnf.yml +++ b/changelogs/fragments/76343-tencentos-dnf.yml @@ -1,2 +1,2 @@ bugfixes: -- distribution - detect tencentos and gather correct fact on distro +- distribution - detect tencentos and gather correct facts on the distro. From 9ab6fb0a78c51269d2df7714f796670dc7731c8c Mon Sep 17 00:00:00 2001 From: James Livulpi Date: Mon, 6 Dec 2021 08:50:30 -0500 Subject: [PATCH 3/3] add mock test and add tencentos to RedHat OS_FAMILY_MAP --- .../module_utils/facts/system/distribution.py | 2 +- .../distribution/fixtures/tencentos_3_1.json | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 test/units/module_utils/facts/system/distribution/fixtures/tencentos_3_1.json diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py index 03ed83ee6398a7..df20a56967cdfc 100644 --- a/lib/ansible/module_utils/facts/system/distribution.py +++ b/lib/ansible/module_utils/facts/system/distribution.py @@ -484,7 +484,7 @@ 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'], + 'EulerOS', 'openEuler', 'AlmaLinux', 'Rocky', 'TencentOS'], 'Debian': ['Debian', 'Ubuntu', 'Raspbian', 'Neon', 'KDE neon', 'Linux Mint', 'SteamOS', 'Devuan', 'Kali', 'Cumulus Linux', 'Pop!_OS', 'Parrot', 'Pardus GNU/Linux'], diff --git a/test/units/module_utils/facts/system/distribution/fixtures/tencentos_3_1.json b/test/units/module_utils/facts/system/distribution/fixtures/tencentos_3_1.json new file mode 100644 index 00000000000000..f1051dd6a13c49 --- /dev/null +++ b/test/units/module_utils/facts/system/distribution/fixtures/tencentos_3_1.json @@ -0,0 +1,50 @@ +{ + "name": "TencentOS 3.1", + "distro": { + "codename": "Final", + "id": "tencentos", + "name": "TencentOS Server", + "version": "3.1", + "version_best": "3.1", + "lsb_release_info": {}, + "os_release_info": { + "name": "TencentOS Server", + "version": "3.1 (Final)", + "id": "tencentos", + "id_like": "rhel fedora centos", + "version_id": "3.1", + "platform_id": "platform:el8", + "pretty_name": "TencentOS Server 3.1 (Final)", + "ansi_color": "0;31", + "cpe_name": "cpe:/o:tencentos:tencentos:3", + "home_url": "https://tlinux.qq.com/", + "bug_report_url": "https://tlinux.qq.com/", + "centos_mantisbt_project": "CentOS-8", + "centos_mantisbt_project_version": "8", + "redhat_support_product": "centos", + "redhat_support_product_version": "8", + "name_orig": "CentOS Linux", + "codename": "Final" + } + }, + "input": { + "/etc/centos-release": "NAME=\"TencentOS Server\"\nVERSION=\"3.1 (Final)\"\nID=\"tencentos\"\nID_LIKE=\"rhel fedora centos\"\nVERSION_ID=\"3.1\"\nPLATFORM_ID=\"platform:el8\"\nPRETTY_NAME=\"TencentOS Server 3.1 (Final)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:tencentos:tencentos:3\"\nHOME_URL=\"https://tlinux.qq.com/\"\nBUG_REPORT_URL=\"https://tlinux.qq.com/\"\n\nCENTOS_MANTISBT_PROJECT=\"CentOS-8\"\nCENTOS_MANTISBT_PROJECT_VERSION=\"8\"\nREDHAT_SUPPORT_PRODUCT=\"centos\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"8\"\nNAME_ORIG=\"CentOS Linux\"\n", + "/etc/redhat-release": "CentOS Linux release 8.4.2105 (Core)\n", + "/etc/system-release": "NAME=\"TencentOS Server\"\nVERSION=\"3.1 (Final)\"\nID=\"tencentos\"\nID_LIKE=\"rhel fedora centos\"\nVERSION_ID=\"3.1\"\nPLATFORM_ID=\"platform:el8\"\nPRETTY_NAME=\"TencentOS Server 3.1 (Final)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:tencentos:tencentos:3\"\nHOME_URL=\"https://tlinux.qq.com/\"\nBUG_REPORT_URL=\"https://tlinux.qq.com/\"\n\nCENTOS_MANTISBT_PROJECT=\"CentOS-8\"\nCENTOS_MANTISBT_PROJECT_VERSION=\"8\"\nREDHAT_SUPPORT_PRODUCT=\"centos\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"8\"\nNAME_ORIG=\"CentOS Linux\"\n", + "/etc/os-release": "NAME=\"TencentOS Server\"\nVERSION=\"3.1 (Final)\"\nID=\"tencentos\"\nID_LIKE=\"rhel fedora centos\"\nVERSION_ID=\"3.1\"\nPLATFORM_ID=\"platform:el8\"\nPRETTY_NAME=\"TencentOS Server 3.1 (Final)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:tencentos:tencentos:3\"\nHOME_URL=\"https://tlinux.qq.com/\"\nBUG_REPORT_URL=\"https://tlinux.qq.com/\"\n\nCENTOS_MANTISBT_PROJECT=\"CentOS-8\"\nCENTOS_MANTISBT_PROJECT_VERSION=\"8\"\nREDHAT_SUPPORT_PRODUCT=\"centos\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"8\"\nNAME_ORIG=\"CentOS Linux\"\n", + "/usr/lib/os-release": "NAME=\"CentOS Linux\"\nVERSION=\"8\"\nID=\"centos\"\nID_LIKE=\"rhel fedora\"\nVERSION_ID=\"8\"\nPLATFORM_ID=\"platform:el8\"\nPRETTY_NAME=\"CentOS Linux 8\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:centos:centos:8\"\nHOME_URL=\"https://centos.org/\"\nBUG_REPORT_URL=\"https://bugs.centos.org/\"\nCENTOS_MANTISBT_PROJECT=\"CentOS-8\"\nCENTOS_MANTISBT_PROJECT_VERSION=\"8\"\n" + }, + "platform.dist": [ + "tencentos", + "3.1", + "Final" + ], + "result": { + "distribution": "TencentOS", + "distribution_version": "3.1", + "distribution_release": "Final", + "distribution_major_version": "3", + "os_family": "RedHat" + }, + "platform.release": "5.4.32-19-0001" +} \ No newline at end of file