Files
computer-playbook/tests/lint/ansible/variables/README.md
T
kevinveenbirkenbachandClaude Opus 4.7 16bdbf03d7 docs: fix repo-wide drift against documentation.md style rules
Three classes of drift cleaned up across 85 .md files:

- Em-dashes: replaced ` — ` with the contextually correct separator
  (colon for `term: explanation`, period to split clauses across
  sentences/source lines, parentheses for asides, semicolon for
  tight-linked continuations). Two intentional exceptions remain
  in `docs/contributing/documentation.md` (the rule literal) and
  inside a fenced ```sh block in `docs/contributing/actions/debugging/ci.md`.
- SPOT self-labels: rewrote "This is the SPOT for X" to describe
  the subject directly ("This directory holds X" / "This file
  describes X"). Cross-references to other artefacts' canonical
  role remain unchanged.
- Heading-emoji position: moved leading-emoji headings (`# 🧩 Title`)
  to trailing position (`# Title 🧩`) per the headline rule that
  emojis MUST come after the title text.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 20:12:07 +02:00

1.8 KiB

Ansible Variable Lints 🪪

Lint tests that enforce variable-lifecycle invariants across the Ansible tree: every name a role declares MUST be consumed somewhere, and every name a role passes MUST be referenced by the play / template stack that receives it.

Tests in this directory MUST only cover variable definition / consumption checks. Four orthogonal scopes live here:

  • test_role_and_group_vars_used.py scans top-level keys of roles/<role>/{vars,defaults}/main.yml and group_vars/**/*.yml against every project .yml / .yaml / .j2 file. The suppression rule key is unused-var (see suppression.md).
  • test_vars_usage_in_yaml.py scans task-level vars: blocks against the same consumer set. The two scanners never overlap because their declaration shapes differ.
  • test_no_jinja_default_on_spot_path.py forbids | default(...) on Jinja expressions whose path resolves via group_vars/all/*.yml. Those keys are loaded unconditionally, so the default is dead code at best and silent SPOT decoupling at worst. Per-line suppression: # nocheck: spot-default.
  • test_dotted_path_keys_exist.py validates that every Jinja dotted path (FOO.BAR.BAZ) whose head is in group_vars/all/ or the consuming role's own vars/defaults resolves to an existing key in that dict tree, catching typos / renamed / removed sub-keys. Per-line suppression: # nocheck: dotted-path.

Both tests route every read through the project caches (utils.cache.files, utils.cache.yaml); contributors adding a new variable scanner MUST do the same instead of calling yaml.safe_load* or open() directly.

For framework, directory layout, and make test-lint usage see lint.md.