mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 23:21:22 -07:00
Ensure Clear Linux parsing is actually parsing a Clear Linux host and all others fall back to NA (#53298)
Fixes a bug where parse_distribution_file_ClearLinux() was called on CoreOS (and probably many other distros) and it returned True since it successfully parses the distribution file. Since this file exists on many Linux distributions and they are a very similar format, add an additional check to make sure it is Clear Linux. Change the order in which distribution files are processed so NA is last. This prevents a match on CoreOS hosts since they also have /etc/os-release and the called matching function for NA is very general and will match CoreOS. * Add changelog * Add unit tests Only add tests for Clear Linux parsing since that was the cause of this issue.
This commit is contained in:
parent
ba3345b52b
commit
1d91e03119
3 changed files with 87 additions and 5 deletions
|
@ -70,8 +70,8 @@ class DistributionFiles:
|
|||
{'path': '/etc/lsb-release', 'name': 'Mandriva'},
|
||||
{'path': '/etc/sourcemage-release', 'name': 'SMGL'},
|
||||
{'path': '/usr/lib/os-release', 'name': 'ClearLinux'},
|
||||
{'path': '/etc/os-release', 'name': 'NA'},
|
||||
{'path': '/etc/coreos/update.conf', 'name': 'Coreos'},
|
||||
{'path': '/etc/os-release', 'name': 'NA'},
|
||||
)
|
||||
|
||||
SEARCH_STRING = {
|
||||
|
@ -406,6 +406,11 @@ class DistributionFiles:
|
|||
if "clearlinux" not in name.lower():
|
||||
return False, clear_facts
|
||||
|
||||
pname = re.search('NAME="(.*)"', data)
|
||||
if pname:
|
||||
if 'Clear Linux' not in pname.groups()[0]:
|
||||
return False, clear_facts
|
||||
clear_facts['distribution'] = pname.groups()[0]
|
||||
version = re.search('VERSION_ID=(.*)', data)
|
||||
if version:
|
||||
clear_facts['distribution_major_version'] = version.groups()[0]
|
||||
|
@ -413,9 +418,6 @@ class DistributionFiles:
|
|||
release = re.search('ID=(.*)', data)
|
||||
if release:
|
||||
clear_facts['distribution_release'] = release.groups()[0]
|
||||
pname = re.search('NAME="(.*)"', data)
|
||||
if pname:
|
||||
clear_facts['distribution'] = pname.groups()[0]
|
||||
return True, clear_facts
|
||||
|
||||
|
||||
|
@ -449,8 +451,8 @@ class Distribution(object):
|
|||
{'path': '/etc/altlinux-release', 'name': 'Altlinux'},
|
||||
{'path': '/etc/sourcemage-release', 'name': 'SMGL'},
|
||||
{'path': '/usr/lib/os-release', 'name': 'ClearLinux'},
|
||||
{'path': '/etc/os-release', 'name': 'NA'},
|
||||
{'path': '/etc/coreos/update.conf', 'name': 'Coreos'},
|
||||
{'path': '/etc/os-release', 'name': 'NA'},
|
||||
)
|
||||
|
||||
SEARCH_STRING = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue