A good trick with the lineinfile module is almost always to use the
template module if you can :)

The problem here is if you start something with a quote, it assumes that
quote is not part of the string and then will end the quote.

Thus you might find it easier to just escape quotes with \" or \' when
needed.





On Sun, Nov 16, 2014 at 11:59 PM, <[email protected]> wrote:

>
>     I am using the lineinfile module to define the SMART_HOST value in a
> sendmail.mc file.  I have tried many variations of specifying the 'line='
> value, but all generate almost but not quite correct results.
>     For example: lineinfile: dest=/etc/mail/sendmail.mc state=present
> regexp='SMART_HOST' line="define(`SMART_HOST', `{{smarthost}}')dnl"
>     generates:  define(\`SMART_HOST', \`gateway.here.com')dnl
>
>     Or: lineinfile: dest=/etc/mail/sendmail.mc state=present
> regexp='SMART_HOST' line='define(`SMART_HOST'', `{{smarthost}}'')dnl'
> (that is two single quotes)
>     generates:  define(`SMART_HOST, `gateway.here.com)dnl
>
>     And: lineinfile: dest=/etc/mail/sendmail.mc state=present
> regexp='SMART_HOST' line="define(`SMART_HOST"'", `{{smarthost}}"'")dnl"
> (double quote, single, double)
>     generates:  define(`SMART_HOST", `gateway.here.com")dnl
>
>     And so on.  Everything I have tried either comes close or just totally
> fails.  The result I am looking for is:  define(`SMART_HOST', `
> gateway.here.com')dnl
>     Does anyone know the proper quoting and escaping required to achieve
> this through YAML?
>     Thanks,
>     -Mark
>
>
>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c46c39da-31ee-4eee-a52e-b39cf79b0668%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/c46c39da-31ee-4eee-a52e-b39cf79b0668%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgxoeuPvV7J1KCvRrHDoQW6sSBMz8HuoP1JsYupOJ8zHEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to