Skip to content

Commit b7e2dbc

Browse files
committed
persist login hostkey across rebuilds
1 parent bf74764 commit b7e2dbc

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
3+
- name: Ensure hostkeys directory exists on persistent storage
4+
file:
5+
path: "{{ appliances_state_dir }}/hostkeys/{{ inventory_hostname }}"
6+
state: directory
7+
owner: root
8+
group: root
9+
mode: 0600
10+
11+
- name: Copy hostkeys from persistent storage
12+
# won't fail if no keys are in persistent storage
13+
copy:
14+
src: "{{ appliances_state_dir }}/hostkeys/{{ inventory_hostname }}/"
15+
dest: /etc/ssh/
16+
remote_src: true
17+
18+
- name: Find hostkeys
19+
find:
20+
path: /etc/ssh/
21+
patterns: ssh_host_*_key*
22+
register: _find_ssh_keys
23+
24+
- name: Persist hostkeys
25+
copy:
26+
dest: "{{ appliances_state_dir }}/hostkeys/{{ inventory_hostname }}/"
27+
src: "{{ item }}"
28+
remote_src: true
29+
mode: preserve
30+
loop: "{{ _find_ssh_keys.files | map(attribute='path') }}"
31+
32+
- meta: reset_connection
33+

slurm-infra.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
loop_control:
2121
loop_var: host
2222

23+
- name: Persist login hostkey across rebuilds
24+
hosts: login
25+
gather_facts: no
26+
become: yes
27+
roles:
28+
- persist_hostkeys
29+
2330
# Ensure that the secrets are generated and persisted on the control host
2431
- name: Generate and persist secrets
2532
hosts: control

0 commit comments

Comments
 (0)