Collect packge info in the repo, not in python

There is no need for a python fact collector, just do it in ansible
commands instead
This commit is contained in:
Eric Paris 2015-04-03 12:00:33 -04:00
parent c4241fb2ae
commit 0166392cfe
3 changed files with 32 additions and 39 deletions

View File

@ -1,37 +0,0 @@
#!/usr/bin/python
import subprocess
import re
def main():
module = AnsibleModule(
argument_spec = dict(
),
)
facts = {}
result = {}
result['rc'] = 0
result['changed'] = False
result['ansible_facts'] = facts
args = ("rpm", "-q", "firewalld")
popen = subprocess.Popen(args, stdout=subprocess.PIPE)
rc = popen.wait()
facts['has_firewalld'] = False
if rc == 0:
facts['has_firewalld'] = True
args = ("rpm", "-q", "iptables-services")
popen = subprocess.Popen(args, stdout=subprocess.PIPE)
rc = popen.wait()
facts['has_iptables'] = False
if rc == 0:
facts['has_iptables'] = True
module.exit_json(**result)
# import module snippets
from ansible.module_utils.basic import *
main()

View File

@ -13,6 +13,6 @@
is_atomic: true
when: s.stat.exists
- name: Collect fact about what RPM's are installed
rpm_facts:
# collect information about what packages are installed
- include: rpm.yml
when: ansible_pkg_mgr == "yum"

View File

@ -0,0 +1,30 @@
---
- name: Determine if firewalld installed
command: "rpm -q firewalld"
register: s
changed_when: false
failed_when: false
- name: Init the has_firewalld fact
set_fact:
has_firewalld: false
- name: Set the has_firewalld fact
set_fact:
has_firewalld: true
when: s.rc == 0
- name: Determine if iptables-services installed
command: "rpm -q iptables-services"
register: s
changed_when: false
failed_when: false
- name: Init the has_iptables fact
set_fact:
has_iptables: false
- name: Set the has_iptables fact
set_fact:
has_iptables: true
when: s.rc == 0