1
0
IaC/ansible/roles/ufw/tasks/main.yaml

34 lines
751 B
YAML
Raw Normal View History

2024-04-20 09:04:17 -04:00
- name: Install ufw package (Archlinux)
when: ansible_facts['os_family'] == "Archlinux"
community.general.pacman:
name:
- ufw
state: present
update_cache: true
- name: Add ufw rules
community.general.ufw:
comment: "{{ item.name }}"
direction: 'in'
from_ip: "{{ item.source }}"
proto: "{{ item.protocol }}"
rule: "{{ item.action }}"
to_ip: "{{ item.destination }}"
to_port: "{{ item.port }}"
loop: "{{ ufw_rules }}"
- name: Enable ufw
when: ufw_enabled
community.general.ufw:
default: "deny"
direction: "incoming"
logging: "low"
state: enabled
- name: Enable the ufw service
when: ufw_enabled
ansible.builtin.service:
name: ufw
state: restarted
enabled: true