Merge pull request #4886 from sergeyhush/devel
fix when the system does not have lsb_release script, but has /etc/lsb_release file
This commit is contained in:
commit
91f903eabe
1 changed files with 46 additions and 25 deletions
|
@ -381,8 +381,7 @@ class Facts(object):
|
|||
|
||||
def get_lsb_facts(self):
|
||||
lsb_path = module.get_bin_path('lsb_release')
|
||||
if lsb_path is None:
|
||||
return self.facts
|
||||
if lsb_path:
|
||||
rc, out, err = module.run_command([lsb_path, "-a"])
|
||||
if rc == 0:
|
||||
self.facts['lsb'] = {}
|
||||
|
@ -402,6 +401,28 @@ class Facts(object):
|
|||
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'):
|
||||
self.facts['lsb'] = {}
|
||||
f = open('/etc/lsb-release', 'r')
|
||||
try:
|
||||
for line in f.readlines():
|
||||
value = line.split('=',1)[1].strip()
|
||||
if 'DISTRIB_ID' in line:
|
||||
self.facts['lsb']['id'] = value
|
||||
elif 'DISTRIB_RELEASE' in line:
|
||||
self.facts['lsb']['release'] = value
|
||||
elif 'DISTRIB_DESCRIPTION' in line:
|
||||
self.facts['lsb']['description'] = value
|
||||
elif 'DISTRIB_CODENAME' in line:
|
||||
self.facts['lsb']['codename'] = value
|
||||
finally:
|
||||
f.close()
|
||||
else:
|
||||
return self.facts
|
||||
|
||||
if 'lsb' in self.facts and 'release' in self.facts['lsb']:
|
||||
self.facts['lsb']['major_release'] = self.facts['lsb']['release'].split('.')[0]
|
||||
|
||||
|
||||
def get_selinux_facts(self):
|
||||
if not HAVE_SELINUX:
|
||||
|
|
Loading…
Reference in a new issue