Using "insertafter=EOF" should do the trick.

[]s,

Em dom, 17 de abr de 2016 20:31, Bob Tanner <[email protected]>
escreveu:

> Struggling with lineinfile behavior.
>
> The general question: can lineinfile be used to replace a line in a file
> if it's found and if it's not found add the line to the file?
>
> I've seen posts saying yes, same saying no, same saying don't use
> lineinfile, use a template.
>
> Here's the recipe I've been trying:
>
>   lineinfile: >
>       dest="/tmp/testfile"
>       regexp="(.*){{ item.param }}(.*)?$"
>       line='{{ item.param }} {{ item.value }}'
>       backrefs="yes"
>       state="present"
>   with_items:
>       - { param: 'testparam', value: 'testvalue' }
>
> The contents of /tmp/testfile
>
> blah blahvalue
> foo foovalue
> ugh ughvalue
>
> I run the task and "testparam testvalue" does not get added to
> /tmp/testfile
>
> blah blahvalue
> foo foovalue
> ugh ughvalue
> testvalue wrongvalue
>
> Run the task again and I get what I think is the right output
>
> blah blahvalue
> foo foovalue
> ugh ughvalue
> testvalue testvalue
>
> --
> 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/7c3c9db8-c3cd-4d19-8e0e-7280303e93b6%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7c3c9db8-c3cd-4d19-8e0e-7280303e93b6%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/CAGeLGgsSS3x4E23RDjyvv%2BdaH0yBx%3DFRi9UNXx9NSxz19khzVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to