ssh - reload only if config changed

This commit is contained in:
Ludovic Cartier
2026-02-20 17:00:16 +01:00
parent beed86501b
commit 6b71851b06
+6 -1
View File
@@ -5,6 +5,7 @@
mode: '0644'
validate: /usr/sbin/sshd -t -f %s
when: ssh_root_authorized_ips is defined
register: sshd_conf_changes
- name: SSH | configure root authorized keys
template:
@@ -19,9 +20,13 @@
command: /usr/sbin/sshd -t
register: sshd_config_check
changed_when: false
when: sshd_conf_changes.changed
- name: SSH | reload SSH service
service:
name: ssh
state: reloaded
when: sshd_config_check.rc == 0
when:
- sshd_conf_changes.changed
- sshd_config_check.rc == 0