You would need to use regexp. So, if you are trying to write ddd, the defined regexp would be :
regexp:'^ddd' This way lineinfile will look for a line matching that regexp before writting. If it finds that line, it will get overwritten with the same content. Else, it will be added. state = present also needs to be specified. Le mercredi 25 mars 2015 12:13:43 UTC-4, Cevyn E a écrit : > > I'm new to Ansible and learning a lot but I have a stupid question. I > just can not quite see the answer. > I have a file > > aaa > bbb > ccc > > I want to add > ddd > eee > > but only if it does not already exist. So I can rerun playbook without > creating dups. > > I've tried register and when. > I have tried using backrefs=yes > > It is just slipping though my fingers. I'm sure this is child's play for > many of you . Please instruct... > > -- 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/9547c4fd-7a91-498c-809e-5e1af082577f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
