Add a task for optionally configuring the AllowUsers directive

This commit is contained in:
Alexander Gorelyshev
2026-05-18 20:10:12 +04:00
parent c66e8daddf
commit e8376ee112

View File

@@ -21,3 +21,12 @@
regexp: '^#?LogLevel' regexp: '^#?LogLevel'
line: 'LogLevel VERBOSE' line: 'LogLevel VERBOSE'
validate: sshd -f %s -t validate: sshd -f %s -t
- name: "Configure AllowUsers"
when: sshd_allow_users is defined
notify: Restart sshd
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?\s*AllowUsers\s+'
line: "AllowUsers {{ sshd_allow_users }}"
validate: sshd -f %s -t