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
53 lines
2.0 KiB
YAML
53 lines
2.0 KiB
YAML
---
|
|
# Stray variable guard: the role does not discover rules by variable name, so a variable
|
|
# named like <role>_ufw_rules / <role>_ufw_before_rules would be silently ignored. Fail instead,
|
|
# naming it. The base lists ufw_rules and ufw_before_rules have no prefix before "_ufw_" and do not
|
|
# match; the producers' <role>_ufw_service_rules do not either. varnames covers every variable
|
|
# visible to the host (inventory, play, role and extra vars), unlike the deprecated vars dictionary.
|
|
- name: Refuse stray *_ufw_rules and *_ufw_before_rules variables
|
|
ansible.builtin.assert:
|
|
that: ufw_stray_rule_variables | length == 0
|
|
fail_msg: >-
|
|
ufw does not read variables named like *_ufw_rules or *_ufw_before_rules, so they would
|
|
be ignored: {{ ufw_stray_rule_variables | join(', ') }}. Pass the rules of a service through
|
|
the ufw role's tasks_from: service_rules entry point (ufw_service_name and ufw_service_rules),
|
|
or move base rules into ufw_rules. Delete or rename the leftover definition in group_vars,
|
|
host_vars or the play.
|
|
quiet: true
|
|
vars:
|
|
ufw_stray_rule_variables: >-
|
|
{{ lookup('ansible.builtin.varnames', '^.+_ufw_(before_)?rules$', wantlist=True) | sort }}
|
|
tags: [ufw, always]
|
|
|
|
- name: Import UFW install task
|
|
ansible.builtin.import_tasks: install.yml
|
|
tags: [ufw, ufw_install]
|
|
|
|
- name: Import UFW sysctl task
|
|
ansible.builtin.import_tasks: sysctl.yml
|
|
tags: [ufw, ufw_sysctl]
|
|
|
|
- name: Import UFW aggregate task
|
|
ansible.builtin.import_tasks: aggregate_rules.yml
|
|
tags: [ufw, ufw_aggregate]
|
|
|
|
- name: Import UFW validate task
|
|
ansible.builtin.import_tasks: validate.yml
|
|
tags: [ufw, ufw_validate]
|
|
|
|
- name: Import UFW before rules task
|
|
ansible.builtin.import_tasks: before_rules.yml
|
|
tags: [ufw, ufw_before_rules]
|
|
|
|
- name: Import UFW defaults task
|
|
ansible.builtin.import_tasks: defaults.yml
|
|
tags: [ufw, ufw_defaults]
|
|
|
|
- name: Import UFW rules task
|
|
ansible.builtin.import_tasks: rules.yml
|
|
tags: [ufw, ufw_rules]
|
|
|
|
- name: Import UFW enable task
|
|
ansible.builtin.import_tasks: enable.yml
|
|
tags: [ufw, ufw_enable]
|