I have a bash script that fetches running selenium nodes, grabs their ID, and SSHs into them to perform configuration tasks.
#!/bin/bash
# retrieve list of running vagrant machines, filter them to selenium nodes, and
# process provisioning for each
vagrant global-status --prune | grep "selenium_node" | while read -ra line ; do
echo -e "\033[32mBEGININNG ${line[1]} PROVISIONING\033[37m"
# adding this statement causes the loop to exit after 1 iteration
vagrant ssh ${line[0]} -- "
echo 'it runs'
"
echo -e "\033[32mEND ${line[1]} PROVISION\033[37m"
done
My problem is that running vagrant ssh
causes the loop to terminate after the first iteration. I confirmed this by removing 'vagrant ssh' and the results were that both the BEGINNING and END echo commands ran successfully for every iteration (in my case - two iterations).
What's stranger is that the loop DOES complete it's first iteration (as evinced by the END echo line completing), it just doesn't run any further iterations.
Also, I've confirmed that it's not just neglecting to show the output from the other iterations. It never performs any operations on the other machines.