Copied from the environment repository's local role. The files are identical except: galaxy namespace mortis; comments, argument_specs descriptions and the README scrubbed of environment references (issue numbers, CI runs, playbooks, inventory paths and groups, scripts and caller roles by name), with the technical explanation kept and reworded generically; the stray-variable guard's fail message drops its issue reference; the molecule scenario calls the role by its FQCN (mortis.kamino.ufw), follows the Kamino scenario conventions (kamino-molecule header, scenario.test_sequence) and no longer sets ANSIBLE_COLLECTIONS_PATH or ANSIBLE_ROLES_PATH. No variable, default, argument_specs type or task logic changed; the test coverage is the same. The README follows the other Kamino roles: purpose, the main, service_rules and orphan_rules entry points, variables, and example plays with the FQCN and tasks_from. The meta licence stays GPL-3.0-or-later AND GPL-3.0-only (templates/before.rules.j2 is derived from ufw's own file, already annotated in REUSE.toml and NOTICE). galaxy.yml's dependency comment names ufw as a community.general user. Not verified locally: the molecule scenario (it runs on the kamino-molecule runner in CI) and ansible-test sanity. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
32 lines
1004 B
YAML
32 lines
1004 B
YAML
---
|
|
# community.general.ufw runs `ufw -f enable` and `ufw logging` unconditionally
|
|
# (rewriting /etc/ufw/user.rules and re-applying sysctl.conf), so only call it
|
|
# when UFW is inactive or its logging setting differs from ufw_logging.
|
|
- name: Read current UFW status
|
|
become: true
|
|
ansible.builtin.command: ufw status verbose
|
|
register: ufw_status_verbose
|
|
changed_when: false
|
|
check_mode: false
|
|
environment:
|
|
LC_ALL: C
|
|
LANGUAGE: C
|
|
when: ufw_enabled
|
|
|
|
- name: Enable UFW
|
|
become: true
|
|
community.general.ufw:
|
|
state: enabled
|
|
logging: "{{ ufw_logging }}"
|
|
vars:
|
|
# "on" matches any level ("Logging: on (low)"); "off" and levels match exactly.
|
|
ufw_logging_expected: >-
|
|
{{ 'Logging: off' if ufw_logging == 'off'
|
|
else 'Logging: on' if ufw_logging == 'on'
|
|
else 'Logging: on (' ~ ufw_logging ~ ')' }}
|
|
when:
|
|
- ufw_enabled
|
|
- >-
|
|
'Status: active' not in ufw_status_verbose.stdout
|
|
or ufw_logging_expected not in ufw_status_verbose.stdout
|