mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-05-02 15:06:36 +00:00
- add support to provision VMs on googlecloud - refactor the way we define the project used by Terraform (we'll now use the GOOGLE_PROJECT environment variable, and if it's not set, we'll set it automatically by getting the default project from the gcloud CLI)
45 lines
1.3 KiB
Bash
45 lines
1.3 KiB
Bash
# This file can be sourced in order to directly run commands on
|
|
# a group of VMs whose IPs are located in ips.txt of the directory in which
|
|
# the command is run.
|
|
|
|
pssh() {
|
|
if [ -z "$TAG" ]; then
|
|
>/dev/stderr echo "Variable \$TAG is not set."
|
|
return
|
|
fi
|
|
|
|
HOSTFILE="tags/$TAG/ips.txt"
|
|
|
|
[ -f $HOSTFILE ] || {
|
|
>/dev/stderr echo "Hostfile $HOSTFILE not found."
|
|
return
|
|
}
|
|
|
|
echo "[parallel-ssh] $@"
|
|
|
|
# There are some routers that really struggle with the number of TCP
|
|
# connections that we open when deploying large fleets of clusters.
|
|
# We're adding a 1 second delay here, but this can be cranked up if
|
|
# necessary - or down to zero, too.
|
|
sleep ${PSSH_DELAY_PRE-1}
|
|
|
|
# When things go wrong, it's convenient to ask pssh to show the output
|
|
# of the failed command. Let's make that easy with a DEBUG env var.
|
|
if [ "$DEBUG" ]; then
|
|
PSSH_I=-i
|
|
else
|
|
PSSH_I=""
|
|
fi
|
|
|
|
$(which pssh || which parallel-ssh) -h $HOSTFILE -l ubuntu \
|
|
--par ${PSSH_PARALLEL_CONNECTIONS-100} \
|
|
--timeout 300 \
|
|
-O LogLevel=ERROR \
|
|
-O IdentityFile=tags/$TAG/id_rsa \
|
|
-O UserKnownHostsFile=/dev/null \
|
|
-O StrictHostKeyChecking=no \
|
|
-O ForwardAgent=yes \
|
|
$PSSH_I \
|
|
"$@"
|
|
}
|