2 function copy-ssh-keys-to-slave() {
4 for j in $(seq 1 $RETRIES); do
5 if `ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub "jenkins@${i}" > /dev/null 2>&1`; then
6 ssh jenkins@${i} 'echo "$(facter ipaddress_eth0) $(/bin/hostname)" | sudo tee -a /etc/hosts'
7 echo "Successfully copied public keys to slave ${i}"
9 elif [ $j -eq $RETRIES ]; then
10 echo "SSH not responding on ${i} after $RETIRES tries. Giving up."
13 echo "SSH not responding on ${i}. Retrying in 10 seconds..."
19 # TODO: Remove condition when we no longer use JClouds plugin
20 if [ -z "$JCLOUDS_IPS" ]; then
21 # If JCLOUDS_IPS is not set then we will spawn instances with
23 source $WORKSPACE/.venv-openstack/bin/activate
24 CONTROLLER_IPS=`openstack --os-cloud rackspace stack show -f json -c outputs $STACK_NAME | jq -r '.outputs[] | select(.output_key=="vm_0_ips") | .output_value[]'`
25 MININET_IPS=`openstack --os-cloud rackspace stack show -f json -c outputs $STACK_NAME | jq -r '.outputs[] | select(.output_key=="vm_1_ips") | .output_value[]'`
26 ADDR=($CONTROLLER_IPS $MININET_IPS)
28 echo "OpenStack IPS are ${JCLOUDS_IPS}"
29 IFS=',' read -ra ADDR <<< "${JCLOUDS_IPS}"
33 for i in "${ADDR[@]}"; do
34 ( copy-ssh-keys-to-slave ) &
35 # Store PID of process
39 # Detect when a process failed to copy ssh keys and fail build
42 echo "Process $p successfully copied ssh keys."
44 echo "Process $p failed to copy ssh keys."
48 echo "Copying ssh keys complete."