fix(ufw, fail2ban): pass --check on a host without the package
Under --check the package task only reports a change, so on a fresh host the tasks after it ran against a missing binary, /etc directory or unit and failed. They now skip when the install would change in check mode. fail2ban registers __fail2ban_install and guards its template, service, config test, jail tasks and handler with the standard `not ansible_check_mode or ... is not changed` guard. ufw registers __ufw_install plus a command probe (ansible_check_mode is not set for a play-level check_mode inside include_role), combined once in vars/main.yml as __ufw_can_configure. flush_handlers is left unguarded: the handler it runs is guarded itself. A check-absent scenario per role purges the package, refreshes the APT cache and runs only `check`, so each fix is tested; one scenario covering both would make the ufw role a user of fail2ban and select the ufw and traefik scenarios on every fail2ban change. Fixes #478 Assisted-by: Claude Code
This commit is contained in:
1 parent
0173f6f226
commit
924a0ea7a7
20 files changed
+234
-9
No files matched your search
@@ -1,2 +1,5 @@
|
||||
---
|
||||
ufw_package_name: ufw
|
||||
# False only when a check-mode run would install ufw: the binary and /etc/ufw are then missing, so
|
||||
# the tasks that need them are skipped. True when install.yml did not run (its tags were skipped).
|
||||
__ufw_can_configure: "{{ __ufw_install | default({}) is not changed or __ufw_install_probe is not skipped }}"
|
||||
Reference in new issue
Block a user