Skip to content

Demonstrate inconsistent behavior for ansible.parsing.yaml.loader.AnsibleLoader

Notifications You must be signed in to change notification settings

andras-kth/ansible-yaml-loader-issue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ansible-yaml-loader-issue

Demonstrate inconsistent behavior for ansible.parsing.yaml.loader.AnsibleLoader

ansible/ansible#75212

Two equivalent ways to specifiy the same content:

user@host:~/ansible-yaml-loader-issue$ diff roles/*/tasks/main.yml
8,10c8
<     block: |
<       	extra line with leading TAB;
<       	another line with leading TAB;
---
>     block: "\textra line with leading TAB;\n\tanother line with leading TAB;\n"

Different behaviour when running with or without libyaml / CParser:

user@host:~/ansible-yaml-loader-issue$ ./loader.py roles/*/tasks/main.yml
 <class '__main__.AnsibleCLoader'> roles/easy_to_read/tasks/main.yml 
 while scanning a block scalar
  in "roles/easy_to_read/tasks/main.yml", line 8, column 12
found a tab character where an indentation space is expected
  in "roles/easy_to_read/tasks/main.yml", line 9, column 7 
 <class '__main__.AnsiblePyLoader'> roles/easy_to_read/tasks/main.yml 
[
  {
    "name": "Block-in-file with leading TAB",
    "blockinfile": {
      "path": "{{ test_conf }}",
      "insertbefore": "^};$",
      "marker": "\t// {mark} ANSIBLE MANAGED BLOCK",
      "block": "\textra line with leading TAB;\n\tanother line with leading TAB;\n"
    }
  }
]
 <class '__main__.AnsibleCLoader'> roles/hard_to_read/tasks/main.yml 
[
  {
    "name": "Block-in-file with leading TAB",
    "blockinfile": {
      "path": "{{ test_conf }}",
      "insertbefore": "^};$",
      "marker": "\t// {mark} ANSIBLE MANAGED BLOCK",
      "block": "\textra line with leading TAB;\n\tanother line with leading TAB;\n"
    }
  }
]
 <class '__main__.AnsiblePyLoader'> roles/hard_to_read/tasks/main.yml 
[
  {
    "name": "Block-in-file with leading TAB",
    "blockinfile": {
      "path": "{{ test_conf }}",
      "insertbefore": "^};$",
      "marker": "\t// {mark} ANSIBLE MANAGED BLOCK",
      "block": "\textra line with leading TAB;\n\tanother line with leading TAB;\n"
    }
  }
]
user@host:~/ansible-yaml-loader-issue$

About

Demonstrate inconsistent behavior for ansible.parsing.yaml.loader.AnsibleLoader

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published