String quotes are unexpectly removed
jinja2 pre and post-processor to update with YAML
Brought to you by:
anthon
When I load a Ansible YAML like:
- set_fact:
artifact_id: "{{ role_name }}"
and load it via.
yaml = YAML(typ='jinja2')
yaml.width = sys.maxsize
data = yaml.load("file.yml")
and store it via.
yaml.dump(data, "file.yml")
The string quotation is removed:
- set_fact:
artifact_id: {{ role_name }}
This is bad, because Ansible detects that as a syntax error.
Is there any way to prevent that?
Used versions:
Please post these kind of questions on StackOverflow, that makes the answer much more easy to find for most people (tag them with
ruamel.yamland I will be notified automatically).Try to insert
after creating the
YAML()instance and before loading.The officially recommended extension for files containing YAML documents has been
.yamlsince at least September 2006. So please catch up.I searched already on Stack Overflow. But I did not expect to find the solution in the source code. Thanks for the answer.
I'm also respecting the file extension in the future.