2020-08-05 15:22:13 +02:00
|
|
|
---
|
|
|
|
- name: Generate new ssh host key pair if necessary
|
2021-03-08 21:39:39 +01:00
|
|
|
become: true
|
|
|
|
community.crypto.openssh_keypair:
|
|
|
|
path: "/etc/ssh/ssh_host_{{ item }}_key"
|
|
|
|
type: "{{ item }}"
|
2020-08-05 15:22:13 +02:00
|
|
|
with_items: "{{ sshd__key_types }}"
|
|
|
|
when:
|
|
|
|
- sshd__manage_key_types | bool
|
|
|
|
notify:
|
|
|
|
- systemctl restart ssh
|
2021-07-13 11:14:53 +02:00
|
|
|
- service restart ssh
|
2020-08-05 15:22:13 +02:00
|
|
|
|
2021-03-08 21:39:39 +01:00
|
|
|
- name: make sure only the correct keys are available
|
|
|
|
ansible.builtin.file:
|
2020-08-05 15:22:13 +02:00
|
|
|
path: '/etc/ssh/ssh_host_{{ item }}_key'
|
|
|
|
state: absent
|
2021-03-08 21:39:39 +01:00
|
|
|
become: true
|
2020-08-05 15:22:13 +02:00
|
|
|
with_items:
|
|
|
|
- "{{ sshd__key_types_list | difference( sshd__key_types ) }}"
|
|
|
|
notify:
|
|
|
|
- systemctl restart ssh
|
2021-07-13 11:14:53 +02:00
|
|
|
- service restart ssh
|
2020-08-05 15:22:13 +02:00
|
|
|
|
2021-03-08 21:39:39 +01:00
|
|
|
- name: make sure only the correct pubkeys are available
|
|
|
|
ansible.builtin.file:
|
2020-08-05 15:22:13 +02:00
|
|
|
path: '/etc/ssh/ssh_host_{{ item }}_key.pub'
|
|
|
|
state: absent
|
2021-03-08 21:39:39 +01:00
|
|
|
become: true
|
2020-08-05 15:22:13 +02:00
|
|
|
with_items:
|
|
|
|
- "{{ sshd__key_types_list | difference( sshd__key_types ) }}"
|
|
|
|
notify:
|
|
|
|
- systemctl restart ssh
|
2021-07-13 11:14:53 +02:00
|
|
|
- service restart ssh
|