I have several lineinfile statements to insert iptables rules into /etc/sysconfig/iptables I'm using positional like insertbefore to get them in the order I want, and it works just fine on the first run. But subsequent runs are not idempotent... if I insert B before Y, and then C before Y, and then D before Y; then run the playbook over, it seems to see that the line before Y is D, and adds B again, then C, then D.
Is there a way to use positional but tell ansible that if it sees a line matching a regexp anywhere in the file to not execute?
Or is there another module that might be more appropriate for this? I mean, I could use a shell directive to check the config file or output of iptables for a line matching a regexp, and if no match then insert my line, and then iptables-save, but that just isn't as neat as using the lineinfile module :-)