Files
Kamino/roles/ufw/tasks/sysctl.yml
T
Defame1297 22f5bc33e9
Build / build (pull_request) Successful in 28s
Molecule / select (pull_request) Successful in 12s
Lint / lint (pull_request) Successful in 3m0s
Molecule / Result (pull_request) Canceled after 0s
Molecule / scenarios (pull_request) Canceled after 18m22s
chore: correct comments the ci image change left stale
image.yml's push paths listed extensions/molecule/requirements.yml under
the ci image, which no longer bakes it; it now sits with the
molecule-controller files. The list only triggers the build, so the paths
are unchanged. requirements-dev.txt no longer feeds Molecule, so the
proxmoxer comment names lint only. The ufw probe comments now say the
probe's stdout is empty in check mode, in two lines each, and two lines
in lint.yml and the workflow rules are re-wrapped.

Assisted-by: Claude Code
2026-12-02 09:26:03 +00:00

37 lines
1.3 KiB
YAML

---
- name: Check whether ufw sysctl.conf exists
become: true
ansible.builtin.stat:
path: /etc/ufw/sysctl.conf
register: ufw_sysctl_stat
check_mode: false
when: ufw_enabled and ufw_sysctl_overrides | length > 0
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode.
- name: Probe whether the run is in check mode
ansible.builtin.command: echo ran
register: ufw_sysctl_probe
changed_when: false
when: ufw_enabled and ufw_sysctl_overrides | length > 0
- name: Remember whether the run is in check mode
ansible.builtin.set_fact:
ufw_sysctl_check: "{{ ufw_sysctl_probe.stdout != 'ran' }}"
when: ufw_enabled and ufw_sysctl_overrides | length > 0
# In check mode on a fresh host ufw is not installed yet, so the file is absent.
- name: Set sysctl overrides in ufw sysctl.conf
become: true
ansible.builtin.lineinfile:
path: /etc/ufw/sysctl.conf
regexp: '^#?\s*{{ ufw_sysctl_override.name }}='
line: "{{ ufw_sysctl_override.name }}={{ ufw_sysctl_override.value }}"
owner: root
group: root
mode: "0644"
loop: "{{ ufw_sysctl_overrides }}"
loop_control:
loop_var: ufw_sysctl_override
when: ufw_enabled and (ufw_sysctl_stat.stat.exists or not ufw_sysctl_check)