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].
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/653946f2-5e63-48b7-9522-a28162241c97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.