I'm trying to modify my AllowGroups entry in sshd_config but I'm running into a problem where I have AllowUsers on some servers.
Example line:
AllowGroups group1 group2 group3 !*
Desired output:
AllowGroups group1 group2 group3 newgroup !*
Current playbook:
- name: Add group to sshd_config
hosts: '{{ target }}'
handlers:
- name: reload sshd
service:
name: sshd
state: reloaded
tasks:
- name: Add Group to AllowGroups
replace:
dest: /etc/ssh/sshd_config
regexp: '\!\*$'
replace: 'newgroup !*'
validate: 'sshd -t -f %s'
notify: reload sshd
Is there a way I can tweak this where I only capture lines that begin with 'AllowGroups' ?