--- - name: Check if firewalld package is installed (on RHEL). shell: yum list installed firewalld args: warn: no register: firewalld_installed ignore_errors: true changed_when: false when: ansible_os_family == "RedHat" and firewall_disable_firewalld - name: Disable the firewalld service (on RHEL, if configured). service: name: firewalld state: stopped enabled: no when: ansible_os_family == "RedHat" and firewall_disable_firewalld and firewalld_installed.rc == 0 - name: Check if ufw package is installed (on Ubuntu). shell: service ufw status args: warn: no register: ufw_installed ignore_errors: true changed_when: false when: ansible_distribution == "Ubuntu" and firewall_disable_ufw - name: Disable the ufw firewall (on Ubuntu, if configured). service: name: ufw state: stopped enabled: no when: ansible_distribution == "Ubuntu" and firewall_disable_ufw and ufw_installed.rc == 0 - name: Check if ufw package is installed (on Archlinux). command: pacman -Q ufw args: warn: no register: ufw_installed ignore_errors: true changed_when: false when: ansible_distribution == "Archlinux" and firewall_disable_ufw - name: Disable the ufw firewall (on Archlinux, if configured). service: name: ufw state: stopped enabled: no when: ansible_distribution == "Archlinux" and firewall_disable_ufw and ufw_installed.rc == 0