- name: Install UFW.
apt:
name: ufw
state: present
- name: Setup default firewall rules.
command: "ufw {{ item }}"
with_items:
- default deny incoming on eth0
- default allow outgoing on eth0
- default allow incoming on eth1
- default allow outgoin on eth1
- default allow FORWARD
- allow ssh
- name: Set up custom firewall rules.
command: "ufw {{ item }}"
with_items: firewall_rules
- name: Start UFW.
command: ufw --force enable # Force flag used to skip `are you sure` query.