Skip to content

Commit

Permalink
last ditch debian release data (ansible#20571)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoca authored Feb 1, 2017
1 parent 91b363e commit 86db15b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/ansible/module_utils/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,18 @@ def get_distribution_Debian(self, name, data, path):
release = re.search("PRETTY_NAME=[^(]+ \(?([^)]+?)\)", data)
if release:
self.facts['distribution_release'] = release.groups()[0]

# Last resort: try to find release from tzdata as either lsb is missing or this is very old debian
if self.facts['distribution_release'] == 'NA' and 'Debian' in data:
dpkg_cmd = self.module.get_bin_path('dpkg')
if dpkg_cmd:
cmd = "%s --status tzdata|grep Provides|cut -f2 -d'-'" % dpkg_cmd
rc, out, err = self.module.run_command(cmd)
if rc == 0:
self.facts['distribution_release'] = out.strip()
elif 'Ubuntu' in data:
self.facts['distribution'] = 'Ubuntu'
pass # Ubuntu gets correct info from python functions
else:
return False # TODO: remove if tested without this
# nothing else to do, Ubuntu gets correct info from python functions

def get_distribution_Mandriva(self, name, data, path):
if 'Mandriva' in data:
Expand Down

0 comments on commit 86db15b

Please sign in to comment.