|
32 | 32 | reload: true |
33 | 33 | when: ansible_facts['all_ipv6_addresses'] | length > 0 |
34 | 34 |
|
35 | | -- name: Handle modern nftables/iptables-nft stack (Arch Linux ARM 6.18+) |
| 35 | +- name: Handle modern nftables/iptables-nft stack (Arch Linux 6.18+) |
36 | 36 | when: |
37 | 37 | - ansible_facts['distribution'] == 'Archlinux' |
38 | 38 | - ansible_facts['kernel'] is version('6.18', '>=') |
|
48 | 48 | force: true |
49 | 49 | when: |
50 | 50 | - "'iptables' in ansible_facts.packages" |
51 | | - - "'iptables-nft' not in ansible_facts.packages" |
52 | 51 |
|
53 | 52 | - name: Install iptables-nft and nftables |
54 | 53 | community.general.pacman: |
|
57 | 56 | - nftables |
58 | 57 | state: present |
59 | 58 |
|
60 | | - - name: Ensure nftables is enabled and started |
61 | | - ansible.builtin.systemd: |
62 | | - name: nftables |
63 | | - state: started |
64 | | - enabled: true |
| 59 | + - name: Check nftables service |
| 60 | + ansible.builtin.service_facts: |
| 61 | + |
| 62 | + - name: Configure nftables include and K3s rules fragment |
| 63 | + when: |
| 64 | + - ansible_facts.services['nftables.service'] is defined |
| 65 | + - ansible_facts.services['nftables.service'].status == 'enabled' |
| 66 | + block: |
| 67 | + - name: Ensure nftables include directory exists |
| 68 | + ansible.builtin.file: |
| 69 | + path: /etc/nftables.d |
| 70 | + state: directory |
| 71 | + mode: "0755" |
| 72 | + |
| 73 | + - name: Ensure nftables loads /etc/nftables.d rules |
| 74 | + ansible.builtin.lineinfile: |
| 75 | + path: /etc/nftables.conf |
| 76 | + regexp: '^include "/etc/nftables\\.d/\\*\\.nft"$' |
| 77 | + line: 'include "/etc/nftables.d/*.nft"' |
| 78 | + insertafter: EOF |
| 79 | + |
| 80 | + - name: Install K3s nftables rules fragment |
| 81 | + ansible.builtin.template: |
| 82 | + src: k3s.nft.j2 |
| 83 | + dest: /etc/nftables.d/k3s.nft |
| 84 | + mode: "0644" |
| 85 | + notify: Reload nftables |
65 | 86 |
|
66 | 87 | - name: Populate service facts |
67 | 88 | ansible.builtin.service_facts: |
|
0 commit comments