| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- ---
- - name: "Update firewall rules for Zabbix agent"
- hosts: all
- gather_facts: True
- become: true
- tasks:
- - name: Gather package facts
- package_facts:
- manager: auto
- - name: Populate systemd service_facts
- service_facts:
- #
- #################################
- # Determine and set the firewall method
- - name: Set variable to indicate which firewall method is being used by a systemd
- set_fact:
- FW_METHOD: "ufw"
- when: "'ufw' in ansible_facts.packages"
- - name: Set variable to indicate which firewall method is being used by a systemd
- set_fact:
- FW_METHOD: "iptables"
- when: "'iptables' in ansible_facts.packages"
- - name: Set variable to indicate which firewall method is being used by a systemd
- set_fact:
- FW_METHOD: "firewalld"
- when:
- - ansible_facts.distribution_file_variety != "Debian"
- - ansible_facts.services['firewalld.service']['status'] == 'enabled' or ansible_facts.services['firewalld.service']['status'] == 'running'
- - name: Set variable to indicate which firewall method is being used by a systemd
- set_fact:
- FW_METHOD: "firewalld"
- when:
- - ansible_facts.distribution_file_variety != "Debian"
- - ansible_facts.services['iptables.service']['status'] == 'enabled' or ansible_facts.services['iptables.service']['status'] == 'running'
- - name: Show value of FW_METHOD
- debug:
- msg: FW_METHOD is "{{ FW_METHOD }}"
|