You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Bug Report
OS / ENVIRONMENT
$ ansible-lint --versionansible-lint 6.22.1 using ansible-core:2.16.0 ansible-compat:4.1.10 ruamel-yaml:0.18.5 ruamel-yaml-clib:0.2.8
Fedora 39
ansible installation method: OS package
ansible-lint installation method: pip
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.
diff --git i/roles/test_role4/meta/main.yml w/roles/test_role4/meta/main.yml
index c572acc..62bafb9 100644
--- i/roles/test_role4/meta/main.yml
+++ w/roles/test_role4/meta/main.yml
@@ -1,3 +1,4 @@
+---
galaxy_info:
author: your name
description: your role description
@@ -40,12 +41,12 @@ galaxy_info:
# - 99.99
galaxy_tags: []
- # List tags for your role here, one per line. A tag is a keyword that describes
- # and categorizes the role. Users find roles by searching for tags. Be sure to
- # remove the '[]' above, if you add tags to this list.
- #
- # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
- # Maximum 20 tags per role.
+# List tags for your role here, one per line. A tag is a keyword that describes
+# and categorizes the role. Users find roles by searching for tags. Be sure to
+# remove the '[]' above, if you add tags to this list.
+#
+# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
+# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
The text was updated successfully, but these errors were encountered:
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: