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
ansible-lint --versionansible-lint 6.11.0 using ansible 2.14.1
ansible installation method: pip
ansible-lint installation method: pip
STEPS TO REPRODUCE
When trying to automatically prettify a larger set of Ansible roles, I detected some strange diffs in files with multiline blocks. I fixed some other stuff in the meantime and after 2-3 ansible-lint runs, it suddenly started crashing.
Here is a reproducing case:
foo.yml:---- name: Demo hosts: all tasks: - name: Demo ansible.builtin.debug: msg: |3 multi line message
Desired Behavior
Either leave this as-is or at least don't break it over time.
the output of running ansible-lint including the command line used
if you're getting a stack trace, also the output of ansible-playbook --syntax-check playbook
# First run:
ansible-lint --write foo.yml
---
- name: Demo
hosts: all
tasks:
- name: Demo
ansible.builtin.debug:
msg: |4
multi
line
message
# Running again:
ansible-lint --write foo.yml
---
- name: Demo
hosts: all
tasks:
- name: Demo
ansible.builtin.debug:
msg: |4
multi
line
message
# Running _again_:
ansible-lint --write foo.yml
# Now it crashes:
ruamel.yaml.parser.ParserError: while parsing a block mapping
in "<unicode string>", line 7, column 9:
msg: |4
^ (line: 7)
expected <block end>, but found '<scalar>'
in "<unicode string>", line 9, column 11:
line
^ (line: 9)
The text was updated successfully, but these errors were encountered:
To be honest, I am not surprised it chokes on this feature. I am aware of reformatting bugs with far more popular YAML options, that one being one that I never used myself.
Update: that one is quite problematic because the workaround is to use same indentation for sequences as for hashes, which is not the Ansible formatting, basically ruamel.yaml formatting works only with classic formatting which does not add extra indentation for lists.
Luckily I could avoid this specific YAML feature in the one case that I encountered it, but in general it is something to be aware of - especially since it did not crash after the first reformat and it took 3 runs in total to get a crash.
Summary
If blocks are indented using indentation indicators (https://yaml.org/spec/1.2.2/#8111-block-indentation-indicator), the
--write
mode seems to have a hard time and constantly re-formats the file until it outputs invalid YAMLIssue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
When trying to automatically prettify a larger set of Ansible roles, I detected some strange diffs in files with multiline blocks. I fixed some other stuff in the meantime and after 2-3 ansible-lint runs, it suddenly started crashing.
Here is a reproducing case:
Desired Behavior
Either leave this as-is or at least don't break it over time.
Actual Behavior
Please give some details of what is happening.
Include a minimum complete verifiable example with:
ansible-playbook --syntax-check playbook
The text was updated successfully, but these errors were encountered: