From dd59a158e85900eb1e6fc8eba980bbc284d01162 Mon Sep 17 00:00:00 2001 From: Albin Vass Date: Thu, 9 Jul 2020 14:00:07 +0200 Subject: [PATCH] Enforce BatchMode when setting up ssh for windows Change-Id: I62742dc43df5276f51805e259229405ba9b19362 --- roles/add-build-sshkey/tasks/create-key-and-replace.yaml | 2 +- roles/add-build-sshkey/tasks/remote-windows.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/add-build-sshkey/tasks/create-key-and-replace.yaml b/roles/add-build-sshkey/tasks/create-key-and-replace.yaml index 1202ab13d..2c898546e 100644 --- a/roles/add-build-sshkey/tasks/create-key-and-replace.yaml +++ b/roles/add-build-sshkey/tasks/create-key-and-replace.yaml @@ -24,7 +24,7 @@ when: ansible_os_family != "Windows" - name: Verify we can still SSH to all nodes (windows) - command: ssh -o ConnectTimeout=10 {{ ansible_user }}@{{ ansible_host }} echo success + command: ssh -o BatchMode=yes -o ConnectTimeout=10 {{ ansible_user }}@{{ ansible_host }} echo success delegate_to: localhost when: - ansible_os_family == "Windows" diff --git a/roles/add-build-sshkey/tasks/remote-windows.yaml b/roles/add-build-sshkey/tasks/remote-windows.yaml index b5aff4a5b..9365c4364 100644 --- a/roles/add-build-sshkey/tasks/remote-windows.yaml +++ b/roles/add-build-sshkey/tasks/remote-windows.yaml @@ -4,17 +4,17 @@ set -eu echo "Add node to known_hosts" - ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no {{ ansible_user }}@{{ ansible_host }} echo success + 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" - scp {{ zuul_temp_ssh_key }} {{ ansible_user }}@{{ ansible_host }}:.ssh/id_rsa - scp {{ zuul_temp_ssh_key }}.pub {{ ansible_user }}@{{ ansible_host }}:.ssh/id_rsa.pub + 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 {{ ansible_user }}@{{ ansible_host }} "type .ssh\\id_rsa.pub >> .ssh\\authorized_keys" + ssh -o BatchMode=yes {{ ansible_user }}@{{ ansible_host }} "type .ssh\\id_rsa.pub >> .ssh\\authorized_keys" register: windows_remote_ssh # Ignore errors here because this should not break non-ssh enabled windows hosts ignore_errors: true