Compare commits

...

4 Commits

Author SHA1 Message Date
6e33ac688c Merge pull request 'feat/ufw_implementation' (#2) from feat/ufw_implementation into main
Reviewed-on: #2
2026-06-01 08:49:12 +00:00
Damien
5768492bd3 Update UFW rc-update changed condition 2026-06-01 10:48:05 +02:00
Damien
38e73c9c96 Add UFW installation and configuration tasks 2026-06-01 10:45:59 +02:00
Damien
19c5371601 Update homelab playbook and UFW role
Change hosts target from online to managed
Add tags to UFW role tasks
Set default UFW policies
Allow traffic on Tailscale interface
2026-06-01 10:21:18 +02:00
3 changed files with 55 additions and 4 deletions

View File

@@ -1,11 +1,15 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/playbook.json # yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/playbook.json
--- ---
- name: Homelab alignment - name: Homelab alignment
hosts: online hosts: managed
become: true become: true
roles: roles:
- role: repos
- role: common
- role: ufw - role: ufw
tags: ufw
- role: repos
tags: repos
- role: upgrade - role: upgrade
tags: upgrade

View File

@@ -1,4 +1,5 @@
# roles/ufw/defaults/main.yml # roles/ufw/defaults/main.yml
--- ---
ufw_default_incoming_policy: deny
ufw_default_outgoing_policy: allow
ufw_tailscale_interface: tailscale0 ufw_tailscale_interface: tailscale0
ufw_extra_rules: []

View File

@@ -0,0 +1,46 @@
---
# 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: >- # ">- : transform multiple lines into one line"
'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
interface: "{{ ufw_tailscale_interface }}"
direction: in