add-build-sshkey: Ensure .ssh exists, enable admin authorized_keys

Change-Id: I54608635711a4936ce01c3859706236627d80af9
This commit is contained in:
Albin Vass 2020-07-09 21:02:14 +02:00
parent dd59a158e8
commit a7faab5819

View File

@ -10,11 +10,16 @@
# We use scp here as this is much more performant than ansible copy
echo "Copy build ssh keys to node"
ssh -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=no {{ ansible_user }}@{{ ansible_host }} powershell "md -Force -Path .ssh"
scp -B {{ zuul_temp_ssh_key }} {{ ansible_user }}@{{ ansible_host }}:.ssh/id_rsa
scp -B {{ zuul_temp_ssh_key }}.pub {{ ansible_user }}@{{ ansible_host }}:.ssh/id_rsa.pub
echo "Add build ssh keys to authorized_keys"
ssh -o BatchMode=yes {{ ansible_user }}@{{ ansible_host }} "type .ssh\\id_rsa.pub >> .ssh\\authorized_keys"
{% if win_admin_ssh | default(false) %}
ssh -o BatchMode=yes {{ ansible_user }}@{{ ansible_host }} cmd "type .ssh\\id_rsa.pub >> %programdata%\\ssh\\administrators_authorized_keys"
{% else %}
ssh -o BatchMode=yes {{ ansible_user }}@{{ ansible_host }} cmd "type .ssh\\id_rsa.pub >> .ssh\\authorized_keys"
{% endif %}
register: windows_remote_ssh
# Ignore errors here because this should not break non-ssh enabled windows hosts
ignore_errors: true