make unlock user aware

master
Michael Wilson 3 years ago
parent bf8db4acb8
commit 9b84a7f3ea
  1. 17
      hetzner/autoinstall/tasks/unlock.yml

@ -1,5 +1,6 @@
- name: send unlock command
raw: "printf '{{ autoinstall_disk_encryption_secret }}' | cryptroot-unlock"
- name: wait for boot
wait_for:
delay: 5
@ -8,3 +9,19 @@
search_regex: OpenSSH|dropbear
timeout: 300
delegate_to: localhost
- name: test ssh connection with {{ ansible_user }}
shell: |
ssh -p{{ ansible_ssh_port|default(22) }} \
-i {{ ansible_ssh_private_key_file }} \
-oStrictHostkeyChecking=no \
-oBatchMode=yes \
{{ ansible_user }}@{{ ansible_ssh_host }} echo test
register: connection_test
ignore_errors: yes
changed_when: False
- name: set ansible_user
set_fact:
ansible_ssh_user: "{{ bootstrap_user|default('root') }}"
when: connection_test is succeeded

Loading…
Cancel
Save