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
ansible-lint --fix munges ansible-galaxy role init meta/main.yml indentation #3941
Comments
I opened an issue in ansible/ansible for this, initially thinking of updating the generated meta/main.yml file to be ansible-lint friendly. I'm not sure if that's viable, but I thought it was worth raising an issue here as well. |
I 100% agree that ignoring this is a substandard dev experience- if we're going to implement formatting rules, our own sample/skeleton content should probably pass it cleanly, one way or another. That said, I assume the root cause of this issue is ruamel's invented comment-to-node mapping. Since comments are still officially not part of the YAML presentation stream (the meaty spec line there is "comments are not associated with a particular node"), ruamel's comment preservation/emission behavior defines its own extra-spec rules to make this work. IIRC, comments and whitespace-only lines on lines containing no YAML content are assumed to "belong" to the next node below them, and are thus force-aligned to that node by the emitter. If my assumption above is correct, and we're just leaning on a round-trip through ruamel as the SoT for the ansible-lint rule in question, it makes me slightly nervous that those rules are at the whim of a non-YAML-spec implementation that's not necessarily stable. I don't really have a problem adjusting the core skeleton for this case (ala something like ansible/ansible#82529), but bigger-picture, before we completely delegate that off to ruamel, can we see if there's a reasonable way to ignore comment-only line changes in the rule (at least where there's >0 empty lines before the node it wants to align with)? The role metadata skeleton case is borderline anyway, so I don't really care about changing that one as-proposed, but there may be legitimate cases where this rule will force users to change comment indentation in ways that negatively affect readability. |
Summary
If you generate an Ansible role using the ansible-galaxy role init command, it creates a default meta/main.yml file.
If you later run ansible-lint --fix against that role, it changes the comment indentation for the galaxy_tags section.
Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
ansible-galaxy role init test_role
check it into git or make a backup of meta/main.yml to diff
ansible-lint --fix test_role
git diff test_role
N/A
Desired Behavior
ansible-lint would keep the indentation of the meta/main.yml consistent.
Actual Behavior
The indentation of the comments for galaxy_tags is moved to the beginning of the line which is inconsistent with the rest of the meta/main.yml file.
The text was updated successfully, but these errors were encountered: