From 60e815c8444eb4df8e67155695b3565b2ae24ebe Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Wed, 7 Jan 2015 19:07:12 -0500 Subject: [PATCH] Set ansible_distribution_version differently for Solaris variants. --- lib/ansible/module_utils/facts.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 1c2ebb9a7d6..73cba20aa3b 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -323,18 +323,27 @@ class Facts(object): break uname_rc, uname_out, uname_err = module.run_command(['uname', '-v']) + distribution_version = None if 'SmartOS' in data: self.facts['distribution'] = 'SmartOS' + if os.path.exists('/etc/product'): + product_data = dict([l.split(': ', 1) for l in get_file_content('/etc/product').split('\n') if ': ' in l]) + if 'Image' in product_data: + distribution_version = product_data.get('Image').split()[-1] elif 'OpenIndiana' in data: self.facts['distribution'] = 'OpenIndiana' elif 'OmniOS' in data: self.facts['distribution'] = 'OmniOS' + distribution_version = data.split()[-1] elif uname_rc == 0 and 'NexentaOS_' in uname_out: self.facts['distribution'] = 'Nexenta' + distribution_version = data.split()[-1].lstrip('v') - if self.fact['distribution'] in ('SmartOS', 'OpenIndiana', 'OmniOS', 'Nexenta'): + if self.facts['distribution'] in ('SmartOS', 'OpenIndiana', 'OmniOS', 'Nexenta'): self.facts['distribution_release'] = data.strip() - if uname_rc == 0: + if distribution_version is not None: + self.facts['distribution_version'] = distribution_version + elif uname_rc == 0: self.facts['distribution_version'] = uname_out.split('\n')[0].strip() break