CHANGE: moves ssh server restart into handlers

This commit is contained in:
2026-08-11 14:21:34 +04:00
parent 39408cab31
commit 26c6bc610f
2 changed files with 28 additions and 13 deletions
+13
View File
@@ -0,0 +1,13 @@
---
- name: Restart ssh-server Debian
ansible.builtin.service:
name: sshd
state: restarted
changed_when: false # It's just a handler, no need to increase 'changed' counter
- name: Restart ssh-server Ubuntu
ansible.builtin.service:
name: ssh
state: restarted
changed_when: false
+15 -13
View File
@@ -6,6 +6,7 @@
dest: /etc/ssh/sshd_config.d/hardened_sshd.conf
mode: u=rw,g=r,o=r
when: ansible_facts['distribution'] == 'Ubuntu'
notify: Restart ssh-server Ubuntu
- name: Configure ssh-server daemon
ansible.builtin.copy:
@@ -13,6 +14,7 @@
dest: /etc/ssh/sshd_config.d/hardened_sshd.conf
mode: u=rw,g=r,o=r
when: ansible_facts['distribution'] == 'Debian'
notify: Restart ssh-server Debian
- name: Configure ssh client
remote_user: ansible
@@ -21,16 +23,16 @@
dest: /etc/ssh/ssh_config.d/hardened_ssh.conf
mode: u=rw,g=r,o=r
- name: Restart ssh-server Debian
remote_user: ansible
ansible.builtin.service:
name: sshd
state: restarted
when: ansible_facts['distribution'] == 'Debian'
- name: Restart ssh-server Ubuntu
remote_user: ansible
ansible.builtin.service:
name: ssh
state: restarted
when: ansible_facts['distribution'] == 'Ubuntu'
#- name: Restart ssh-server Debian
# remote_user: ansible
# ansible.builtin.service:
# name: sshd
# state: restarted
# when: ansible_facts['distribution'] == 'Debian'
#
#- name: Restart ssh-server Ubuntu
# remote_user: ansible
# ansible.builtin.service:
# name: ssh
# state: restarted
# when: ansible_facts['distribution'] == 'Ubuntu'