-
Notifications
You must be signed in to change notification settings - Fork 636
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
key-order warning when using block with when condition #2509
Comments
This is not a bug, it is like this on purpose and documented on https://ansible-lint.readthedocs.io/rules/key-order/ We discussed a lot about the subject and the decision was that block/rescue/always cannot have anything after them, not even |
@ssbarnea sorry for the noise, understand now. But would be great if you would add an example for |
I'll add a bit of unsolicited commentary here because we did talk about this for a while. In the case of a block, the tags and when clause are applied to each task within the block. For readability, having it at the top make it easier to see the details about the block itself. This becomes increasing important as the block size gets bigger and the tasks have large data structures... |
We were talking about updating docs for that reason! The challenge just started as we did not establish a full order for all possible keys yet. But updating official examples is a very good idea. |
Is there any rule/recommendation about block size ? Unless always/rescue/... are needed, if the block is getting big, wouldn't it be better/cleaner to just put the tasks in a different file ? |
@apatard Look at https://ansible-lint.readthedocs.io/profiles/#shared and you will see two planned rules there related to these. They are not implemented yet, but they are planned. We still need to decide what is too-big, and for that we will need to run some data-collection scripts on what was published so far and get some feedback from the users. I am inclined to believe that |
@ssbarnea 100 tasks in a block ? sounds a lot. Maybe you meant 10 ? Maybe open a poll to get the number ? Once this is decided, if the number is "small", will the check be reconsidered for block (as asked by this bug) ? |
Summary
key-order warning when using block with when condition.
Issue Type
Ansible and Ansible Lint details
OS / ENVIRONMENT
NA
STEPS TO REPRODUCE
Create playbook based on https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html#grouping-tasks-with-blocks:
Desired Behavior
No warning for the above playbook.
Actual Behavior
The text was updated successfully, but these errors were encountered: