Skip to content

Instantly share code, notes, and snippets.

@johnroyer
Last active March 13, 2022 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnroyer/0c67f14b376ce2d23e6aef16cd7d4e2f to your computer and use it in GitHub Desktop.
Save johnroyer/0c67f14b376ce2d23e6aef16cd7d4e2f to your computer and use it in GitHub Desktop.
Automatically create multiple node via linode-cli
#!/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