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

fix lsb fact gathering

was erroring out when rc !=0 also fixed redundant paths
fixes #14965
This commit is contained in:
Brian Coca 2016-03-16 16:59:44 -07:00
parent d7d47bcd75
commit 0cb804f0c2

View file

@ -631,22 +631,20 @@ class Facts(object):
rc, out, err = self.module.run_command([lsb_path, "-a"]) rc, out, err = self.module.run_command([lsb_path, "-a"])
if rc == 0: if rc == 0:
self.facts['lsb'] = {} self.facts['lsb'] = {}
for line in out.split('\n'): for line in out.split('\n'):
if len(line) < 1 or ':' not in line: if len(line) < 1 or ':' not in line:
continue continue
value = line.split(':', 1)[1].strip() value = line.split(':', 1)[1].strip()
if 'LSB Version:' in line: if 'LSB Version:' in line:
self.facts['lsb']['release'] = value self.facts['lsb']['release'] = value
elif 'Distributor ID:' in line: elif 'Distributor ID:' in line:
self.facts['lsb']['id'] = value self.facts['lsb']['id'] = value
elif 'Description:' in line: elif 'Description:' in line:
self.facts['lsb']['description'] = value self.facts['lsb']['description'] = value
elif 'Release:' in line: elif 'Release:' in line:
self.facts['lsb']['release'] = value self.facts['lsb']['release'] = value
elif 'Codename:' in line: elif 'Codename:' in line:
self.facts['lsb']['codename'] = value self.facts['lsb']['codename'] = value
if 'lsb' in self.facts and 'release' in self.facts['lsb']:
self.facts['lsb']['major_release'] = self.facts['lsb']['release'].split('.')[0]
elif lsb_path is None and os.path.exists('/etc/lsb-release'): elif lsb_path is None and os.path.exists('/etc/lsb-release'):
self.facts['lsb'] = {} self.facts['lsb'] = {}
for line in get_file_lines('/etc/lsb-release'): for line in get_file_lines('/etc/lsb-release'):
@ -659,13 +657,10 @@ class Facts(object):
self.facts['lsb']['description'] = value self.facts['lsb']['description'] = value
elif 'DISTRIB_CODENAME' in line: elif 'DISTRIB_CODENAME' in line:
self.facts['lsb']['codename'] = value self.facts['lsb']['codename'] = value
else:
return self.facts
if 'lsb' in self.facts and 'release' in self.facts['lsb']: if 'lsb' in self.facts and 'release' in self.facts['lsb']:
self.facts['lsb']['major_release'] = self.facts['lsb']['release'].split('.')[0] self.facts['lsb']['major_release'] = self.facts['lsb']['release'].split('.')[0]
def get_selinux_facts(self): def get_selinux_facts(self):
if not HAVE_SELINUX: if not HAVE_SELINUX:
self.facts['selinux'] = False self.facts['selinux'] = False