Skip to content

Comments

[Q&A Proposal] Enable unamed-task check in ansible-linter#874

Merged
insatomcat merged 4 commits intoseapath:mainfrom
AntoineDupre:unamed-task
Feb 20, 2026
Merged

[Q&A Proposal] Enable unamed-task check in ansible-linter#874
insatomcat merged 4 commits intoseapath:mainfrom
AntoineDupre:unamed-task

Conversation

@AntoineDupre
Copy link

@AntoineDupre AntoineDupre commented Feb 20, 2026

Currently, the name[missing] rule from ansible-lint is disabled in the repository.
Rule: All tasks should be named

This rule was originally disabled because it also impacts debugging tasks.

However, disabling it globally is risky. Even if unnamed tasks are currently limited to debug-related usage, nothing guarantees that future changes will not introduce unnamed tasks in production-related code paths.

For maintainability, readability, and safer CI enforcement, this rule should be enabled again.

This proposal:

  • Re-enables name[missing]
  • Avoids disabling lint rules globally
  • Uses explicit, targeted # noqa exceptions
  • Improves code quality and maintainability
  • Ensures clearer CI output and operational traceability

Keep in mind the mantra:

If a rule is not automatically check in your code, it's not your rule.

Why enabling this rule is important

Named tasks provide:

  • Clear and structured Ansible output
  • Easier debugging in CI/CD pipelines
  • Better production traceability
  • Improved readability and maintainability
    An unnamed task produces generic output such as:
TASK [include_vars]

Whereas a properly named task provides context:

TASK [Load distribution-specific variables]

Identified cases and proposed handling

Enabling this rule requires handling three specific categories:

1 - Debug tasks
Debug tasks are sometimes intentionally minimal and may not require naming.

Instead of disabling the rule globally, we can explicitly exclude these occurrences with:

# noqa: name[missing]

This approach is:

  • Explicit
  • Self-documenting
  • Safer than disabling the rule repository-wide
  • Future-proof

It prevents unintended unnamed tasks from being introduced elsewhere.

2 include_vars tasks
Even though they look simple, they may:

  • Fail
  • Load incorrect files
  • Introduce configuration issues

Because of that, they should always be explicitly named to ensure:

  • Clear execution reporting
  • Easier troubleshooting
  • Explicit intent
- name: Load distribution-specific variables
  ansible.builtin.include_vars:
    file: "{{ seapath_distro }}.yml"

3 Conditional blocks (when + block)
Conditional blocks must be named.

Even if all inner tasks are named, the block itself represents a functional unit.
Without a name, Ansible output becomes less coherent.

- name: Configure systemd-resolved DNS settings
 when: dns_servers is defined
 block:

Additional lint exceptions

Two additional # noqa annotations were required:

# noqa: var-naming[no-reserved]

This is due to the use of the variable name query, which is considered reserved by ansible-lint.

In these two specific cases, the variable name is intentional and valid within our context.
Rather than renaming it globally and risking functional regressions, we explicitly disable the rule for those occurrences only.

Copy link

@SkytAsul SkytAsul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Antoine Dupre added 2 commits February 20, 2026 14:34
Signed-off-by: Antoine Dupre <antoine.dupre@savoirfairelinux.com>
Signed-off-by: Antoine Dupre <antoine.dupre@savoirfairelinux.com>
Paullgk
Paullgk previously approved these changes Feb 20, 2026
insatomcat
insatomcat previously approved these changes Feb 20, 2026
Antoine Dupre added 2 commits February 20, 2026 15:29
Signed-off-by: Antoine Dupre <antoine.dupre@savoirfairelinux.com>
Signed-off-by: Antoine Dupre <antoine.dupre@savoirfairelinux.com>
@insatomcat insatomcat merged commit b08ee96 into seapath:main Feb 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants