If there is a colon in a YAML line, it must be quoted.
Because you have escaped your starting quote with \", that doesn't
count as a quote, and does not serve to quote the colon.
It appears the answer is to not escape your leading \", and instead
just say lineinfile:" ... and to keep it simple, use single quotes
inside the double, and you own't have to escape anything else.
sure the version info and output are much needed !
I had a very similar uses case to what I understood from Nick.
I needed to insert/insure a line such as below being declared in /etc/hosts.deny file:
ALL: ALL
Using the lineinfile module, the only way I found for a line to contain a column character, is to use something like I described.
ERROR: Syntax Error while loading YAML script, /host_access_restricted/tasks/main.yml
Note: The error may actually appear before this position: line 33, column 14
regexp=‘^ALL:\s+ALL’
line=“ALL: ALL”
^
ansible-playbook version in my case is 1.5.3
Not sure if the above error really is an error or should be considered as a bug.
Note: this is old code on my side and IIRC I applied this workaround since ansible >= 1.2
Based on your post , and in my case where the statement is spread over multiples lines
I just found the following to work (tend to always forgot the yaml syntax for multi-line )
which to me is even simpler (this is just me) as no even need to double quote