It's not an option as the current file has previously templated with some common configuration. It's a role who has to add the group to the line if the host includes it.

Br

On 06/04/14 17:24, Paul Durivage wrote:
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* <[email protected] <mailto:[email protected]>>
Date: Sat, Apr 5, 2014 at 9:02 AM
Subject: [ansible-project] Help with Idempotent lineinfile regex
To: [email protected] <mailto:[email protected]>


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 [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>. 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 [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAK6JQEGN8mrLPvYFqhNLKcx1rNx_rodrFXYoPNbe58O5nL7BJQ%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CAK6JQEGN8mrLPvYFqhNLKcx1rNx_rodrFXYoPNbe58O5nL7BJQ%40mail.gmail.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/53419E16.8000208%40swissms.ch.
For more options, visit https://groups.google.com/d/optout.

Reply via email to