A better, more reliable approach would be to create a template sshd_config file (or just a regular, non-templated file) that is placed on nodes via the copy <http://docs.ansible.com/copy_module.html> or template<http://docs.ansible.com/template_module.html>module.
---------- Forwarded message ---------- From: Antonio Marin <ama...@swissms.ch> Date: Sat, Apr 5, 2014 at 9:02 AM Subject: [ansible-project] Help with Idempotent lineinfile regex To: ansible-project@googlegroups.com Hello, I'm trying to create a lineinfile task to append a word in a line, when it's not present, like the following: # The line should start with AllowGroups # Follows an unknown length sequence of "\s\w+" # It's possible to find groupN within the previous sequence, in which case the task should return ok # If groupN is not present, the result will be AllowGroups, followed by the existing sequence, followed by " groupN" - name: Add group to ssh allowed lineinfile: backrefs=yes dest=/etc/ssh/sshd_config regex='^AllowGroups(.*)(?! groupN)(.*)' line='AllowGroups\\1\\3 groupN' state=present I have tried several approaches but none have been successful. I would appreciate any light to achieve it. BR, Tony -- 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/653946f2-5e63-48b7-9522-a28162241c97%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/653946f2-5e63-48b7-9522-a28162241c97%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 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/CAK6JQEGN8mrLPvYFqhNLKcx1rNx_rodrFXYoPNbe58O5nL7BJQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.