From 65393e47476ec0c4faf86f6400010250a6784738 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Tue, 3 Oct 2017 15:32:33 -0400 Subject: [PATCH] Fix ansible_distribution on Ubuntu 10.04 (#31108) The /etc/os-release based distro detection doesn't seem to work for Ubuntu 10.04 (no /etc/os-release?). So it was testing the next case which was /etc/lsb-release to see if it is 'Mandriva'. Since the check for existence of (/etc/lsb-release, Mandrive) was the first non-empty dist file match, 'ansible_distribution' was being set to 'Mandriva' expecting to be corrected by the data from the dist file content. But since the dist file parsing for Mandriva didn't match for Ubuntu 10.04 /etc/lsb-release _and_ there is no Debian specific lsb-release check, 'ansible_distribution' stayed at 'Mandriva' and the dist file checking loop keeps going and eventually off the end of the list before finding a better match. Adding a debian/ubuntu specific check for /etc/lsb-release after the debian os-release sets the info correctly and stops further checking of dist files. Fixes #30693 --- .../module_utils/facts/system/distribution.py | 1 + .../module_utils/test_distribution_version.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py index 3d75c57be2..815352fe77 100644 --- a/lib/ansible/module_utils/facts/system/distribution.py +++ b/lib/ansible/module_utils/facts/system/distribution.py @@ -69,6 +69,7 @@ class DistributionFiles: {'path': '/etc/SuSE-release', 'name': 'SUSE'}, {'path': '/etc/gentoo-release', 'name': 'Gentoo'}, {'path': '/etc/os-release', 'name': 'Debian'}, + {'path': '/etc/lsb-release', 'name': 'Debian'}, {'path': '/etc/lsb-release', 'name': 'Mandriva'}, {'path': '/etc/altlinux-release', 'name': 'Altlinux'}, {'path': '/etc/sourcemage-release', 'name': 'SMGL'}, diff --git a/test/units/module_utils/test_distribution_version.py b/test/units/module_utils/test_distribution_version.py index b1e79fa19a..68dddd9d8b 100644 --- a/test/units/module_utils/test_distribution_version.py +++ b/test/units/module_utils/test_distribution_version.py @@ -418,6 +418,26 @@ BUG_REPORT_URL="http://bugs.debian.org/" "distribution_version": "16.04" } }, + { + '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 +""" + }, + 'platform.dist': ('Ubuntu', '10.04', 'lucid'), + 'result': + { + 'distribution': u'Ubuntu', + 'distribution_major_version': u'10', + 'distribution_release': u'lucid', + "os_family": "Debian", + 'distribution_version': u'10.04' + } + }, { 'name': "Ubuntu 14.04", 'input': {