github.com/inflatablewoman/deis@v1.0.1-0.20141111034523-a4511c46a6ce/contrib/digitalocean/provision-do-cluster.sh (about) 1 #!/usr/bin/env bash 2 # 3 # Usage: ./provision-do-cluster.sh <REGION_ID> <SSH_ID> <SIZE> 4 # 5 6 set -e 7 8 listcontains() { 9 for i in $1; do 10 [[ $i = $2 ]] && return 0 11 done 12 return 1 13 } 14 15 THIS_DIR=$(cd $(dirname $0); pwd) # absolute path 16 CONTRIB_DIR=$(dirname $THIS_DIR) 17 18 REGION_SLUG=$1 19 SSH_ID=$2 20 SIZE=$3 21 22 source $CONTRIB_DIR/utils.sh 23 24 if [ -z "$3" ]; then 25 echo_red 'Usage: provision-do-cluster.sh <REGION_SLUG> <SSH_ID> <SIZE>' 26 exit 1 27 fi 28 29 # check for DO tools in $PATH 30 if ! which docl > /dev/null; then 31 echo_red 'Please install the docl gem and ensure it is in your $PATH.' 32 exit 1 33 fi 34 35 if [ -z "$DEIS_NUM_INSTANCES" ]; then 36 DEIS_NUM_INSTANCES=3 37 fi 38 39 regions_without_private_networking_or_metadata="nyc1 nyc2 ams1 ams2 sfo1" 40 if listcontains "$regions_without_private_networking_or_metadata" "$REGION_SLUG"; 41 then 42 echo_red "Invalid region. Please supply a region with private networking & metadata support." 43 echo_red "Valid regions are (use the name in brackets):" 44 docl regions --private_networking --metadata 45 exit 1 46 fi 47 48 # check that the CoreOS user-data file is valid 49 $CONTRIB_DIR/util/check-user-data.sh 50 51 # TODO: Make it follow a specific ID once circumstances allow us to do so. 52 BASE_IMAGE_ID='coreos-alpha' 53 54 if [ -z "$BASE_IMAGE_ID" ]; then 55 echo_red "DigitalOcean Image not found..." 56 exit 1 57 fi 58 59 # launch the Deis cluster on DigitalOcean 60 i=1 ; while [[ $i -le $DEIS_NUM_INSTANCES ]] ; do \ 61 NAME=deis-$i 62 echo_yellow "Provisioning ${NAME}..." 63 docl create $NAME $BASE_IMAGE_ID $SIZE $REGION_SLUG --key=$SSH_ID --private-networking --user-data=$CONTRIB_DIR/coreos/user-data --wait 64 ((i = i + 1)) ; \ 65 done 66 67 echo_green "Your Deis cluster has successfully deployed to DigitalOcean." 68 echo_green "Please continue to follow the instructions in the README."