restart sshd if needed

This commit is contained in:
Pim Kunis 2023-04-26 19:12:10 +02:00
parent 96bc6e97c0
commit 65ea776c21
2 changed files with 8 additions and 0 deletions

4
handlers/main.yml Normal file
View file

@ -0,0 +1,4 @@
- name: restart sshd
systemd:
name: sshd
state: restarted

View file

@ -36,6 +36,7 @@
line: "CertificateFile /etc/ssh/{{ item.name }}-cert.pub" line: "CertificateFile /etc/ssh/{{ item.name }}-cert.pub"
create: true create: true
when: item.type == "user" when: item.type == "user"
notify: restart sshd
- name: Enable user identity - name: Enable user identity
lineinfile: lineinfile:
@ -43,6 +44,7 @@
line: "IdentityFile /etc/ssh/{{ item.name }}" line: "IdentityFile /etc/ssh/{{ item.name }}"
create: true create: true
when: item.type == "user" when: item.type == "user"
notify: restart sshd
- name: Enable host certificate - name: Enable host certificate
lineinfile: lineinfile:
@ -50,6 +52,7 @@
line: "HostCertificate /etc/ssh/{{ item.name }}-cert.pub" line: "HostCertificate /etc/ssh/{{ item.name }}-cert.pub"
create: true create: true
when: item.type == "host" when: item.type == "host"
notify: restart sshd
- name: Enable host key - name: Enable host key
lineinfile: lineinfile:
@ -57,3 +60,4 @@
line: "HostKey /etc/ssh/{{ item.name }}" line: "HostKey /etc/ssh/{{ item.name }}"
create: true create: true
when: item.type == "host" when: item.type == "host"
notify: restart sshd