From 86db15b105b09c8dbce3b5a713069ff978f87828 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 1 Feb 2017 13:15:02 -0500 Subject: [PATCH] last ditch debian release data (#20571) fixes #10445 --- lib/ansible/module_utils/facts.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index ca5120a888..9903595c2a 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -931,11 +931,18 @@ class Distribution(object): 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: