Last active
March 13, 2022 13:50
-
-
Save johnroyer/0c67f14b376ce2d23e6aef16cd7d4e2f to your computer and use it in GitHub Desktop.
Automatically create multiple node via linode-cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# usage: | |
# linodecreate NUM | |
# | |
# NUM is the number of node you want to create | |
genpassword() { | |
PASS=$( tr -dc A-Za-z0-9 </dev/urandom | head -c 5 | tr '[:upper:]' '[:lower:]' ) | |
echo -n "prefix-$PASS" | |
} | |
if [[ "$@" =~ ^[1-9]+[0-9]*$ ]]; then | |
RANGE=$( seq 1 "$@" ) | |
else | |
echo "wrong number" | |
exit 255 | |
fi | |
for N in $RANGE; do | |
PASS="$( genpassword )" | |
IP=$( linode-cli linodes create --json --tag AUTO_CREATED --root_pass "${PASS}" | jq -r '.[0].ipv4[0]' ) | |
echo -e "${IP} \t ${PASS}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment