1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Facts distribution clear linux 31501 (#32453)

The search string used to look for Clear Linux
was changed in 45a9f96774 to
be more specific, but was too specific. Now finding
a substring match for 'Clear Linux' in /usr/lib/os-release
is enough to consider a match.

Since the details of the full name in os-release varies
('Clear Linux Software for Intel Architecture',
 'Clear Linux OS for Intel Architecture', etc) the
search string match was failing and would fall back to the
'first word in the release file' method resulting in
ansible_distribution='NAME="Clear'

Also add a meta fact indicating which search string
was matched.

Test case info from:
        https://github.com/ansible/ansible/issues/31501#issuecomment-340861535

Fixes #31501
This commit is contained in:
Adrian Likins 2018-01-20 15:05:53 -05:00 committed by GitHub
parent fc180a378a
commit ec9769c82f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View file

@ -32,6 +32,7 @@ filelist = [
'/etc/altlinux-release',
'/etc/os-release',
'/etc/coreos/update.conf',
'/usr/lib/os-release',
]
fcont = {}

View file

@ -82,7 +82,7 @@ class DistributionFiles:
'OracleLinux': 'Oracle Linux',
'RedHat': 'Red Hat',
'Altlinux': 'ALT Linux',
'ClearLinux': 'Clear Linux Software for Intel Architecture',
'ClearLinux': 'Clear Linux',
'SMGL': 'Source Mage GNU/Linux',
}
@ -115,6 +115,7 @@ class DistributionFiles:
if self.SEARCH_STRING[name] in dist_file_content:
# this sets distribution=RedHat if 'Red Hat' shows up in data
dist_file_dict['distribution'] = name
dist_file_dict['distribution_file_search_string'] = self.SEARCH_STRING[name]
else:
# this sets distribution to what's in the data, e.g. CentOS, Scientific, ...
dist_file_dict['distribution'] = dist_file_content.split()[0]

View file

@ -839,6 +839,37 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)"
}
},
# ClearLinux https://github.com/ansible/ansible/issues/31501#issuecomment-340861535
{
"platform.dist": [
"Clear Linux OS for Intel Architecture",
"18450",
"clear-linux-os"
],
"input": {
"/usr/lib/os-release": '''
NAME="Clear Linux OS for Intel Architecture"
VERSION=1
ID=clear-linux-os
VERSION_ID=18450
PRETTY_NAME="Clear Linux OS for Intel Architecture"
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"
'''
},
"name": "Clear Linux OS for Intel Architecture 1",
"result": {
"distribution_release": "clear-linux-os",
"distribution": "ClearLinux",
"distribution_major_version": "18450",
"os_family": "ClearLinux",
"distribution_version": "18450"
}
},
# 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
{