From 38e73c9c96de8d67222e4b595873416770e864fa Mon Sep 17 00:00:00 2001 From: Damien Date: Mon, 1 Jun 2026 10:45:59 +0200 Subject: [PATCH] Add UFW installation and configuration tasks --- roles/ufw/tasks/main.yml | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/roles/ufw/tasks/main.yml b/roles/ufw/tasks/main.yml index ddbc547..678c54e 100644 --- a/roles/ufw/tasks/main.yml +++ b/roles/ufw/tasks/main.yml @@ -1,3 +1,44 @@ +--- +# roles/ufw/tasks/main.yml + +- name: Install UFW (Alpine) + community.general.apk: + name: ufw + state: present + update_cache: true + when: ansible_facts['os_family'] == "Alpine" + +- name: Install UFW (Debian) + ansible.builtin.apt: + name: ufw + state: present + update_cache: true + when: ansible_facts['os_family'] == "Debian" + +- name: Add UFW to default runlevel (Alpine) + ansible.builtin.command: + cmd: rc-update add ufw default + register: rc_update_result + changed_when: >- + 'already' not in rc_update_result.stdout + and 'already' not in rc_update_result.stderr + failed_when: rc_update_result.rc != 0 + when: ansible_facts['os_family'] == "Alpine" + +- name: Set default incoming policy + community.general.ufw: + default: "{{ ufw_default_incoming_policy }}" + direction: incoming + +- name: Set default outgoing policy + community.general.ufw: + default: "{{ ufw_default_outgoing_policy }}" + direction: outgoing + +- name: Enable UFW + community.general.ufw: + state: enabled + - name: Allow all traffic on Tailscale interface community.general.ufw: rule: allow