diff options
author | Adrian Likins <alikins@redhat.com> | 2017-09-25 15:06:05 -0400 |
---|---|---|
committer | Adrian Likins <alikins@redhat.com> | 2017-09-25 15:06:05 -0400 |
commit | 2149d1092bb6bbff9874258d975c21a7e89939e0 (patch) | |
tree | c7613655c944f5d87887ce48bc6c3be26f65f832 /test | |
parent | 3aa7941b72089eee803533f27c54d63529a9c949 (diff) | |
download | ansible-2149d1092bb6bbff9874258d975c21a7e89939e0.tar.gz |
Fix 'distribution' fact for ArchLinux (#30723)
Allow empty wasn't breaking out of the process_dist_files
loop, so a empty /etc/arch-release would continue searching
and eventually try /etc/os-release. The os-release parsing
works, but the distro name there is 'Arch Linux' which does
not match the 2.3 behavior of 'Archlinux'
Add a OS_RELEASE_ALIAS map for the cases where we need to get
the distro name from os-release but use an alias.
We can't include 'Archlinux' in SEARCH_STRING because a name match on its keys
but without a match on the content causes a fallback to using the first
whitespace seperated item from the file content as the name.
For os-release, that is in form 'NAME=Arch Linux'
With os-release returning the right name, this also supports the
case where there is no /etc/arch-release, but there is a /etc/os-release
Fixes #30600
* pep8 and comment cleanup
(cherry picked from commit 3eab636b3f544251bcbde4f89986212c2423fb46)
Diffstat (limited to 'test')
-rw-r--r-- | test/units/module_utils/test_distribution_version.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/units/module_utils/test_distribution_version.py b/test/units/module_utils/test_distribution_version.py index 148f1a9747..b1e79fa19a 100644 --- a/test/units/module_utils/test_distribution_version.py +++ b/test/units/module_utils/test_distribution_version.py @@ -815,6 +815,48 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)" "distribution_version": "NA" } }, + + # ArchLinux with an empty /etc/arch-release and a /etc/os-release with "NAME=Arch Linux" + { + "platform.dist": [ + "", + "", + "" + ], + "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": "", + }, + "name": "Arch Linux NA", + "result": { + "distribution_release": "NA", + "distribution": "Archlinux", + "distribution_major_version": "NA", + "os_family": "Archlinux", + "distribution_version": "NA" + } + }, + + # 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 + { + "platform.dist": [ + "", + "", + "" + ], + "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 + }, + "name": "Arch Linux no arch-release NA", + "result": { + "distribution_release": "NA", + "distribution": "Archlinux", + "distribution_major_version": "NA", + "os_family": "Archlinux", + "distribution_version": "NA" + } + } ] |