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
This commit is contained in:
Matthew Jones 2015-11-24 11:20:27 -05:00
parent 68d7119337
commit e69fdfa79b

View File

@ -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()