I've also run into this issue and haven't picked the best way to deal with it yet.
You can always run that command via the shell module. Occasionally commands get a little gross and you'll have to add so many escape characters and quotes that even you can't tell what's going on. If that happens, you could consider adding the command as a file or template, pushing that to a host, running it and then deleting it (if you so choose). All of those are a little clunky and feel pretty anti-Ansible. It's goal is to be idempotent and with a command like that, you are breaking this canon. Out of curiosity, what are you trying to add to what? On Friday, August 1, 2014 12:47:14 PM UTC-5, John Oliver wrote: > > I have a list of lines I want to add to a file on the target system if > they don't exist. I don't want to wholesale overwrite the file, and I > don't want to write dozens of lineinfile: statements. > > Is it possible to do the equivalent of: > > while read line; do > if grep "$line" /target/file >/dev/null 2>&1 ; then : ; else echo $line > >> /target/file; fi > done < /source/file > > -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/31493436-484f-42b6-9b1d-6a83bfe2bef3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.