fix Amazon system-release version parsing (#51521)

Previously it was assumed that the Amazon system-release
number was the final value of the string.  This isn't always
the case.  Some releases have the name at the end.

  Amazon Linux release 2
  Amazon Linux release 2 (Karoo)

Fix by instead looking for a number in the string.

Fixes #48823
pull/51920/head
Jeremiah Mahler 6 years ago committed by ansibot
parent c1e51ef486
commit ffbc9d99de

@ -0,0 +1,2 @@
bugfixes:
- Fix Amazon system-release version parsing (https://github.com/ansible/ansible/issues/48823)

@ -228,10 +228,11 @@ class DistributionFiles:
def parse_distribution_file_Amazon(self, name, data, path, collected_facts): def parse_distribution_file_Amazon(self, name, data, path, collected_facts):
amazon_facts = {} amazon_facts = {}
if 'Amazon' not in data: if 'Amazon' not in data:
# return False # TODO: remove # huh? return False, amazon_facts
return False, amazon_facts # TODO: remove
amazon_facts['distribution'] = 'Amazon' amazon_facts['distribution'] = 'Amazon'
amazon_facts['distribution_version'] = data.split()[-1] version = [n for n in data.split() if n.isdigit()]
version = version[0] if version else 'NA'
amazon_facts['distribution_version'] = version
return True, amazon_facts return True, amazon_facts
def parse_distribution_file_OpenWrt(self, name, data, path, collected_facts): def parse_distribution_file_OpenWrt(self, name, data, path, collected_facts):

Loading…
Cancel
Save