2 echo "----------> Copy ssh public keys to csit lab"
4 source $WORKSPACE/.venv-openstack/bin/activate
6 function copy-ssh-keys-to-slave() {
8 for j in $(seq 1 $RETRIES); do
9 if `ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub "jenkins@${i}" > /dev/null 2>&1`; then
10 ssh jenkins@${i} 'echo "$(facter ipaddress_eth0) $(/bin/hostname)" | sudo tee -a /etc/hosts'
11 echo "Successfully copied public keys to slave ${i}"
13 elif [ $j -eq $RETRIES ]; then
14 echo "SSH not responding on ${i} after $RETIRES tries. Giving up."
17 echo "SSH not responding on ${i}. Retrying in 10 seconds..."
21 # ping test to see if connectivity is available
22 if ping -c1 ${i} &> /dev/null; then
23 echo "Ping to ${i} successful."
25 echo "Ping to ${i} failed."
30 # Print the Stack outputs parameters so that we can identify which IPs belong
32 openstack --os-cloud rackspace stack show -c outputs $STACK_NAME
34 ADDR=(`openstack --os-cloud rackspace stack show -f json -c outputs $STACK_NAME | \
36 select(.output_key | match("^vm_[0-9]+_ips\$")) | \
37 .output_value | .[]'`)
39 for i in "${ADDR[@]}"; do
40 ( copy-ssh-keys-to-slave ) &
41 # Store PID of process
45 # Detect when a process failed to copy ssh keys and fail build
48 echo "Process $p successfully copied ssh keys."
50 echo "Process $p failed to copy ssh keys."
54 echo "Copying ssh keys complete."