refactor(roles): validate through validate.yml, and prefix internal variables with __ROLE_ #137
Notifications
Due Date
No due date set.
Blocks
Depends on
Reference: Mortis/Kamino#137
Reference in new issue
Block a user
Spec: Role standard, resolution comment, "Validation", "Naming" and "Scenario". Scope also from Role standard gaps found in review and Role interface and semver: output facts, handler names, dropped platforms and internal roles.
Blocked by #271: the check-mode issue deletes the
ufwprobe tasks and theirufw_*_probeandufw_*_checkvariables intasks/sysctl.yml,tasks/orphan_rules.ymlandtasks/service_rules.yml. Those variables are gone by the time this issue is built, so there is nothing to rename there.What
assertintasks/validate.yml. Do not express cross-input rules with spec keys:required_if,mutually_exclusive,required_togetherandrequired_one_ofare used only inside a dict input's suboptions. ansible-core ignores them at entry-point level and ansible-lint refuses them there. Movesystemd_hardening's inline asserts out ofmain.ymlanddropins.ymlintovalidate.yml.validate.ymlwithimport_tasksandtags: alwaysin every role, and put it before every task that changes the host (only fact-computing tasks may come first).fail2banimportsvalidate.ymlbeforeinstall.yml.ufw's order becomes stray-guard, aggregate, validate, install, sysctl and so on. The aggregate tasks are also taggedalways, becausevalidate.ymlreadsufw_aggregated_rules.sshdloadsvalidate.ymlwithimport_tasksinstead ofinclude_tasks.bugfixeschangelog fragment: a bad input now fails before packages or sysctl change.<role>_to__<role>_in every role, along with their uses in templates, handlers and molecule. This coversregister,set_factandvars/constants (ufw_package_nametoo). ansible-lint holds only the prefix; the__is held by review. A registered variable is not part of the interface.<role>_:system_baseline_reboot_required,user_management_all_users,user_management_managed_usernames. Every otherset_factorregisteris renamed to__<role>_(for exampletraefik_installed_version,traefik_update_required,docker_candidates,ufw_oa_*).__split in an internal role._binary_updatekeeps_binary_update_*for all its variables. Leave it unchanged.user_managementis in scope.roles/system_baseline/tasks/tmux.yml. It is internal, but a consumer calls it until #186 is triaged.validate.yml:system_baselineupdateandreboot,ufwservice_rulesandorphan_rules,fail2banservice_jail. Their specs and tests are #227, which follows this issue.noqa. Try replacing thesystemd_hardeningcommand-instead-of-modulewithansible.builtin.service_facts; keep thenoqaonly if that does not work. Every remainingnoqanames one rule and has a reason comment.user_managementtask carryinguser_management_become_password_hashedsetsno_log: true, and fix it if not. Check thatsshd's README states its secrets position.verify.yml(or a file it includes) as block/rescue/assert, matching the expected error message, run last or failing before any change. Existing tests that only assert "it failed" are tightened.Acceptance
Molecule and ansible-lint pass. Apart from validation now failing before any host change (with the
bugfixesfragment), no role changes what it does on a host.refactor(roles): validate through spec keys and validate.yml, and prefix internal variables with __<role>_to refactor(roles): validate through spec keys and validate.yml, and prefix internal variables with __ROLE_Correction from What a role's platform declaration means, and supported entry points:
validate.yml, keep the documented entry points (system_baselineupdateandreboot,ufwservice_rules) working. Giving them specs and tests is #227, which follows this issue.roles/system_baseline/tasks/tmux.yml. It is internal, but a consumer calls it until #186 is triaged.Scope added by Role standard gaps found in review (resolution comment, rules 1, 2, 3 and 7):
__<role>_coversregister,set_factandvars/constants (ufw_package_nametoo). ansible-lint holds only the prefix; the__is held by review.validate.ymlbeforeinstall.yml; ufw's order becomes stray-guard → aggregate → validate → install → sysctl → … with the aggregate tasks also taggedalways(validate readsufw_aggregated_rules); sshd loadsvalidate.ymlwithimport_tasksinstead ofinclude_tasks. Load it withimport_tasksandtags: alwaysin every role. Add abugfixesfragment: a bad input now fails before packages or sysctl change.noqa: try replacing thesystemd_hardeningcommand-instead-of-modulewithansible.builtin.service_facts; keep thenoqaonly if that does not work. Every remainingnoqanames one rule and has a reason comment.user_managementtask carryinguser_management_become_password_hashedsetsno_log: true, and fix it if not; checksshd's README states its secrets position.Review of the map (2026-11-17).
assertintasks/validate.yml;required_if,mutually_exclusive,required_togetherandrequired_one_ofare used only inside a dict input's suboptions. Ansible ignores them at entry-point level and ansible-lint refuses them there (reproduced on ansible-core 2.22.0 and ansible-lint 26.10.1; see the note on Role standard).system_baselineupdateandrebootandufwservice_rules. The full list is:system_baselineupdate,reboot;ufwservice_rules,orphan_rules;fail2banservice_jail. Keep all five working.set_fact, but three facts are documented for consumers:system_baseline_reboot_required,user_management_all_users,user_management_managed_usernames. Renaming them breaks callers, while the acceptance says "No role changes what it does on a host." Do not rename a fact a role README documents until Role interface and semver: output facts, handler names, dropped platforms and internal roles is answered.roles/holds eight roles now;user_managementis in scope.Changed: this issue is now blocked by that ticket.
Proposed, not done: title "refactor(roles): validate through validate.yml, and prefix internal variables with _ROLE".
Scope change from Role interface and semver: output facts, handler names, dropped platforms and internal roles (2026-11-20)
system_baseline_reboot_required,user_management_all_users,user_management_managed_usernames. A fact a role documents under "Variables set by the role" is interface and keeps<role>_. Every otherset_factorregisteris renamed to__<role>_(for exampletraefik_installed_version,traefik_update_required,docker_candidates,ufw_oa_*).__split in an internal role:_binary_updatekeeps_binary_update_*for all its variables. Leave it unchanged.refactor(roles): validate through spec keys and validate.yml, and prefix internal variables with __ROLE_to refactor(roles): validate through validate.yml, and prefix internal variables with __ROLE_Final validation round, second pass (2026-11-20): body edited.
validate.yml; spec keys only inside dict suboptions.import_tasks,tags: always), with thebugfixesfragment; acceptance adjusted to match.<role>_; internal roles have no__split.tmux.ymlnot renamed;noqaand secrets checks folded in.ufwprobe and check variables this issue would otherwise rename.The comments above stay as history.