From bbc4c5b920ff397a349c33aa44f9bbc88217a007 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Fri, 21 Jul 2017 16:21:13 -0400 Subject: [PATCH] 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 --- roles/add-build-sshkey/tasks/create-key-and-replace.yaml | 3 +++ roles/add-build-sshkey/tasks/main.yaml | 1 + 2 files changed, 4 insertions(+) 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 87ddbbe72..e26ceaa2f 100644 --- a/roles/add-build-sshkey/tasks/create-key-and-replace.yaml +++ b/roles/add-build-sshkey/tasks/create-key-and-replace.yaml @@ -1,6 +1,7 @@ - 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: @@ -11,10 +12,12 @@ - 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: diff --git a/roles/add-build-sshkey/tasks/main.yaml b/roles/add-build-sshkey/tasks/main.yaml index 3ffd79110..1a2d4b628 100644 --- a/roles/add-build-sshkey/tasks/main.yaml +++ b/roles/add-build-sshkey/tasks/main.yaml @@ -3,6 +3,7 @@ path: "{{ zuul_temp_ssh_key }}" register: zuul_temp_ssh_key_stat delegate_to: localhost + run_once: true failed_when: false - name: Create a new key in workspace based on build UUID