-
Notifications
You must be signed in to change notification settings - Fork 672
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
KeyError when fixing playbook containing multiple blocks with wrong key order #4091
Comments
Just faced the same issue but with a
|
That's actually #4093 instead, but thanks for the report |
That really is the most minimal reproducer. Amazing. What's going on here as best as I can figure is that the rule is getting confused, but only with a block in a second play. Anything less than that... two tasks in one play, only the second play has a block, plays in a different order, anything else, and the rule correctly identifies the location of the error. But with this specific organization of plays and tasks, the rule points to the task inside the block and not the block itself as the culprit, which does not in fact have a This hopefully shouldn't be too hard to fix, at least not once I've figured out why it's doing that. |
Sorry I have sent a few comments, which should have been added to #4093. Comments were deleted. |
Summary
ansible-lint --fix
breaks with aKeyError
in thekey-order
rule when run on a yaml file containing multiple blocks where blocks after the first have incorrect key order.Issue Type
OS / ENVIRONMENT
ansible-lint 6.22.2 using ansible-core:2.15.10 ansible-compat:4.1.11 ruamel-yaml:None ruamel-yaml-clib:None
STEPS TO REPRODUCE
Run
ansible-lint --fix
on the following test playbook:Desired Behavior
Should fix the key order of the incorrect block without breaking.
Actual Behavior
Results of
ansible-lint --fix
:Results of
ansible-playbook --syntax-check playbook
:The text was updated successfully, but these errors were encountered: