ci(lint): enable and gate ansible-lint's complexity rule #397

Merged
Defame1297 merged 1 commits from ci/138-complexity-gate into main 2026-11-26 19:30:31 +00:00
Owner

What and why

Closes #138

Implements the "Complexity" rule of the role standard (#93), as amended in #138's comments (decided by #257).

  • .ansible-lint: enable_list: [complexity] and warn_list: []. max_tasks stays at the default of 100 because the config schema rejects the key. #139 lowers it to 40. The empty warn list makes experimental rules (complexity) fail Lint. It also makes jinja[spacing] and fqcn[deep] fail, and #257 decided that is intended. Enabling complexity also turns on complexity[nesting] (block depth, default 20).
  • role-name is no longer skipped repository-wide. .ansible-lint-ignore exempts only roles/_binary_update, with the explaining comment moved there, so a misnamed public role fails.
  • roles/AGENTS.md: the Complexity and role-name rules are now held by the ansible-lint control in the Lint job. Their "until #138" wording is removed.

No changelog fragment: Lint config and contributor guidance only, so consumers see no change.

Verified

Locally, with ansible-lint 26.10.1 (the pin) through scripts/ansible-lint.sh:

  • pre-commit run --all-files passes, and so does the pre-push ansible-test sanity.

  • New findings Lint reports: none. No complexity, jinja[spacing], fqcn[deep] or role-name failures. The role-name finding on roles/_binary_update shows as ignored.

  • A throwaway 101-task file in roles/ufw/tasks/ fails with complexity[tasks] (rc=2). Not committed.

  • A throwaway role roles/BadRole fails with role-name (rc=2). Not committed.

  • Largest task counts in roles/ (from the same rule with max_tasks patched lower, molecule files included):

    File Tasks
    roles/ufw/tasks/service_rules.yml 35
    roles/_binary_update/tasks/main.yml 25
    roles/ufw/tasks/orphan_rules.yml 24
    roles/cloudflared/tasks/configure.yml 23
    roles/gitea_runner/tasks/main.yml 19
    roles/gitea/tasks/configure.yml 17
    roles/traefik/tasks/binary/configure.yml 16

    Largest molecule play: roles/traefik/molecule/default/verify.yml, between 21 and 30 tasks. Nothing exceeds 40, so #139 would flag nothing today.

Not verified

  • The Lint job in CI: its result is on this pull request's run. The local run used the same pinned ansible-lint and collections.
  • Molecule: not run. The changed files are on the scenario selector's IGNORED list, and no role changed.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code:claude-opus-5-5

## What and why Closes #138 Implements the "Complexity" rule of the role standard (#93), as amended in #138's comments (decided by #257). - `.ansible-lint`: `enable_list: [complexity]` and `warn_list: []`. `max_tasks` stays at the default of 100 because the config schema rejects the key. #139 lowers it to 40. The empty warn list makes experimental rules (`complexity`) fail Lint. It also makes `jinja[spacing]` and `fqcn[deep]` fail, and #257 decided that is intended. Enabling `complexity` also turns on `complexity[nesting]` (block depth, default 20). - `role-name` is no longer skipped repository-wide. `.ansible-lint-ignore` exempts only `roles/_binary_update`, with the explaining comment moved there, so a misnamed public role fails. - `roles/AGENTS.md`: the Complexity and `role-name` rules are now held by the ansible-lint control in the Lint job. Their "until #138" wording is removed. No changelog fragment: Lint config and contributor guidance only, so consumers see no change. ## Verified Locally, with ansible-lint 26.10.1 (the pin) through `scripts/ansible-lint.sh`: - `pre-commit run --all-files` passes, and so does the pre-push `ansible-test sanity`. - **New findings Lint reports: none.** No `complexity`, `jinja[spacing]`, `fqcn[deep]` or `role-name` failures. The `role-name` finding on `roles/_binary_update` shows as ignored. - A throwaway 101-task file in `roles/ufw/tasks/` fails with `complexity[tasks]` (rc=2). Not committed. - A throwaway role `roles/BadRole` fails with `role-name` (rc=2). Not committed. - **Largest task counts in `roles/`** (from the same rule with `max_tasks` patched lower, molecule files included): | File | Tasks | |---|---| | `roles/ufw/tasks/service_rules.yml` | 35 | | `roles/_binary_update/tasks/main.yml` | 25 | | `roles/ufw/tasks/orphan_rules.yml` | 24 | | `roles/cloudflared/tasks/configure.yml` | 23 | | `roles/gitea_runner/tasks/main.yml` | 19 | | `roles/gitea/tasks/configure.yml` | 17 | | `roles/traefik/tasks/binary/configure.yml` | 16 | Largest molecule play: `roles/traefik/molecule/default/verify.yml`, between 21 and 30 tasks. Nothing exceeds 40, so #139 would flag nothing today. ## Not verified - The Lint job in CI: its result is on this pull request's run. The local run used the same pinned ansible-lint and collections. - Molecule: not run. The changed files are on the scenario selector's IGNORED list, and no role changed. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code:claude-opus-5-5
Claude added this to the Continuous delivery milestone 2026-11-26 19:19:54 +00:00
Claude added 1 commit 2026-11-26 19:19:54 +00:00
ci(lint): enable and gate ansible-lint's complexity rule
Build / build (pull_request) Successful in 29s
Molecule / molecule (pull_request) Successful in 5s
Lint / lint (pull_request) Successful in 1m31s
3b20a1b6c6
Enable complexity at the default max_tasks and empty warn_list so
experimental findings fail Lint. Replace the repository-wide role-name
skip with an ignore line for the internal role _binary_update, so a
misnamed public role fails.

Closes #138

Assisted-by: Claude Code:claude-opus-5-5
CODEOWNERS rules requested review from Defame1297 2026-11-26 19:19:54 +00:00
Defame1297 scheduled this pull request to auto merge when all checks succeed 2026-11-26 19:30:20 +00:00
Defame1297 approved these changes 2026-11-26 19:30:30 +00:00
Defame1297 merged commit 9c415ee347 into main 2026-11-26 19:30:31 +00:00
Defame1297 deleted branch ci/138-complexity-gate 2026-11-26 19:30:31 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#397