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.
On Fri, Mar 22, 2013 at 1:09 PM, Peter Klausner
<
peter.k...@gmail.com> wrote:
> I try to update /etc/sudoers, but fail with the YAML syntax. So I actually
> RTFM'ed and found the last sudoers example matches my case pretty much - and
> it fails as well. I'm running ansible from git. Here's a demo file with
> the sample and the failure:
>
> ________________________________________________________________________________
> mybox$ cat demo.yml
> - hosts: rh
> user: root
> tasks:
> - name: ok - sample w/o colon
> lineinfile: \"dest=/etc/sudoers state=present regexp='^%wheel' line
> ='%wheel ALL=(ALL) NOPASSWD ALL'\"
> - name: also fine, less quoting
> lineinfile: dest=/etc/sudoers state=present regexp='^%wheel' line
> ='%wheel ALL=(ALL) NOPASSWD ALL'
> - name: the colon kills it
> lineinfile: \"dest=/etc/sudoers state=present regexp='^%wheel' line
> ='%wheel ALL=(ALL) NOPASSWD: ALL'\"
> ________________________________________________________________________________
> mybox$ ansible-playbook -v demo.yml
> ERROR: Syntax Error while loading YAML script, demo.yml
> Note: The error may actually appear before this position: line 9, column 102
>
> - name: the colon kills it
> lineinfile: \"dest=/etc/sudoers state=present regexp='^%wheel' line
> ='%wheel ALL=(ALL) NOPASSWD: ALL'\"
>
> ^
> ________________________________________________________________________________
>
>
> Is there a way to quote the colon so that it is passed on properly?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
ansible-proje...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
--
Michael DeHaan <
mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/