Refactor scan_packages for os detection

* Use setup facts ansible_os_family for os family detection now.  Add
  support for Suse and it's ilk (which has a pretty ugly OS family
  implementation
This commit is contained in:
Matthew Jones 2015-11-24 14:19:09 -05:00
parent d95470066c
commit a1fbee4fa0
2 changed files with 6 additions and 5 deletions

View File

@ -4,6 +4,7 @@
scan_use_recursive: false
tasks:
- scan_packages:
os_family: '{{ ansible_os_family }}'
- scan_services:
- scan_files:
paths: '{{ scan_file_paths }}'

View File

@ -70,12 +70,12 @@ def deb_package_list():
def main():
module = AnsibleModule(
argument_spec = dict())
ans_dist = get_distribution().strip()
if ans_dist in ('Centos', 'Centos linux', 'Red hat enterprise linux server', 'Amazon', 'Suse linux enterprise server', 'Opensuse'):
os.system('echo "in rpm_package_list for %s" >> /tmp/foo' % ans_dist)
argument_spec = dict(os_family=dict(required=True))
)
ans_os = module.params['os_family']
if ans_os in ('RedHat', 'Suse', 'openSUSE Leap'):
packages = rpm_package_list()
elif ans_dist in ('Ubuntu', 'Debian'):
elif ans_os == 'Debian':
packages = deb_package_list()
else:
packages = None