+# Macro: integration-copy-ssh-keys
+# Operation: Copy ssh public key used as authentication for robot
+# Used by: {project}-csit-* job templates
+
+- builder:
+ name: integration-copy-ssh-keys
+ builders:
+ - shell: |
+ #!/bin/bash
+ function copy-ssh-keys-to-slave() {
+ RETRIES=30
+ for j in $(seq 1 $RETRIES); do
+ if `ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub "jenkins@${i}" > /dev/null 2>&1`; then
+ ssh jenkins@${i} 'echo "$(facter ipaddress_eth0) $(/bin/hostname)" | sudo tee -a /etc/hosts'
+ echo "Successfully copied public keys to slave ${i}"
+ break
+ elif [ $j -eq $RETRIES ]; then
+ echo "SSH not responding on ${i} after $RETIRES tries. Giving up."
+ exit 1
+ else
+ echo "SSH not responding on ${i}. Retrying in 10 seconds..."
+ sleep 10
+ fi
+ done
+ }
+
+ echo "OpenStack IPS are ${JCLOUDS_IPS}"
+
+ IFS=',' read -ra ADDR <<< "${JCLOUDS_IPS}"
+
+ for i in "${ADDR[@]}"; do
+ copy-ssh-keys-to-slave &
+ done
+
+ wait
+ echo "Copying ssh keys complete."
+