mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Adding support for OpenWrt
This commit is contained in:
@@ -96,6 +96,7 @@ class Facts(object):
|
||||
# This is the fallback to handle unknowns or exceptions
|
||||
OSDIST_DICT = { '/etc/redhat-release': 'RedHat',
|
||||
'/etc/vmware-release': 'VMwareESX',
|
||||
'/etc/openwrt_release': 'OpenWrt',
|
||||
'/etc/system-release': 'OtherLinux' }
|
||||
SELINUX_MODE_DICT = { 1: 'enforcing', 0: 'permissive', -1: 'disabled' }
|
||||
|
||||
@@ -106,6 +107,7 @@ class Facts(object):
|
||||
{ 'path' : '/usr/bin/apt-get', 'name' : 'apt' },
|
||||
{ 'path' : '/usr/bin/zypper', 'name' : 'zypper' },
|
||||
{ 'path' : '/usr/bin/pacman', 'name' : 'pacman' },
|
||||
{ 'path' : '/bin/opkg', 'name' : 'opkg' },
|
||||
{ 'path' : '/opt/local/bin/pkgin', 'name' : 'pkgin' } ]
|
||||
|
||||
def __init__(self):
|
||||
@@ -188,6 +190,16 @@ class Facts(object):
|
||||
if 'Amazon' in data:
|
||||
self.facts['distribution'] = 'Amazon'
|
||||
self.facts['distribution_version'] = data.split()[-1]
|
||||
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]
|
||||
else:
|
||||
self.facts['distribution'] = name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user