mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-21 22:07:13 +00:00
- add support for Digital Ocean (through Terraform) - add support for per-cluster SSH key (hackish for now) - pre-load Kubernetes APT GPG key (because of GCS outage)
42 lines
997 B
Bash
42 lines
997 B
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] $@"
|
|
export PSSH=$(which pssh || which parallel-ssh)
|
|
|
|
case "$INFRACLASS" in
|
|
hetzner) LOGIN=root ;;
|
|
linode) LOGIN=root ;;
|
|
*) LOGIN=ubuntu ;;
|
|
esac
|
|
|
|
if [ -f "tags/$TAG/id_rsa" ]; then
|
|
KEYFLAG="-O IdentityFile=tags/$TAG/id_rsa"
|
|
else
|
|
KEYFLAG=""
|
|
fi
|
|
|
|
$PSSH $KEYFLAG -h $HOSTFILE -l $LOGIN \
|
|
--par 100 \
|
|
--timeout 300 \
|
|
-O LogLevel=ERROR \
|
|
-O UserKnownHostsFile=/dev/null \
|
|
-O StrictHostKeyChecking=no \
|
|
-O ForwardAgent=yes \
|
|
"$@"
|
|
}
|