I have this YAML file (I distilled my question to the bare minimum):
scalar: simple_value
empty:
list:
- 1
- 2
- 3
complex:
- first:
one: 1
two: 2
- second:
one: 3
two: 4
weird: "{{ '{{' }} something {{ '}}' }}"
weirder: "{{ '{{' }} 'TTT' if something == 'blah' else 'FFF' {{ '}}' }}"
weirdest: "&lcub2; ansible_date_time.year &rcub2;.&lcub2; ansible_date_time.month &rcub2;.&lcub2; ansible_date_time.day &rcub2;"
and this playbook:
---
- hosts: localhost
tasks:
- name: Load
include_vars:
file: ./vars.yml
name: object
- name: Write
copy:
content: "{{ object | to_nice_yaml(indent=2) }}"
dest: ./outv.yml
The output file is like this:
complex:
- first:
one: 1
two: 2
- second:
one: 3
two: 4
empty: null
list:
- 1
- 2
- 3
scalar: simple_value
weird: '{{ something }}'
weirder: '{{ ''TTT'' if something == ''blah'' else ''FFF'' }}'
weirdest: '&lcub2; ansible_date_time.year &rcub2;.&lcub2; ansible_date_time.month
&rcub2;.&lcub2; ansible_date_time.day &rcub2;'
While I think that both the output and input list indentations are correct and equivalent and that the Jinja escaping is handled properly, I am not sure about weirder
's value quotation.
And I don't understand the line break for weirdest
's value.
YAMLint says it is ok but actually restores the "normal"quotation and re-joins the line-break during the syntax check.
Is there a way to force the use of double-quotes with filter to_nice_yaml
(or any other filter)?
Is there a way to avoid that line-break (or maybe have a reason for it)?