Fix os_family and distribution on archlinux
Fixes #8732, ansible/ansible-modules-core#34
This commit is contained in:
parent
57d2622c8c
commit
5efc4efca7
1 changed files with 74 additions and 73 deletions
|
@ -273,84 +273,85 @@ class Facts(object):
|
||||||
self.facts['distribution_release'] = dist[2] or 'NA'
|
self.facts['distribution_release'] = dist[2] or 'NA'
|
||||||
# Try to handle the exceptions now ...
|
# Try to handle the exceptions now ...
|
||||||
for (path, name) in Facts.OSDIST_LIST:
|
for (path, name) in Facts.OSDIST_LIST:
|
||||||
if os.path.exists(path) and os.path.getsize(path) > 0:
|
if os.path.exists(path):
|
||||||
if self.facts['distribution'] in ('Fedora', ):
|
if os.path.getsize(path) > 0:
|
||||||
# Once we determine the value is one of these distros
|
if self.facts['distribution'] in ('Fedora', ):
|
||||||
# we trust the values are always correct
|
# Once we determine the value is one of these distros
|
||||||
break
|
# we trust the values are always correct
|
||||||
elif name == 'RedHat':
|
break
|
||||||
data = get_file_content(path)
|
elif name == 'RedHat':
|
||||||
if 'Red Hat' in data:
|
data = get_file_content(path)
|
||||||
|
if 'Red Hat' in data:
|
||||||
|
self.facts['distribution'] = name
|
||||||
|
else:
|
||||||
|
self.facts['distribution'] = data.split()[0]
|
||||||
|
break
|
||||||
|
elif name == 'OtherLinux':
|
||||||
|
data = get_file_content(path)
|
||||||
|
if 'Amazon' in data:
|
||||||
|
self.facts['distribution'] = 'Amazon'
|
||||||
|
self.facts['distribution_version'] = data.split()[-1]
|
||||||
|
break
|
||||||
|
elif name == 'OpenWrt':
|
||||||
|
data = get_file_content(path)
|
||||||
|
if 'OpenWrt' in data:
|
||||||
|
self.facts['distribution'] = name
|
||||||
|
version = re.search('DISTRIB_RELEASE="(.*)"', data)
|
||||||
|
if version:
|
||||||
|
self.facts['distribution_version'] = version.groups()[0]
|
||||||
|
release = re.search('DISTRIB_CODENAME="(.*)"', data)
|
||||||
|
if release:
|
||||||
|
self.facts['distribution_release'] = release.groups()[0]
|
||||||
|
break
|
||||||
|
elif name == 'Alpine':
|
||||||
|
data = get_file_content(path)
|
||||||
self.facts['distribution'] = name
|
self.facts['distribution'] = name
|
||||||
else:
|
self.facts['distribution_version'] = data
|
||||||
self.facts['distribution'] = data.split()[0]
|
|
||||||
break
|
|
||||||
elif name == 'OtherLinux':
|
|
||||||
data = get_file_content(path)
|
|
||||||
if 'Amazon' in data:
|
|
||||||
self.facts['distribution'] = 'Amazon'
|
|
||||||
self.facts['distribution_version'] = data.split()[-1]
|
|
||||||
break
|
break
|
||||||
elif name == 'OpenWrt':
|
elif name == 'Solaris':
|
||||||
data = get_file_content(path)
|
data = get_file_content(path).split('\n')[0]
|
||||||
if 'OpenWrt' in data:
|
if 'Solaris' in data:
|
||||||
self.facts['distribution'] = name
|
ora_prefix = ''
|
||||||
version = re.search('DISTRIB_RELEASE="(.*)"', data)
|
if 'Oracle Solaris' in data:
|
||||||
if version:
|
data = data.replace('Oracle ','')
|
||||||
self.facts['distribution_version'] = version.groups()[0]
|
ora_prefix = 'Oracle '
|
||||||
release = re.search('DISTRIB_CODENAME="(.*)"', data)
|
self.facts['distribution'] = data.split()[0]
|
||||||
if release:
|
self.facts['distribution_version'] = data.split()[1]
|
||||||
self.facts['distribution_release'] = release.groups()[0]
|
self.facts['distribution_release'] = ora_prefix + data
|
||||||
break
|
break
|
||||||
elif name == 'Alpine':
|
elif name == 'SuSE':
|
||||||
data = get_file_content(path)
|
data = get_file_content(path)
|
||||||
self.facts['distribution'] = name
|
if 'suse' in data.lower():
|
||||||
self.facts['distribution_version'] = data
|
if path == '/etc/os-release':
|
||||||
break
|
release = re.search("PRETTY_NAME=[^(]+ \(?([^)]+?)\)", data)
|
||||||
elif name == 'Solaris':
|
if release:
|
||||||
data = get_file_content(path).split('\n')[0]
|
self.facts['distribution_release'] = release.groups()[0]
|
||||||
if 'Solaris' in data:
|
break
|
||||||
ora_prefix = ''
|
elif path == '/etc/SuSE-release':
|
||||||
if 'Oracle Solaris' in data:
|
data = data.splitlines()
|
||||||
data = data.replace('Oracle ','')
|
for line in data:
|
||||||
ora_prefix = 'Oracle '
|
release = re.search('CODENAME *= *([^\n]+)', line)
|
||||||
self.facts['distribution'] = data.split()[0]
|
if release:
|
||||||
self.facts['distribution_version'] = data.split()[1]
|
self.facts['distribution_release'] = release.groups()[0].strip()
|
||||||
self.facts['distribution_release'] = ora_prefix + data
|
break
|
||||||
break
|
elif name == 'Debian':
|
||||||
elif name == 'SuSE':
|
data = get_file_content(path)
|
||||||
data = get_file_content(path)
|
if 'Debian' in data:
|
||||||
if 'suse' in data.lower():
|
|
||||||
if path == '/etc/os-release':
|
|
||||||
release = re.search("PRETTY_NAME=[^(]+ \(?([^)]+?)\)", data)
|
release = re.search("PRETTY_NAME=[^(]+ \(?([^)]+?)\)", data)
|
||||||
if release:
|
if release:
|
||||||
self.facts['distribution_release'] = release.groups()[0]
|
self.facts['distribution_release'] = release.groups()[0]
|
||||||
break
|
break
|
||||||
elif path == '/etc/SuSE-release':
|
elif name == 'Mandriva':
|
||||||
data = data.splitlines()
|
data = get_file_content(path)
|
||||||
for line in data:
|
if 'Mandriva' in data:
|
||||||
release = re.search('CODENAME *= *([^\n]+)', line)
|
version = re.search('DISTRIB_RELEASE="(.*)"', data)
|
||||||
if release:
|
if version:
|
||||||
self.facts['distribution_release'] = release.groups()[0].strip()
|
self.facts['distribution_version'] = version.groups()[0]
|
||||||
break
|
release = re.search('DISTRIB_CODENAME="(.*)"', data)
|
||||||
elif name == 'Debian':
|
if release:
|
||||||
data = get_file_content(path)
|
self.facts['distribution_release'] = release.groups()[0]
|
||||||
if 'Debian' in data:
|
self.facts['distribution'] = name
|
||||||
release = re.search("PRETTY_NAME=[^(]+ \(?([^)]+?)\)", data)
|
break
|
||||||
if release:
|
|
||||||
self.facts['distribution_release'] = release.groups()[0]
|
|
||||||
break
|
|
||||||
elif name == 'Mandriva':
|
|
||||||
data = get_file_content(path)
|
|
||||||
if 'Mandriva' in data:
|
|
||||||
version = re.search('DISTRIB_RELEASE="(.*)"', data)
|
|
||||||
if version:
|
|
||||||
self.facts['distribution_version'] = version.groups()[0]
|
|
||||||
release = re.search('DISTRIB_CODENAME="(.*)"', data)
|
|
||||||
if release:
|
|
||||||
self.facts['distribution_release'] = release.groups()[0]
|
|
||||||
self.facts['distribution'] = name
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
self.facts['distribution'] = name
|
self.facts['distribution'] = name
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue