mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
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:
parent
c4241fb2ae
commit
0166392cfe
@ -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()
|
@ -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"
|
||||
|
30
contrib/ansible/roles/common/tasks/rpm.yml
Normal file
30
contrib/ansible/roles/common/tasks/rpm.yml
Normal 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
|
Loading…
Reference in New Issue
Block a user