State every role rule in force with its reason and how it is held. Rules whose control has not landed say "review until #N lands". Keep the file out of the Collection tarball (build_ignore) until the tarball check refuses AGENTS.md at any depth, and put it on the Molecule selector's IGNORED list: no scenario reads it. Closes #181 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
8.4 KiB
8.4 KiB
Role rules
Every rule for a role in this Collection, in full; the contributor docs point here. Each rule gives its reason (Why) and how it is held (Held): a control names its hook or check, review means a person other than the author sees the change before it merges, aspirational means nothing checks it. "Until #N lands" names the backlog issue that will add the control.
Shape
- Layout. Every role has
tasks/main.yml,defaults/main.yml,meta/main.yml,meta/argument_specs.yml,README.mdandmolecule/default/;vars/holds only constants a consumer must not override. Why: one predictable shape, andvars/outranks inventory. Held: control for the scenario (scripts/select_molecule_scenarios.pyfails a changed role without one), review for the rest. - README headings (public roles). Supported platforms; Requirements and run order; Role variables (table); Entry points (when several); Variables set by the role (when any); Tags; Example play; Tests; Notes, with an "Idempotent: yes/no" line. No licence or author heading. Why: a consumer finds the same thing in the same place. Held: review.
- Complexity. ansible-lint's
complexityrule at its defaultmax_tasks(100), gated withwarn_list: []; 40 once ansible-lint accepts the key. Why: a long task file is hard to review. Held: review until #138 lands. - Roadmap. The pull request that adds a role removes it from the README "Roadmap" list, and removes the section when the list is empty. Why: the list is only useful if it is true. Held: review.
Interface
- Role interface. Inputs, supported entry points, documented output facts and documented
tags (the README
## Tagssection). Renaming or removing any of them is abreaking_changesfragment; adding one isminor_changes. Why: this is what a consumer may depend on. Held: review. - Input changes. Renaming or removing an input is
breaking_changesand a major release, with no compatibility alias. Why: with latest-only support an alias costs more than it gives. Held: review until the fragment check (#183) lands. - argument_specs. Every optional input has a value in
defaults/main.ymland a spec entry withtype,descriptionand the samedefault:;choicesfor closed sets; arequired: trueinput has no default. Why: a specdefault:never sets the variable, but without itansible-doc -t roleshowsnull. Held: review until the spec-defaults drift check (#135) lands. - Suboption defaults. The role applies them itself; spec suboption defaults are documentation. Why: Ansible does not apply them. Held: review until #135 lands.
- Supported entry points. Each has its own
meta/argument_specs.ymlkey, an "Entry points" README entry and a Molecule scenario; every othertasks/*.ymlis internal. Why: a consumer must be able to tell what it may call. Held: review until #227 lands. - Output facts. A fact documented under "Variables set by the role" keeps
<role>_; everything else a role sets or registers is__<role>_. Why: the name says what is interface. Held: review. - Handlers are internal. A caller never notifies a role's handler; a README names one only to explain behaviour; renaming one needs no fragment. Why: handler names are global in a play, so a caller bound to one breaks on a rename. Held: review.
Variables and validation
- Internal variables.
vars/constants,register:andset_factresults are__<role>_. Why: it is the Red Hat Automation Good Practices convention and tells an input from an internal name. Held: ansible-lintvar-naming[no-role-prefix]for the prefix, review for the__. - Validation. The spec holds
type,choicesandrequired; a rule between role variables is anassertintasks/validate.yml; cross-input spec keys (required_if,mutually_exclusiveand the like) appear only inside a dict input's suboptions. Why: Ansible does not apply them at entry-point level. Held: ansible-lint for the misuse, review for the rest. - Validation order.
validate.ymlruns before any task that changes the host, loaded withimport_tasksandtags: always; only fact-computing tasks run before it, and they carryalwaystoo. Why: a bad input fails before any change, andalwaysoninclude_tasksdoes not reach the included tasks. Held: review. noqa. Prefer fixing a finding; anoqathat remains names one rule and has a reason comment. Why: an unexplained exception cannot be reviewed. Held: review.- Secrets. Never in plaintext in the repository, a role's defaults, task output or a file on
the controller;
no_log: trueon every task that carries one; a secret is a required input with no default; a role generates one only straight into a secret store the consumer names. Keys a host generates for itself and keeps (SSH host keys) are not covered. The README line "no_logis not used: the role handles no secrets" stays only where true. Why: nothing leaks today and a role writing to a secret store stays possible. Held: review.
Platforms
- Declared means tested. A platform in
meta/main.ymlis one the role passes Molecule on in CI; one used but untested goes only in a README "Untested platforms" line. Until #226 and #133 land,trixieis declared untested and some roles still declarejammyorall. Why: no tool reads the declaration, so it is worth something only if true. Held: review. - Platforms follow the target hosts. Ubuntu-targeting roles declare exactly
nobleandresolute; Proxmox-targeting roles declare Debiantrixie; each is tested on its own OS. Why: testing on hosts a role never runs on proves nothing. Held: review. Aspirational: every role covers all three; fewer needs a one-line README reason. - Dropping a platform. Removing or narrowing a declared platform is
breaking_changes, tested or not. Why: a consumer on it loses support. Held: review until #183 lands.
Tests
- Verify asserts the effect on the host (the service loaded the config), not only rendered files. Why: a rendered file proves nothing about a running service. Held: review.
- Negative tests. Every validation has one in
verify.yml(or a file it includes): block/rescue/assert matching the expected error message. Why: a bare "it failed" passes for the wrong error. Held: review. - Check mode. Every scenario runs
checkbefore and after converge. The only guards arecheck_mode: falseon read-only probes andwhen: not ansible_check_mode;--checkis the supported preview, and the README says a play-levelcheck_mode: trueis not supported. A role that cannot support check mode says why in README Notes and drops the step. Why: check-mode breakage is a common fix class, and one guard pattern is reviewable. Held: review until #134 lands.
Roles calling roles
- Dependencies. A role uses another role of this Collection only through
ansible.builtin.include_roleorimport_roleby FQCN, never a role outside the Collection, and lists it in its README;meta/main.ymldependenciesstays[]. It calls a public role only on a supported entry point, an internal role on any entry point in its argument_specs. Why: a task-level include keeps the order readable, wheremetadependencies run hidden and deduplicated. Held: control for the scenarios (the selector runs a dependent role's scenarios when a role it uses changes), review for emptydependenciesuntil #246 lands. - Internal roles. A leading
_; only roles of this Collection call it, by FQCN; it refuses to run without a parent role (anassertonansible_parent_role_names, as in_binary_update); it has argument_specs, Molecule scenarios and follows the platform rules. Its README opens with the internal-role statement and otherwise keeps its own headings. Its variables keep_<role>_with no__split. It is outside semver: a change confined to it takes atrivialfragment, and the calling role writes the fragment for any effect a consumer can see. Why: shared machinery without a versioning promise. Held: the assert at run time; review that each new internal role has it. role-namefor internal roles. Each internal role has onerole-nameline in.ansible-lint-ignore. Until #138 landsrole-nameis skipped repository-wide in.ansible-lint. Why: a misnamed public role must still fail. Held: review.