Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 59 lines (48 sloc) 1.83 KB
#!/bin/bash
set -x
# this is the name of the image to build the contains with
ubuntu_version="Ubuntu 16.04"
# this is the name of the key to use for the images
key_name="don h3abionet"
associate_ip() {
nova floating-ip-associate $1 \
$(nova floating-ip-list|grep ' - '|
head -n 1|awk -F'|' '{print $3}');
}
nova_opts=(--image "$ubuntu_version" --security-groups "default,remote SSH" --key-name "$key_name")
# create the consul1 server
nova boot --flavor m1.small "${nova_opts[@]}" \
--block-device "source=volume,id=d5850179-7883-4cea-8cc6-b76f568fdf73,dest=volume,shutdown=preserve" \
--user-data \
<(write-mime-multipart general_config consul_config \
ssh_keys_config ) \
--poll \
consul0;
CONSUL_IP=$(nova show --minimal consul0|
grep network |cut -d '|' -f 3|cut -d, -f 1|
sed 's/ *//g')
## You can use this to associate a floating ip with the consul
associate_ip consul0
# create the manager servers
for a in 0 1; do
nova boot --flavor m1.small "${nova_opts[@]}" --user-data \
<(write-mime-multipart general_config manager_config \
ssh_keys_config |sed "s/___CONSUL_IP___/$CONSUL_IP/") \
manager$a;
associate_ip manager$a;
done;
# create the nodes
for a in $(seq 0 4); do
nova boot --flavor m1.xlarge "${nova_opts[@]}" --user-data \
<(write-mime-multipart general_config node_config \
ssh_keys_config |sed "s/___CONSUL_IP___/$CONSUL_IP/") \
node$a;
associate_ip node$a;
done;
cat - <<EOF
After waiting for the nodes to be created, you should be
able to connect to one of the two manager nodes and check
the status of the build:
nova ssh -i ssh_identity_file manager0 --login ubuntu \
--extra-opts='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
EOF