This commit is contained in:
parent
af914695e6
commit
caa0c9d4cc
3 changed files with 10 additions and 2 deletions
|
@ -94,6 +94,8 @@ class DistributionFiles:
|
||||||
'Archlinux': 'Arch Linux'
|
'Archlinux': 'Arch Linux'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STRIP_QUOTES = r'\'\"\\'
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
self.module = module
|
self.module = module
|
||||||
|
|
||||||
|
@ -110,6 +112,7 @@ class DistributionFiles:
|
||||||
|
|
||||||
def _parse_dist_file(self, name, dist_file_content, path, collected_facts):
|
def _parse_dist_file(self, name, dist_file_content, path, collected_facts):
|
||||||
dist_file_dict = {}
|
dist_file_dict = {}
|
||||||
|
dist_file_content = dist_file_content.strip(DistributionFiles.STRIP_QUOTES)
|
||||||
if name in self.SEARCH_STRING:
|
if name in self.SEARCH_STRING:
|
||||||
# look for the distribution string in the data and replace according to RELEASE_NAME_MAP
|
# look for the distribution string in the data and replace according to RELEASE_NAME_MAP
|
||||||
# only the distribution name is set, the version is assumed to be correct from distro.linux_distribution()
|
# only the distribution name is set, the version is assumed to be correct from distro.linux_distribution()
|
||||||
|
|
|
@ -27,6 +27,7 @@ from ansible.module_utils.facts.collector import BaseFactCollector
|
||||||
class LSBFactCollector(BaseFactCollector):
|
class LSBFactCollector(BaseFactCollector):
|
||||||
name = 'lsb'
|
name = 'lsb'
|
||||||
_fact_ids = set()
|
_fact_ids = set()
|
||||||
|
STRIP_QUOTES = r'\'\"\\'
|
||||||
|
|
||||||
def _lsb_release_bin(self, lsb_path, module):
|
def _lsb_release_bin(self, lsb_path, module):
|
||||||
lsb_facts = {}
|
lsb_facts = {}
|
||||||
|
@ -97,5 +98,9 @@ class LSBFactCollector(BaseFactCollector):
|
||||||
if lsb_facts and 'release' in lsb_facts:
|
if lsb_facts and 'release' in lsb_facts:
|
||||||
lsb_facts['major_release'] = lsb_facts['release'].split('.')[0]
|
lsb_facts['major_release'] = lsb_facts['release'].split('.')[0]
|
||||||
|
|
||||||
|
for k, v in lsb_facts.items():
|
||||||
|
if v:
|
||||||
|
lsb_facts[k] = v.strip(LSBFactCollector.STRIP_QUOTES)
|
||||||
|
|
||||||
facts_dict['lsb'] = lsb_facts
|
facts_dict['lsb'] = lsb_facts
|
||||||
return facts_dict
|
return facts_dict
|
||||||
|
|
|
@ -88,7 +88,7 @@ class TestLSBFacts(BaseFactsTest):
|
||||||
self.assertIsInstance(facts_dict, dict)
|
self.assertIsInstance(facts_dict, dict)
|
||||||
self.assertEqual(facts_dict['lsb']['release'], '14.04')
|
self.assertEqual(facts_dict['lsb']['release'], '14.04')
|
||||||
self.assertEqual(facts_dict['lsb']['id'], 'Ubuntu')
|
self.assertEqual(facts_dict['lsb']['id'], 'Ubuntu')
|
||||||
self.assertEqual(facts_dict['lsb']['description'], '"Ubuntu 14.04.3 LTS"')
|
self.assertEqual(facts_dict['lsb']['description'], 'Ubuntu 14.04.3 LTS')
|
||||||
self.assertEqual(facts_dict['lsb']['codename'], 'trusty')
|
self.assertEqual(facts_dict['lsb']['codename'], 'trusty')
|
||||||
|
|
||||||
def test_etc_lsb_release_no_decimal_release(self):
|
def test_etc_lsb_release_no_decimal_release(self):
|
||||||
|
@ -104,5 +104,5 @@ class TestLSBFacts(BaseFactsTest):
|
||||||
self.assertIsInstance(facts_dict, dict)
|
self.assertIsInstance(facts_dict, dict)
|
||||||
self.assertEqual(facts_dict['lsb']['release'], '11')
|
self.assertEqual(facts_dict['lsb']['release'], '11')
|
||||||
self.assertEqual(facts_dict['lsb']['id'], 'AwesomeOS')
|
self.assertEqual(facts_dict['lsb']['id'], 'AwesomeOS')
|
||||||
self.assertEqual(facts_dict['lsb']['description'], '"AwesomeÖS 11"')
|
self.assertEqual(facts_dict['lsb']['description'], 'AwesomeÖS 11')
|
||||||
self.assertEqual(facts_dict['lsb']['codename'], 'stonehenge')
|
self.assertEqual(facts_dict['lsb']['codename'], 'stonehenge')
|
||||||
|
|
Loading…
Reference in a new issue