zuul-jobs/roles/add-build-sshkey/tasks/create-key-and-replace.yaml
Tobias Henkel b7f14309a7
Support ssh-enabled windows hosts in add-build-sshkey
The winrm protocol is very inefficient when copying things to the node
therefore it makes sense to have working ssh connections on windows
hosts. Adding windows support to the add-build-sshkey role is the
first step towards this.

Change-Id: I5591b39b0107385fec8c6df1fbe6c316177d32e6
2020-04-07 11:12:26 +02:00

39 lines
1.2 KiB
YAML

- name: Create Temp SSH key
command: ssh-keygen -t rsa -N '' -C 'zuul-build-sshkey' -f {{ zuul_temp_ssh_key }}
delegate_to: localhost
run_once: true
- name: Remote setup ssh keys (linux)
include: remote-linux.yaml
when: ansible_os_family != "Windows"
- name: Remote setup ssh keys (windows)
include: remote-windows.yaml
when: ansible_os_family == "Windows"
- name: Remove master key from local agent
# The master key has a filename, all others (e.g., per-project keys)
# have "(stdin)" as a comment.
sshagent_remove_keys:
remove: '^(?!\(stdin\)).*'
delegate_to: localhost
run_once: true
- name: Add back temp key
command: ssh-add {{ zuul_temp_ssh_key }}
delegate_to: localhost
run_once: true
- name: Verify we can still SSH to all nodes
ping:
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
delegate_to: localhost
when:
- ansible_os_family == "Windows"
# Only run if we successfully configured the host. If not the host doesn't support
# ssh and the check shall not break them.
- windows_remote_ssh is succeeded