Create multiple Linodes in parallel with Linode CLI?
I have been working with your API for automated cloud deployments combined with StackScripts but have a question about the API/CLI. is it possible to use the Linode-CLI to deploy multiple Linodes at once, and even all in different network regions?
3 Replies
This is a great question! I've been playing around with the Linode CLI and Bash and this is what I've come up with. You can accomplish this with a relatively simple script, such as:
#!/bin/bash
# Enable Job Control, so that we can create Linodes in parallel
set -m
# Declare the array, "Region", which will contain the list of regions
# in which this script will be deploying Linodes
declare -a Region=("us-central" \
"us-east" \
"us-southeast" \
"us-west");
# Create 4 Linodes, each in a different region with the label "${Region[$i-1]}",
# where $i is the number of the Linode being created (in this case, 1-4)
# Run each Linode creation job in parallel by forcing each one into the
# background at runtime
for i in `seq 4`; do
linode-cli linodes create --label "${Region[$i-1]}" \
--region ${Region[$i-1]} \
--stackscript_id <stackscript_id> \
--stackscript_data <stackscript_data> \
--root_pass <super-secure-password> \
--image <preferred/image> \
--type g6-nanode-1 &
done
# Wait for all of the backgrounded jobs to finish
while [ 1 ]; do fg 2> /dev/null; [ $? == 1 ] && break; done
This script only accounts for 4 1GB Nanodes, each of which is in a different region of the US, but you can customize it however you like. I've tested this script and it works quite well for me.
Hello )
I have a question that is very vital not for myself only, IMO.
Is there a way to use CLI to make several CLONES of my existed Linode? Let it be the exact same region, plan, etc, for example. And could I use CSV to input the names of these new Linodes?
Actually, I think it could be useful even for the main Linode Dashboard as a function.