Skip to content

Rule unnamed-task should not have any exceptions #1411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ansiblejunky opened this issue Feb 25, 2021 · 2 comments · Fixed by #1413
Closed

Rule unnamed-task should not have any exceptions #1411

ansiblejunky opened this issue Feb 25, 2021 · 2 comments · Fixed by #1413
Labels
Milestone

Comments

@ansiblejunky
Copy link
Contributor

ansiblejunky commented Feb 25, 2021

Summary

Ansible good practice generally states to name all your tasks. A simple straightforward rule that should always be applied. Having exceptions to this rule breaks the general philosophy around maintaining good practice. Additionally, ansible-lint docs never state the exceptions at all for this rule. However in the Python code we can see there are indeed exceptions that are not enforced.

    _nameless_tasks = [
        'meta',
        'debug',
        'include_role',
        'import_role',
        'include_tasks',
        'import_tasks',
    ]

While there can be a debate around naming these modules in the exceptions, it generally is a much better practice to have a simple rule that is always applied versus having exceptions to the rule especially when they are not truly documented anywhere.

Issue Type
  • Bug Report
Ansible and Ansible Lint details
ansible --version
latest
ansible-lint --version
latest
  • ansible installation method: source
  • ansible-lint installation method: source
OS / ENVIRONMENT

any

STEPS TO REPRODUCE

Run ansible-lint against playbook containing unnamed tasks using any of the module exceptions (debug, meta, etc.).

Desired Behaviour

ansible-lint should not have exceptions to this rule and should enforce naming of all tasks

Actual Behaviour

ansible-lint does not complain when unnamed tasks use the modules listed in the python code as exceptions

@tonykay
Copy link

tonykay commented Feb 25, 2021

I agree strongly, the idea that certain tasks, hidden in the code of the linter, have an exempt status is to me confusing and echo @ansiblejunky's comment A simple straightforward rule that should always be applied

@ssbarnea
Copy link
Member

These exceptions are historical and very old and I do also agree with OP as we should have no exceptions.

Please make a pull-request to remove them, I will support it. I will only need to wait a little bit more before releasing it as it will annoy few users.

I do remember having long-debates with some colleagues in the past which seen the naming of the tasks useless. Some things changed and did not hear the the same comment for very long time.

Personally I would even look to have a test for no-dup-task-name, as this is another common mistake around naming which makes debugging hard, as you have no idea which task produced it.

@ssbarnea ssbarnea added this to the 5.1.0 milestone Feb 26, 2021
ssbarnea pushed a commit that referenced this issue Feb 27, 2021
ssato added a commit to ssato/ansible-lint-custom-rules that referenced this issue Apr 18, 2021
Because of the change in the upstream of ansible-lint below every tasks
including 'meta' does not do usual 'task' and self-descriptive ones like
debug and include_tasks must have name even if it is good for nothing,
IMHO.

- ansible/ansible-lint#1411
ssato added a commit to ssato/ansible-lint-custom-rules that referenced this issue Apr 18, 2021
Because of the change in the upstream of ansible-lint below every tasks
including 'meta' does not do usual 'task' and self-descriptive ones like
debug and include_tasks must have name even if it is good for nothing,
IMHO.

- ansible/ansible-lint#1411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants