From e69fdfa79b4fd976be891147ece4095fc8c61371 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 24 Nov 2015 11:20:27 -0500 Subject: [PATCH] Improvements to the package scanner * Support Amazon (because it's RH based) * Switch to using module_utils's get_distribution() method for more efficient distro detection --- awx/plugins/library/scan_packages.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/awx/plugins/library/scan_packages.py b/awx/plugins/library/scan_packages.py index 8077cfe45d..b7398ab202 100755 --- a/awx/plugins/library/scan_packages.py +++ b/awx/plugins/library/scan_packages.py @@ -72,14 +72,18 @@ def main(): module = AnsibleModule( argument_spec = dict()) - packages = [] - # TODO: module_utils/basic.py in ansible contains get_distribution() and get_distribution_version() - # which can be used here and is accessible by this script instead of this basic detector. - if os.path.exists("/etc/redhat-release"): + ans_dist = get_distribution() + if ans_dist in ('Centos', 'Centos linux', 'Red hat enterprise linux server', 'Amazon'): packages = rpm_package_list() - elif os.path.exists("/etc/os-release"): + elif ans_dist in ('Ubuntu'): packages = deb_package_list() - results = dict(ansible_facts=dict(packages=packages)) + else: + packages = None + + if packages is not None: + results = dict(ansible_facts=dict(packages=packages)) + else: + results = dict(skipped=True, msg="Unsupported Distribution") module.exit_json(**results) main()