zuul-jobs/roles/add-build-sshkey/tasks/remote-windows.yaml
GomathiselviS e693c19d9a Create a template for ssh-key and size
Signed-off-by: GomathiselviS <gomathiselvi@gmail.com>
Change-Id: I0d34d3a0a40ea612dc06099b74d27216630f97c9
2021-03-17 09:54:45 -04:00

26 lines
1.3 KiB
YAML

- name: Configure ssh on remote node
delegate_to: localhost
shell: |+
set -eu
echo "Add node to known_hosts"
ssh -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=no {{ ansible_user }}@{{ ansible_host }} echo success
echo
# 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/{{ zuul_ssh_key_dest }}
scp -B {{ zuul_temp_ssh_key }}.pub {{ ansible_user }}@{{ ansible_host }}:.ssh/{{ zuul_ssh_key_dest }}.pub
echo "Add build ssh keys to authorized_keys"
{% if win_admin_ssh | default(false) %}
ssh -o BatchMode=yes {{ ansible_user }}@{{ ansible_host }} cmd /c "type .ssh\\{{ zuul_ssh_key_dest }}.pub >> %programdata%\\ssh\\administrators_authorized_keys"
{% else %}
ssh -o BatchMode=yes {{ ansible_user }}@{{ ansible_host }} cmd /c "type .ssh\\{{ zuul_ssh_key_dest }}.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