geerlingguy / ansible-role-firewall

Ansible Role - iptables Firewall configuration.
https://galaxy.ansible.com/geerlingguy/firewall/
MIT License
525 stars 217 forks source link

Disable firewalld/ufw service only when appropriate package is installed #33

Closed dmitry-a-l closed 7 years ago

dmitry-a-l commented 7 years ago

When I run playbook on the system without firewalld, I've got an error:

TASK [geerlingguy.firewall : Disable the firewalld service (on RHEL, if configured).] ***
task path: ...roles/geerlingguy.firewall/tasks/disable-other-firewalls.yml:2
...
fatal: [localhost]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "daemon_reload": false,
            "enabled": false,
            "masked": null,
            "name": "firewalld",
            "state": "stopped",
            "user": false
        }
    },
    "msg": "Could not find the requested service firewalld: cannot disable"
}

So I think we must check that firewalld package installed before disabling it.

geerlingguy commented 7 years ago

Makes sense, allows for a little more flexibility in role usage (you don't have to worry about drift between different OS releases, etc.).