From ab6a9ef1309d6bef8fb9b145b0d87fda570b1bcc Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 28 Jun 2019 19:21:35 -0400 Subject: [PATCH] Get minor version number for CentOS and Debian (#57814) * Get the most detailed version number from distro.version() for CentOS and Debian * Update tests and fixtures * Update fixture generation script to gather distro info and work with Python 3 * Update LinuxMint fixtures * Cleanup fixture formatting * Improvements based on feedback from abadger: - use unicode since that is what distro returns - use frozenset with a tuple - include link Debian to bug --- .../gen_distribution_version_testcase.py | 11 +- lib/ansible/module_utils/common/sys_info.py | 27 + .../module_utils/test_distribution_version.py | 781 +++++++++++------- 3 files changed, 514 insertions(+), 305 deletions(-) diff --git a/hacking/tests/gen_distribution_version_testcase.py b/hacking/tests/gen_distribution_version_testcase.py index 6d09c77af06..e2a1cde02eb 100755 --- a/hacking/tests/gen_distribution_version_testcase.py +++ b/hacking/tests/gen_distribution_version_testcase.py @@ -16,6 +16,7 @@ import json import sys from ansible.module_utils import distro +from ansible.module_utils._text import to_text filelist = [ @@ -53,13 +54,14 @@ dist = distro.linux_distribution(full_distribution_name=False) facts = ['distribution', 'distribution_version', 'distribution_release', 'distribution_major_version', 'os_family'] try: - ansible_out = subprocess.check_output( + b_ansible_out = subprocess.check_output( ['ansible', 'localhost', '-m', 'setup']) except subprocess.CalledProcessError as e: print("ERROR: ansible run failed, output was: \n") print(e.output) sys.exit(e.returncode) +ansible_out = to_text(b_ansible_out) parsed = json.loads(ansible_out[ansible_out.index('{'):]) ansible_facts = {} for fact in facts: @@ -72,6 +74,13 @@ nicename = ansible_facts['distribution'] + ' ' + ansible_facts['distribution_ver output = { 'name': nicename, + 'distro': { + 'codename': distro.codename(), + 'id': distro.id(), + 'name': distro.name(), + 'version': distro.version(), + 'version_best': distro.version(best=True), + }, 'input': fcont, 'platform.dist': dist, 'result': ansible_facts, diff --git a/lib/ansible/module_utils/common/sys_info.py b/lib/ansible/module_utils/common/sys_info.py index d762410a7f6..20476386192 100644 --- a/lib/ansible/module_utils/common/sys_info.py +++ b/lib/ansible/module_utils/common/sys_info.py @@ -50,8 +50,35 @@ def get_distribution_version(): the version, it returns empty string. If this is not run on a Linux machine it returns None ''' version = None + + needs_best_version = frozenset(( + u'centos', + u'debian', + )) + if platform.system() == 'Linux': version = distro.version() + distro_id = distro.id() + + if version is not None: + if distro_id in needs_best_version: + version_best = distro.version(best=True) + + # CentoOS maintainers believe only the major version is appropriate + # but Ansible users desire minor version information, e.g., 7.5. + # https://github.com/ansible/ansible/issues/50141#issuecomment-449452781 + if distro_id == u'centos': + version = u'.'.join(version_best.split(u'.')[:2]) + + # Debian does not include minor version in /etc/os-release. + # Bug report filed upstream requesting this be added to /etc/os-release + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931197 + if distro_id == u'debian': + version = version_best + + else: + version = u'' + return version diff --git a/test/units/module_utils/test_distribution_version.py b/test/units/module_utils/test_distribution_version.py index 2fe548b8e1d..68d27c27013 100644 --- a/test/units/module_utils/test_distribution_version.py +++ b/test/units/module_utils/test_distribution_version.py @@ -7,7 +7,6 @@ __metaclass__ = type from itertools import product -import mock import pytest from ansible.module_utils.six.moves import builtins @@ -24,6 +23,13 @@ TESTSETS = [ "7.2.1511", "Core" ], + 'distro': { + 'codename': 'Core', + 'id': 'centos', + 'name': 'CentOS Linux', + 'version': '7', + 'version_best': '7.2.1511', + }, "input": { "/etc/redhat-release": "CentOS Linux release 7.2.1511 (Core) \n", "/etc/os-release": ( @@ -40,7 +46,7 @@ TESTSETS = [ "distribution": "CentOS", "distribution_major_version": "7", "os_family": "RedHat", - "distribution_version": "7.2.1511", + "distribution_version": "7.2", } }, { @@ -50,6 +56,13 @@ TESTSETS = [ "6.7", "Final" ], + 'distro': { + 'codename': 'Final', + 'id': 'centos', + 'name': 'CentOS Linux', + 'version': '6.7', + 'version_best': '6.7', + }, "input": { "/etc/redhat-release": "CentOS release 6.7 (Final)\n", "/etc/lsb-release": ( @@ -73,6 +86,13 @@ TESTSETS = [ "7.2", "Maipo" ], + 'distro': { + 'codename': 'Maipo', + 'id': 'rhel', + 'name': 'RedHat Enterprise Linux', + 'version': '7.2', + 'version_best': '7.2', + }, "input": { "/etc/redhat-release": "Red Hat Enterprise Linux Server release 7.2 (Maipo)\n", "/etc/os-release": ( @@ -100,6 +120,13 @@ TESTSETS = [ "6.7", "Santiago" ], + 'distro': { + 'codename': 'Santiago', + 'id': 'rhel', + 'name': 'RedHat Enterprise Linux', + 'version': '6.7', + 'version_best': '6.7', + }, "input": { "/etc/redhat-release": "Red Hat Enterprise Linux Server release 6.7 (Santiago)\n", "/etc/lsb-release": ( @@ -123,6 +150,13 @@ TESTSETS = [ "7.3", "" ], + 'distro': { + 'codename': '', + 'id': 'virtuozzo', + 'name': 'Virtuozzo Linux', + 'version': '7.3', + 'version_best': '7.3', + }, "input": { "/etc/redhat-release": "Virtuozzo Linux release 7.3\n", "/etc/os-release": ( @@ -150,26 +184,22 @@ TESTSETS = [ { "name": "openSUSE Leap 42.1", "input": { - "/etc/os-release": """ -NAME="openSUSE Leap" -VERSION="42.1" -VERSION_ID="42.1" -PRETTY_NAME="openSUSE Leap 42.1 (x86_64)" -ID=opensuse -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:opensuse:opensuse:42.1" -BUG_REPORT_URL="https://bugs.opensuse.org" -HOME_URL="https://opensuse.org/" -ID_LIKE="suse" -""", - "/etc/SuSE-release": """ -openSUSE 42.1 (x86_64) -VERSION = 42.1 -CODENAME = Malachite -# /etc/SuSE-release is deprecated and will be removed in the future, use /etc/os-release instead -""" + "/etc/os-release": ( + 'NAME="openSUSE Leap"\nVERSION="42.1"\nVERSION_ID="42.1"\nPRETTY_NAME="openSUSE Leap 42.1 (x86_64)"\nID=opensuse\n' + 'ANSI_COLOR="0;32"\nCPE_NAME="cpe:/o:opensuse:opensuse:42.1"\nBUG_REPORT_URL="https://bugs.opensuse.org"\n' + 'HOME_URL="https://opensuse.org/"\nID_LIKE="suse"'), + "/etc/SuSE-release": ( + 'openSUSE 42.1 (x86_64)\nVERSION = 42.1\nCODENAME = Malachite\n# /etc/SuSE-release is deprecated and will be removed in the future, ' + 'use /etc/os-release instead'), }, "platform.dist": ['SuSE', '42.1', 'x86_64'], + 'distro': { + 'codename': '', + 'id': 'opensuse-leap', + 'name': 'openSUSE Leap', + 'version': '42.1', + 'version_best': '42.1', + }, "result": { "distribution": "openSUSE Leap", "distribution_major_version": "42", @@ -181,24 +211,22 @@ CODENAME = Malachite { 'name': 'openSUSE 13.2', 'input': { - '/etc/SuSE-release': """openSUSE 13.2 (x86_64) -VERSION = 13.2 -CODENAME = Harlequin -# /etc/SuSE-release is deprecated and will be removed in the future, use /etc/os-release instead -""", - '/etc/os-release': """NAME=openSUSE -VERSION="13.2 (Harlequin)" -VERSION_ID="13.2" -PRETTY_NAME="openSUSE 13.2 (Harlequin) (x86_64)" -ID=opensuse -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:opensuse:opensuse:13.2" -BUG_REPORT_URL="https://bugs.opensuse.org" -HOME_URL="https://opensuse.org/" -ID_LIKE="suse" -""" + '/etc/SuSE-release': ( + 'openSUSE 13.2 (x86_64)\nVERSION = 13.2\nCODENAME = Harlequin\n' + '# /etc/SuSE-release is deprecated and will be removed in the future, use /etc/os-release instead'), + '/etc/os-release': ( + 'NAME=openSUSE\nVERSION="13.2 (Harlequin)"\nVERSION_ID="13.2"\nPRETTY_NAME="openSUSE 13.2 (Harlequin) (x86_64)"\nID=opensuse\n' + 'ANSI_COLOR="0;32"\nCPE_NAME="cpe:/o:opensuse:opensuse:13.2"\nBUG_REPORT_URL="https://bugs.opensuse.org"\n' + 'HOME_URL="https://opensuse.org/"\nID_LIKE="suse"'), }, 'platform.dist': ('SuSE', '13.2', 'x86_64'), + 'distro': { + 'codename': '', + 'id': 'opensuse-harlequin', + 'name': 'openSUSE Harlequin', + 'version': '13.2', + 'version_best': '13.2', + }, 'result': { 'distribution': u'openSUSE', 'distribution_major_version': u'13', @@ -213,6 +241,13 @@ ID_LIKE="suse" "", "" ], + 'distro': { + 'codename': '', + 'id': 'opensuse-tumbleweed', + 'name': 'openSUSE Tumbleweed', + 'version': '20160917', + 'version_best': '20160917', + }, "input": { "/etc/os-release": ( "NAME=\"openSUSE Tumbleweed\"\n# VERSION=\"20160917\"\nID=opensuse\nID_LIKE=\"suse\"\nVERSION_ID=\"20160917\"\n" @@ -235,6 +270,13 @@ ID_LIKE="suse" "", "" ], + 'distro': { + 'codename': '', + 'id': 'opensuse-leap', + 'name': 'openSUSE Leap', + 'version': '15.0', + 'version_best': '15.0', + }, "input": { "/etc/os-release": ( "NAME=\"openSUSE Leap\"\n# VERSION=\"15.0\"\nID=opensuse-leap\nID_LIKE=\"suse opensuse\"\nVERSION_ID=\"15.0\"\n" @@ -254,13 +296,16 @@ ID_LIKE="suse" { # see https://github.com/ansible/ansible/issues/14837 "name": "SLES 11.3", "input": { - "/etc/SuSE-release": """ -SUSE Linux Enterprise Server 11 (x86_64) -VERSION = 11 -PATCHLEVEL = 3 -""" + "/etc/SuSE-release": "SUSE Linux Enterprise Server 11 (x86_64)\nVERSION = 11\nPATCHLEVEL = 3" }, "platform.dist": ['SuSE', '11', 'x86_64'], + 'distro': { + 'codename': '', + 'id': 'sles', + 'name': 'SUSE Linux Enterprise Server', + 'version': '11', + 'version_best': '11', + }, "result": { "distribution": "SLES", "distribution_major_version": "11", @@ -272,23 +317,20 @@ PATCHLEVEL = 3 { # see https://github.com/ansible/ansible/issues/14837 "name": "SLES 11.4", "input": { - "/etc/SuSE-release": """ -SUSE Linux Enterprise Server 11 (x86_64) -VERSION = 11 -PATCHLEVEL = 4 -""", - "/etc/os-release": """ -NAME="SLES" -VERSION="11.4" -VERSION_ID="11.4" -PRETTY_NAME="SUSE Linux Enterprise Server 11 SP4" -ID="sles" -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:suse:sles:11:4" -""", + "/etc/SuSE-release": "\nSUSE Linux Enterprise Server 11 (x86_64)\nVERSION = 11\nPATCHLEVEL = 4", + "/etc/os-release": ( + 'NAME="SLES"\nVERSION="11.4"\nVERSION_ID="11.4"\nPRETTY_NAME="SUSE Linux Enterprise Server 11 SP4"\nID="sles"\n' + 'ANSI_COLOR="0;32"\nCPE_NAME="cpe:/o:suse:sles:11:4"'), }, "platform.dist": ['SuSE', '11', 'x86_64'], - "result":{ + 'distro': { + 'codename': '', + 'id': 'sles', + 'name': 'SUSE Linux Enterprise Server', + 'version': '11.4', + 'version_best': '11.4', + }, + "result": { "distribution": "SLES", "distribution_major_version": "11", "distribution_release": "4", @@ -299,24 +341,22 @@ CPE_NAME="cpe:/o:suse:sles:11:4" { # see https://github.com/ansible/ansible/issues/14837 "name": "SLES 12 SP0", "input": { - "/etc/SuSE-release": """ -SUSE Linux Enterprise Server 12 (x86_64) -VERSION = 12 -PATCHLEVEL = 0 -# This file is deprecated and will be removed in a future service pack or release. -# Please check /etc/os-release for details about this release. -""", - "/etc/os-release": """ -NAME="SLES" -VERSION="12" -VERSION_ID="12" -PRETTY_NAME="SUSE Linux Enterprise Server 12" -ID="sles" -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:suse:sles:12" -""", + "/etc/SuSE-release": ( + '\nSUSE Linux Enterprise Server 12 (x86_64)\nVERSION = 12\nPATCHLEVEL = 0\n' + '# This file is deprecated and will be removed in a future service pack or release.\n' + '# Please check /etc/os-release for details about this release.'), + "/etc/os-release": ( + 'NAME="SLES"\nVERSION="12"\nVERSION_ID="12"\nPRETTY_NAME="SUSE Linux Enterprise Server 12"\nID="sles"\n' + 'ANSI_COLOR="0;32"\nCPE_NAME="cpe:/o:suse:sles:12"'), }, "platform.dist": ['SuSE', '12', 'x86_64'], + 'distro': { + 'codename': '', + 'id': 'sles', + 'name': 'SUSE Linux Enterprise Server', + 'version': '12', + 'version_best': '12', + }, "result": { "distribution": "SLES", "distribution_major_version": "12", @@ -328,25 +368,23 @@ CPE_NAME="cpe:/o:suse:sles:12" { # see https://github.com/ansible/ansible/issues/14837 "name": "SLES 12 SP1", "input": { - "/etc/SuSE-release": """ -SUSE Linux Enterprise Server 12 (x86_64) -VERSION = 12 -PATCHLEVEL = 0 -# This file is deprecated and will be removed in a future service pack or release. -# Please check /etc/os-release for details about this release. -""", - "/etc/os-release": """ -NAME="SLES" -VERSION="12-SP1" -VERSION_ID="12.1" -PRETTY_NAME="SUSE Linux Enterprise Server 12 SP1" -ID="sles" -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:suse:sles:12:sp1" - """, + "/etc/SuSE-release": ( + '\nSUSE Linux Enterprise Server 12 (x86_64)\nVERSION = 12\nPATCHLEVEL = 0\n' + '# This file is deprecated and will be removed in a future service pack or release.\n' + '# Please check /etc/os-release for details about this release.'), + "/etc/os-release": ( + 'NAME="SLES"\nVERSION="12-SP1"\nVERSION_ID="12.1"\nPRETTY_NAME="SUSE Linux Enterprise Server 12 SP1"\nID="sles"\n' + 'ANSI_COLOR="0;32"\nCPE_NAME="cpe:/o:suse:sles:12:sp1"'), }, "platform.dist": ['SuSE', '12', 'x86_64'], - "result":{ + 'distro': { + 'codename': '', + 'id': 'sles', + 'name': 'SUSE Linux Enterprise Server', + 'version': '12.1', + 'version_best': '12.1', + }, + "result": { "distribution": "SLES", "distribution_major_version": "12", "distribution_release": "1", @@ -357,25 +395,23 @@ CPE_NAME="cpe:/o:suse:sles:12:sp1" { "name": "SLES4SAP 12 SP2", "input": { - "/etc/SuSE-release": """ -SUSE Linux Enterprise Server 12 (x86_64) -VERSION = 12 -PATCHLEVEL = 2 -# This file is deprecated and will be removed in a future service pack or release. -# Please check /etc/os-release for details about this release. -""", - "/etc/os-release": """ -NAME="SLES_SAP" -VERSION="12-SP2" -VERSION_ID="12.2" -PRETTY_NAME="SUSE Linux Enterprise Server for SAP Applications 12 SP2" -ID="sles_sap" -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:suse:sles_sap:12:sp2" - """, + "/etc/SuSE-release": ( + 'SUSE Linux Enterprise Server 12 (x86_64)\nVERSION = 12\nPATCHLEVEL = 2\n' + '# This file is deprecated and will be removed in a future service pack or release.\n' + '# Please check /etc/os-release for details about this release.'), + "/etc/os-release": ( + 'NAME="SLES_SAP"\nVERSION="12-SP2"\nVERSION_ID="12.2"\nPRETTY_NAME="SUSE Linux Enterprise Server for SAP Applications 12 SP2"\n' + 'ID="sles_sap"\nANSI_COLOR="0;32"\nCPE_NAME="cpe:/o:suse:sles_sap:12:sp2"'), }, "platform.dist": ['SuSE', '12', 'x86_64'], - "result":{ + 'distro': { + 'codename': '', + 'id': 'sles', + 'name': 'SUSE Linux Enterprise Server', + 'version': '12.2', + 'version_best': '12.2', + }, + "result": { "distribution": "SLES_SAP", "distribution_major_version": "12", "distribution_release": "2", @@ -386,25 +422,23 @@ CPE_NAME="cpe:/o:suse:sles_sap:12:sp2" { "name": "SLES4SAP 12 SP3", "input": { - "/etc/SuSE-release": """ -SUSE Linux Enterprise Server 12 (x86_64) -VERSION = 12 -PATCHLEVEL = 3 -# This file is deprecated and will be removed in a future service pack or release. -# Please check /etc/os-release for details about this release. -""", - "/etc/os-release": """ -NAME="SLES" -VERSION="12-SP3" -VERSION_ID="12.3" -PRETTY_NAME="SUSE Linux Enterprise Server 12 SP3" -ID="sles" -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:suse:sles_sap:12:sp3" - """, + "/etc/SuSE-release": ( + 'SUSE Linux Enterprise Server 12 (x86_64)VERSION = 12PATCHLEVEL = 3' + '\n# This file is deprecated and will be removed in a future service pack or release.\n' + '# Please check /etc/os-release for details about this release.'), + "/etc/os-release": ( + 'NAME="SLES"\nVERSION="12-SP3"\nVERSION_ID="12.3"\nPRETTY_NAME="SUSE Linux Enterprise Server 12 SP3"\n' + 'ID="sles"\nANSI_COLOR="0;32"\nCPE_NAME="cpe:/o:suse:sles_sap:12:sp3"'), }, "platform.dist": ['SuSE', '12', 'x86_64'], - "result":{ + 'distro': { + 'codename': '', + 'id': 'sles', + 'name': 'SUSE Linux Enterprise Server', + 'version': '12.3', + 'version_best': '12.3', + }, + "result": { "distribution": "SLES_SAP", "distribution_major_version": "12", "distribution_release": "3", @@ -415,42 +449,42 @@ CPE_NAME="cpe:/o:suse:sles_sap:12:sp3" { "name": "Debian stretch/sid", "input": { - "/etc/os-release": """ -PRETTY_NAME="Debian GNU/Linux stretch/sid" -NAME="Debian GNU/Linux" -ID=debian -HOME_URL="https://www.debian.org/" -SUPPORT_URL="https://www.debian.org/support" -BUG_REPORT_URL="https://bugs.debian.org/" -""", - "/etc/debian_version": """ - stretch/sid - """, + "/etc/os-release": ( + 'PRETTY_NAME="Debian GNU/Linux stretch/sid"\nNAME="Debian GNU/Linux"\nID=debian\nHOME_URL="https://www.debian.org/"\n' + 'SUPPORT_URL="https://www.debian.org/support"\nBUG_REPORT_URL="https://bugs.debian.org/"'), + "/etc/debian_version": 'stretch/sid\n', }, "platform.dist": ('debian', 'stretch/sid', ''), + 'distro': { + 'codename': 'stretch', + 'id': 'debian', + 'name': 'Debian GNU/Linux', + 'version': '9', + 'version_best': '9.8', + }, "result": { "distribution": "Debian", - "distribution_major_version": "stretch/sid", - "distribution_release": "NA", + "distribution_major_version": "9", + "distribution_release": "stretch", "os_family": "Debian", - "distribution_version": "stretch/sid", + "distribution_version": "9.8", } }, { 'name': "Debian 7.9", 'input': { - '/etc/os-release': """PRETTY_NAME="Debian GNU/Linux 7 (wheezy)" -NAME="Debian GNU/Linux" -VERSION_ID="7" -VERSION="7 (wheezy)" -ID=debian -ANSI_COLOR="1;31" -HOME_URL="http://www.debian.org/" -SUPPORT_URL="http://www.debian.org/support/" -BUG_REPORT_URL="http://bugs.debian.org/" -""" + '/etc/os-release': ( + 'PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"\nNAME="Debian GNU/Linux"\nVERSION_ID="7"\nVERSION="7 (wheezy)"\nID=debian\nANSI_COLOR="1;31"\n' + 'HOME_URL="http://www.debian.org/"\nSUPPORT_URL="http://www.debian.org/support/"\nBUG_REPORT_URL="http://bugs.debian.org/"'), }, 'platform.dist': ('debian', '7.9', ''), + 'distro': { + 'codename': 'wheezy', + 'id': 'debian', + 'name': 'Debian GNU/Linux', + 'version': '7', + 'version_best': '7.9', + }, 'result': { 'distribution': u'Debian', 'distribution_major_version': u'7', @@ -462,23 +496,20 @@ BUG_REPORT_URL="http://bugs.debian.org/" { 'name': "SteamOS 2.0", 'input': { - '/etc/os-release': """PRETTY_NAME="SteamOS GNU/Linux 2.0 (brewmaster)" -NAME="SteamOS GNU/Linux" -VERSION_ID="2" -VERSION="2 (brewmaster)" -ID=steamos -ID_LIKE=debian -HOME_URL="http://www.steampowered.com/" -SUPPORT_URL="http://support.steampowered.com/" -BUG_REPORT_URL="http://support.steampowered.com/" -""", - '/etc/lsb-release': """DISTRIB_ID=SteamOS -DISTRIB_RELEASE=2.0 -DISTRIB_CODENAME=brewmaster -DISTRIB_DESCRIPTION="SteamOS 2.0" -""" + '/etc/os-release': ( + 'PRETTY_NAME="SteamOS GNU/Linux 2.0 (brewmaster)"\nNAME="SteamOS GNU/Linux"\nVERSION_ID="2"\nVERSION="2 (brewmaster)"\n' + 'ID=steamos\nID_LIKE=debian\nHOME_URL="http://www.steampowered.com/"\nSUPPORT_URL="http://support.steampowered.com/"\n' + 'BUG_REPORT_URL="http://support.steampowered.com/"'), + '/etc/lsb-release': 'DISTRIB_ID=SteamOS\nDISTRIB_RELEASE=2.0\nDISTRIB_CODENAME=brewmaster\nDISTRIB_DESCRIPTION="SteamOS 2.0"', }, 'platform.dist': ('Steamos', '2.0', 'brewmaster'), + 'distro': { + 'codename': 'brewmaster', + 'id': 'steamos', + 'name': 'SteamOS GNU/Linux', + 'version': '2.0', + 'version_best': '2.0', + }, 'result': { 'distribution': u'SteamOS', 'distribution_major_version': u'2', @@ -490,17 +521,17 @@ DISTRIB_DESCRIPTION="SteamOS 2.0" { 'name': "Devuan", 'input': { - '/etc/os-release': """PRETTY_NAME="Devuan GNU/Linux 1 (jessie)" -NAME="Devuan GNU/Linux" -VERSION_ID="1" -VERSION="1 (jessie)" -ID=devuan -HOME_URL="http://www.devuan.org/" -SUPPORT_URL="http://www.devuan.org/support/" -BUG_REPORT_URL="https://bugs.devuan.org/" -""" + '/etc/os-release': ('PRETTY_NAME="Devuan GNU/Linux 1 (jessie)"\nNAME="Devuan GNU/Linux"\nVERSION_ID="1"\nVERSION="1 (jessie)"\n' + 'ID=devuan\nHOME_URL="http://www.devuan.org/"\nSUPPORT_URL="http://www.devuan.org/support/"\nBUG_REPORT_URL="https://bugs.devuan.org/"'), }, 'platform.dist': ('', '', ''), + 'distro': { + 'codename': 'jessie', + 'id': 'devuan', + 'name': 'Devuan GNU/Linux', + 'version': '1', + 'version_best': '1', + }, 'result': { 'distribution': u'Devuan', 'distribution_major_version': u'1', @@ -512,15 +543,18 @@ BUG_REPORT_URL="https://bugs.devuan.org/" { 'name': "Devuan", 'input': { - '/etc/os-release': """PRETTY_NAME="Devuan GNU/Linux ascii" -NAME="Devuan GNU/Linux" -ID=devuan -HOME_URL="https://www.devuan.org/" -SUPPORT_URL="https://devuan.org/os/community" -BUG_REPORT_URL="https://bugs.devuan.org/" -""" + '/etc/os-release': ( + 'PRETTY_NAME="Devuan GNU/Linux ascii"\nNAME="Devuan GNU/Linux"\nID=devuan\nHOME_URL="https://www.devuan.org/"\n' + 'SUPPORT_URL="https://devuan.org/os/community"\nBUG_REPORT_URL="https://bugs.devuan.org/"'), }, 'platform.dist': ('', '', ''), + 'distro': { + 'codename': '', + 'id': 'devuan', + 'name': 'Devuan GNU/Linux', + 'version': '', + 'version_best': '', + }, 'result': { 'distribution': u'Devuan', 'distribution_major_version': u'NA', @@ -535,6 +569,13 @@ BUG_REPORT_URL="https://bugs.devuan.org/" "16.04", "xenial" ], + 'distro': { + 'codename': 'xenial', + 'id': 'ubuntu', + 'name': 'Ubuntu', + 'version': '16.04', + 'version_best': '16.04.6', + }, "input": { "/etc/os-release": ( "NAME=\"Ubuntu\"\nVERSION=\"16.04 LTS (Xenial Xerus)\"\nID=ubuntu\nID_LIKE=debian\nPRETTY_NAME=\"Ubuntu 16.04 LTS\"\n" @@ -556,13 +597,16 @@ BUG_REPORT_URL="https://bugs.devuan.org/" 'name': "Ubuntu 10.04 guess", 'input': { - '/etc/lsb-release': """DISTRIB_ID=Ubuntu -DISTRIB_RELEASE=10.04 -DISTRIB_CODENAME=lucid -DISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS -""" + '/etc/lsb-release': 'DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=10.04\nDISTRIB_CODENAME=lucid\nDISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS', }, 'platform.dist': ('Ubuntu', '10.04', 'lucid'), + 'distro': { + 'codename': 'lucid', + 'id': 'ubuntu', + 'name': 'Ubuntu', + 'version': '10.04', + 'version_best': '10.04.1', + }, 'result': { 'distribution': u'Ubuntu', @@ -575,23 +619,19 @@ DISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS { 'name': "Ubuntu 14.04", 'input': { - '/etc/lsb-release': """DISTRIB_ID=Ubuntu -DISTRIB_RELEASE=14.04 -DISTRIB_CODENAME=trusty -DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS" -""", - '/etc/os-release': """NAME="Ubuntu" -VERSION="14.04.4 LTS, Trusty Tahr" -ID=ubuntu -ID_LIKE=debian -PRETTY_NAME="Ubuntu 14.04.4 LTS" -VERSION_ID="14.04" -HOME_URL="http://www.ubuntu.com/" -SUPPORT_URL="http://help.ubuntu.com/" -BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" -""" + '/etc/lsb-release': 'DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=14.04\nDISTRIB_CODENAME=trusty\nDISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"', + '/etc/os-release': ( + 'NAME="Ubuntu"\nVERSION="14.04.4 LTS, Trusty Tahr"\nID=ubuntu\nID_LIKE=debian\nPRETTY_NAME="Ubuntu 14.04.4 LTS"\nVERSION_ID="14.04"\n' + 'HOME_URL="http://www.ubuntu.com/"\nSUPPORT_URL="http://help.ubuntu.com/"\nBUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"'), }, 'platform.dist': ('Ubuntu', '14.04', 'trusty'), + 'distro': { + 'codename': 'trusty', + 'id': 'ubuntu', + 'name': 'Ubuntu', + 'version': '14.04', + 'version_best': '14.04.4', + }, 'result': { 'distribution': u'Ubuntu', 'distribution_major_version': u'14', @@ -602,19 +642,20 @@ BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" }, { 'name': "Ubuntu 12.04", - 'input': {'/etc/lsb-release': """DISTRIB_ID=Ubuntu -DISTRIB_RELEASE=12.04 -DISTRIB_CODENAME=precise -DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS" -""", - '/etc/os-release': """NAME="Ubuntu" -VERSION="12.04.5 LTS, Precise Pangolin" -ID=ubuntu -ID_LIKE=debian -PRETTY_NAME="Ubuntu precise (12.04.5 LTS)" -VERSION_ID="12.04" -"""}, + 'input': { + '/etc/lsb-release': 'DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=12.04\nDISTRIB_CODENAME=precise\nDISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"', + '/etc/os-release': ( + 'NAME="Ubuntu"\nVERSION="12.04.5 LTS, Precise Pangolin"\nID=ubuntu\nID_LIKE=debian\n' + 'PRETTY_NAME="Ubuntu precise (12.04.5 LTS)"\nVERSION_ID="12.04"'), + }, 'platform.dist': ('Ubuntu', '12.04', 'precise'), + 'distro': { + 'codename': 'precise', + 'id': 'ubuntu', + 'name': 'Ubuntu', + 'version': '12.04', + 'version_best': '12.04.5', + }, 'result': {'distribution': u'Ubuntu', 'distribution_major_version': u'12', 'distribution_release': u'precise', @@ -638,6 +679,13 @@ VERSION_ID="12.04" '2019.1', '' ], + 'distro': { + 'codename': 'kali-rolling', + 'id': 'kali', + 'name': 'Kali GNU/Linux Rolling', + 'version': '2019.1', + 'version_best': '2019.1', + }, 'result': { 'distribution': 'Kali', 'distribution_version': '2019.1', @@ -652,6 +700,13 @@ VERSION_ID="12.04" "16.04", "xenial" ], + 'distro': { + 'codename': 'xenial', + 'id': 'neon', + 'name': 'KDE neon', + 'version': '16.04', + 'version_best': '16.04', + }, "input": { "/etc/os-release": ("NAME=\"KDE neon\"\nVERSION=\"5.8\"\nID=neon\nID_LIKE=\"ubuntu debian\"\nPRETTY_NAME=\"KDE neon User Edition 5.8\"\n" "VERSION_ID=\"16.04\"\nHOME_URL=\"http://neon.kde.org/\"\nSUPPORT_URL=\"http://neon.kde.org/\"\n" @@ -670,29 +725,24 @@ VERSION_ID="12.04" { 'name': 'Core OS', 'input': { - '/etc/os-release': """ -NAME=CoreOS -ID=coreos -VERSION=976.0.0 -VERSION_ID=976.0.0 -BUILD_ID=2016-03-03-2324 -PRETTY_NAME="CoreOS 976.0.0 (Coeur Rouge)" -ANSI_COLOR="1;32" -HOME_URL="https://coreos.com/" -BUG_REPORT_URL="https://github.com/coreos/bugs/issues" -""", - '/etc/lsb-release': """DISTRIB_ID=CoreOS -DISTRIB_RELEASE=976.0.0 -DISTRIB_CODENAME="Coeur Rouge" -DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" -""", + '/etc/os-release': ( + 'NAME=CoreOS\nID=coreos\nVERSION=976.0.0\nVERSION_ID=976.0.0\nBUILD_ID=2016-03-03-2324\nPRETTY_NAME="CoreOS 976.0.0 (Coeur Rouge)"\n' + 'ANSI_COLOR="1;32"\nHOME_URL="https://coreos.com/"\nBUG_REPORT_URL="https://github.com/coreos/bugs/issues"'), + '/etc/lsb-release': ( + 'DISTRIB_ID=CoreOS\nDISTRIB_RELEASE=976.0.0\nDISTRIB_CODENAME="Coeur Rouge"\nDISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)"'), }, 'platform.dist': ('', '', ''), + 'distro': { + 'codename': 'Coeur Rouge', + 'id': 'coreos', + 'name': 'CoreOS', + 'version': '976.0.0', + 'version_best': '976.0.0', + }, 'platform.release': '', 'result': { "distribution": "CoreOS", - "distribution_major_version": "NA", - "distribution_release": "NA", + "distribution_major_version": "976", "distribution_version": "976.0.0", } }, @@ -711,6 +761,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": (" SmartOS 20160330T234717Z x86_64\n" " Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.\n" @@ -747,6 +804,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": (" SmartOS x86_64\n Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.\n" " Copyright 2010-2013 Joyent, Inc. All Rights Reserved.\n Use is subject to license terms.\n" @@ -769,6 +833,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": (" OpenIndiana Development oi_151.1.9 X86 (powered by illumos)\n Copyright 2011 Oracle and/or its affiliates. " "All rights reserved.\n Use is subject to license terms.\n " @@ -790,6 +861,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, # "platform.release": 'OmniOS', "input": { "/etc/release": ( @@ -812,6 +890,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "platform.release:": "", "input": { "/etc/release": (" Open Storage Appliance v3.1.6\n Copyright (c) 2014 Nexenta Systems, Inc. " @@ -834,6 +919,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": (" Open Storage Appliance 4.0.3-FP2\n Copyright (c) 2014 Nexenta Systems, Inc. " "All Rights Reserved.\n Copyright (c) 2010 Oracle. All Rights Reserved.\n " @@ -857,6 +949,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": (" Solaris 10 10/09 s10x_u8wos_08a X86\n Copyright 2009 Sun Microsystems, Inc. " "All Rights Reserved.\n Use is subject to license terms.\n " @@ -880,6 +979,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": (" Oracle Solaris 11 11/11 X86\n Copyright (c) 1983, 2011, Oracle and/or its affiliates. " "All rights reserved.\n Assembled 18 October 2011\n") @@ -894,6 +1000,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": ( " Oracle Solaris 11.3 X86\n Copyright (c) 1983, 2018, Oracle and/or its affiliates. " @@ -917,6 +1030,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": ( " Oracle Solaris 11.4 SPARC\n Copyright (c) 1983, 2018, Oracle and/or its affiliates." @@ -940,6 +1060,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': '', + 'name': '', + 'version': '', + 'version_best': '', + }, "input": { "/etc/release": (" Oracle Solaris 10 1/13 s10x_u11wos_24a X86\n Copyright (c) 1983, 2013, Oracle and/or its affiliates. " "All rights reserved.\n Assembled 17 January 2013\n") @@ -960,6 +1087,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "22", "Twenty Two" ], + 'distro': { + 'codename': 'Twenty Two', + 'id': 'fedora', + 'name': 'Fedora', + 'version': '22', + 'version_best': '22', + }, "input": { "/etc/redhat-release": "Fedora release 22 (Twenty Two)\n", "/etc/os-release": ( @@ -985,6 +1119,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "25", "Rawhide" ], + 'distro': { + 'codename': 'Rawhide', + 'id': 'fedora', + 'name': 'Fedora', + 'version': '25', + 'version_best': '25', + }, "input": { "/etc/redhat-release": "Fedora release 25 (Rawhide)\n", "/etc/os-release": ( @@ -1012,6 +1153,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': 'smgl', + 'name': 'Source Mage GNU/Linux', + 'version': '', + 'version_best': '', + }, "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") @@ -1033,6 +1181,13 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "", "" ], + 'distro': { + 'codename': '', + 'id': 'arch', + 'name': 'Arch Linux', + 'version': '', + 'version_best': '', + }, "input": { "/etc/os-release": "NAME=\"Arch Linux\"\nPRETTY_NAME=\"Arch Linux\"\nID=arch\nID_LIKE=archlinux\nANSI_COLOR=\"0;36\"\nHOME_URL=\"https://www.archlinux.org/\"\nSUPPORT_URL=\"https://bbs.archlinux.org/\"\nBUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n\n", # noqa "/etc/arch-release": "", @@ -1048,49 +1203,38 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" }, # ClearLinux https://github.com/ansible/ansible/issues/31501#issuecomment-340861535 -{ - "platform.dist": [ - "Clear Linux OS", - "26580", - "clear-linux-os" - ], - "input": { - "/etc/os-release": ''' -NAME="Clear Linux OS" -VERSION=1 -ID=clear-linux-os -ID_LIKE=clear-linux-os -VERSION_ID=26580 -PRETTY_NAME="Clear Linux OS" -ANSI_COLOR="1;35" -HOME_URL="https://clearlinux.org" -SUPPORT_URL="https://clearlinux.org" -BUG_REPORT_URL="mailto:dev@lists.clearlinux.org" -PRIVACY_POLICY_URL="http://www.intel.com/privacy" -''', - "/usr/lib/os-release": ''' -NAME="Clear Linux OS" -VERSION=1 -ID=clear-linux-os -ID_LIKE=clear-linux-os -VERSION_ID=26580 -PRETTY_NAME="Clear Linux OS" -ANSI_COLOR="1;35" -HOME_URL="https://clearlinux.org" -SUPPORT_URL="https://clearlinux.org" -BUG_REPORT_URL="mailto:dev@lists.clearlinux.org" -PRIVACY_POLICY_URL="http://www.intel.com/privacy" -''' + { + "platform.dist": [ + "Clear Linux OS", + "26580", + "clear-linux-os" + ], + 'distro': { + 'codename': '', + 'id': 'clear-linux-os', + 'name': 'Clear Linux OS', + 'version': '26580', + 'version_best': '26580', + }, + "input": { + "/etc/os-release": ( + 'NAME="Clear Linux OS"\nVERSION=1\nID=clear-linux-os\nID_LIKE=clear-linux-os\nVERSION_ID=26580\nPRETTY_NAME="Clear Linux OS"\n' + 'ANSI_COLOR="1;35"\nHOME_URL="https://clearlinux.org"\nSUPPORT_URL="https://clearlinux.org"\n' + 'BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"\nPRIVACY_POLICY_URL="http://www.intel.com/privacy"'), + "/usr/lib/os-release": ( + 'NAME="Clear Linux OS"\nVERSION=1\nID=clear-linux-os\nID_LIKE=clear-linux-os\nVERSION_ID=26580\nPRETTY_NAME="Clear Linux OS"\n' + 'ANSI_COLOR="1;35"\nHOME_URL="https://clearlinux.org"\nSUPPORT_URL="https://clearlinux.org"\n' + 'BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"\nPRIVACY_POLICY_URL="http://www.intel.com/privacy"'), + }, + "name": "ClearLinux 26580", + "result": { + "distribution_release": "clear-linux-os", + "distribution": "Clear Linux OS", + "distribution_major_version": "26580", + "os_family": "ClearLinux", + "distribution_version": "26580" + } }, - "name": "ClearLinux 26580", - "result": { - "distribution_release": "clear-linux-os", - "distribution": "Clear Linux OS", - "distribution_major_version": "26580", - "os_family": "ClearLinux", - "distribution_version": "26580" - } -}, # ArchLinux with no /etc/arch-release but with a /etc/os-release with NAME=Arch Linux # The fact needs to map 'Arch Linux' to 'Archlinux' for compat with 2.3 and earlier facts { @@ -1099,6 +1243,13 @@ PRIVACY_POLICY_URL="http://www.intel.com/privacy" "", "" ], + 'distro': { + 'codename': '', + 'id': 'arch', + 'name': 'Arch Linux', + 'version': '', + 'version_best': '', + }, "input": { "/etc/os-release": "NAME=\"Arch Linux\"\nPRETTY_NAME=\"Arch Linux\"\nID=arch\nID_LIKE=archlinux\nANSI_COLOR=\"0;36\"\nHOME_URL=\"https://www.archlinux.org/\"\nSUPPORT_URL=\"https://bbs.archlinux.org/\"\nBUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n\n", # noqa }, @@ -1114,18 +1265,19 @@ PRIVACY_POLICY_URL="http://www.intel.com/privacy" { 'name': "Cumulus Linux 3.7.3", 'input': { - '/etc/os-release': """NAME="Cumulus Linux" -VERSION_ID=3.7.3 -VERSION="Cumulus Linux 3.7.3" -PRETTY_NAME="Cumulus Linux" -ID=cumulus-linux -ID_LIKE=debian -CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:3.7.3 -HOME_URL="http://www.cumulusnetworks.com/" -SUPPORT_URL="http://support.cumulusnetworks.com/" -""" + '/etc/os-release': ( + 'NAME="Cumulus Linux"\nVERSION_ID=3.7.3\nVERSION="Cumulus Linux 3.7.3"\nPRETTY_NAME="Cumulus Linux"\nID=cumulus-linux\n' + 'ID_LIKE=debian\nCPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:3.7.3\nHOME_URL="http://www.cumulusnetworks.com/"\n' + 'SUPPORT_URL="http://support.cumulusnetworks.com/"'), }, 'platform.dist': ('debian', '8.11', ''), + 'distro': { + 'codename': '', + 'id': 'cumulus-linux', + 'name': 'Cumulus Linux', + 'version': '3.7.3', + 'version_best': '3.7.3', + }, 'result': { 'distribution': 'Cumulus Linux', 'distribution_major_version': '3', @@ -1137,18 +1289,19 @@ SUPPORT_URL="http://support.cumulusnetworks.com/" { 'name': "Cumulus Linux 2.5.4", 'input': { - '/etc/os-release': """NAME="Cumulus Linux" -VERSION_ID=2.5.4 -VERSION="2.5.4-6dc6e80-201510091936-build" -PRETTY_NAME="Cumulus Linux" -ID=cumulus-linux -ID_LIKE=debian -CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:2.5.4-6dc6e80-201510091936-build -HOME_URL="http://www.cumulusnetworks.com/" -SUPPORT_URL="http://support.cumulusnetworks.com/" -""" + '/etc/os-release': ( + 'NAME="Cumulus Linux"\nVERSION_ID=2.5.4\nVERSION="2.5.4-6dc6e80-201510091936-build"\nPRETTY_NAME="Cumulus Linux"\nID=cumulus-linux\n' + 'ID_LIKE=debian\nCPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:2.5.4-6dc6e80-201510091936-build\nHOME_URL="http://www.cumulusnetworks.com/"\n' + 'SUPPORT_URL="http://support.cumulusnetworks.com/"'), }, 'platform.dist': ('', '', ''), + 'distro': { + 'codename': '', + 'id': 'cumulus-linux', + 'name': 'Cumulus Linux', + 'version': '2.5.4', + 'version_best': '2.5.4', + }, 'result': { 'distribution': 'Cumulus Linux', 'distribution_major_version': '2', @@ -1159,22 +1312,37 @@ SUPPORT_URL="http://support.cumulusnetworks.com/" }, { "platform.dist": [ - "LinuxMint", - "18.3", - "sylvia", + "linuxmint", + "18.2", + "sonya" ], "input": { - "/etc/os-release": "NAME=\"Linux Mint\"\nVERSION=\"18.3 (Sylvia)\"\nID=linuxmint\nID_LIKE=ubuntu\nPRETTY_NAME=\"Linux Mint 18.3\"\nVERSION_ID=\"18.3\"\nHOME_URL=\"http://www.linuxmint.com/\"\nSUPPORT_URL=\"http://forums.linuxmint.com/\"\nBUG_REPORT_URL=\"http://bugs.launchpad.net/linuxmint/\"\nVERSION_CODENAME=sylvia\nUBUNTU_CODENAME=xenial", # noqa + "/etc/os-release": ( + 'NAME="Linux Mint"\nVERSION="18.2 (Sonya)"\nID=linuxmint\nID_LIKE=ubuntu\nPRETTY_NAME="Linux Mint 18.2"\n' + 'VERSION_ID="18.2"\nHOME_URL="http://www.linuxmint.com/"\nSUPPORT_URL="http://forums.linuxmint.com/"\n' + 'BUG_REPORT_URL="http://bugs.launchpad.net/linuxmint/"\nVERSION_CODENAME=sonya\nUBUNTU_CODENAME=xenial\n'), + "/usr/lib/os-release": ( + 'NAME="Linux Mint"\nVERSION="18.2 (Sonya)"\nID=linuxmint\nID_LIKE=ubuntu\nPRETTY_NAME="Linux Mint 18.2"\n' + 'VERSION_ID="18.2"\nHOME_URL="http://www.linuxmint.com/"\nSUPPORT_URL="http://forums.linuxmint.com/"\n' + 'BUG_REPORT_URL="http://bugs.launchpad.net/linuxmint/"\nVERSION_CODENAME=sonya\nUBUNTU_CODENAME=xenial\n'), + "/etc/lsb-release": "DISTRIB_ID=LinuxMint\nDISTRIB_RELEASE=18.2\nDISTRIB_CODENAME=sonya\nDISTRIB_DESCRIPTION=\"Linux Mint 18.2 Sonya\"\n" }, - "name": "Linux Mint 18.3", "result": { - "distribution_release": "sylvia", + "distribution_release": "sonya", "distribution": "Linux Mint", "distribution_major_version": "18", "os_family": "Debian", - "distribution_version": "18.3" - } - } + "distribution_version": "18.2" + }, + "name": "Linux Mint 18.2", + "distro": { + "codename": "sonya", + "version": "18.2", + "id": "linuxmint", + "version_best": "18.2", + "name": "Linux Mint" + }, + }, ] @@ -1230,13 +1398,18 @@ def test_distribution_version(am, mocker, testcase): return testcase.get('platform.version', '') def mock_distro_name(): - return testcase['platform.dist'][0] + return testcase['distro']['name'] - def mock_distro_version(): - return testcase['platform.dist'][1] + def mock_distro_id(): + return testcase['distro']['id'] + + def mock_distro_version(best=False): + if best: + return testcase['distro']['version_best'] + return testcase['distro']['version'] def mock_distro_codename(): - return testcase['platform.dist'][2] + return testcase['distro']['codename'] def mock_open(filename, mode='r'): if filename in testcase['input']: @@ -1255,7 +1428,7 @@ def test_distribution_version(am, mocker, testcase): mocker.patch('ansible.module_utils.facts.system.distribution.get_uname', mock_get_uname) mocker.patch('ansible.module_utils.facts.system.distribution._file_exists', mock_file_exists) mocker.patch('ansible.module_utils.distro.name', mock_distro_name) - mocker.patch('ansible.module_utils.distro.id', mock_distro_name) + mocker.patch('ansible.module_utils.distro.id', mock_distro_id) mocker.patch('ansible.module_utils.distro.version', mock_distro_version) mocker.patch('ansible.module_utils.distro.codename', mock_distro_codename) mocker.patch('os.path.isfile', mock_os_path_is_file)