zuul-jobs/roles/add-build-sshkey/tasks/create-key-and-replace.yaml
Paul Belanger bbc4c5b920
Only run once our delegate_to locahost commands
In a multi node setup, we only want this logic to be run one across
all hosts.

Change-Id: I4ebb62f76d4ff7363635bee7073c2d7e8f0ad70e
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-21 16:21:13 -04:00

24 lines
580 B
YAML

- name: Create Temp SSH key
command: ssh-keygen -t rsa -b 1024 -N '' -f {{ zuul_temp_ssh_key }}
delegate_to: localhost
run_once: true
- name: Distribute it to all nodes
authorized_key:
user: "{{ ansible_ssh_user }}"
state: present
key: "{{ lookup('file', zuul_temp_ssh_key + '.pub') }}"
- name: Remove all keys from local agent
command: ssh-add -D
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: