Another option that would work for ini-style files:

- ini_file:
    dest=/etc/example.conf
    section=test
    option=example
    value=value

Just add one option/value pair for each required option. Unfortunately, in 
my case, the config file in question isn't actually an ini-style file, so 
ini_file doesn't work.

On Thursday, February 6, 2014 2:02:58 PM UTC-6, Jeff Geerling wrote:
>
> I'm trying to make my lineinfile command that uses multiple lines 
> idempotent:
>
> - lineinfile: >
>     dest=/etc/example.conf
>     regexp='^\[test(.*)'
>     line='[test]{{ '\n' }}secondline'
>
> I've tried this, and the following regexp variations:
>
> regexp=''/^\[test(.*)/s' # trying to get it to work multiline
> regexp='^\[test\]{{ '\n' }}secondline' # trying to use same pattern in 
> 'line'
>
> I've also tried a bunch of other variations, with no luck, as well as 
> adding 'insertafter=EOF'. In all cases, I ended up getting another block of 
> text each time I ran ansible-playbook.
>
> How can I do a lineinfile with multiple lines with idempotence?
>
> (Also, I can't get the line to work without wrapping newlines, tab 
> characters, etc. in a variable reference ({{ }}), though I've seen other 
> examples online where those whitespace characters must be working correctly.
>

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to