-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Capgemini/15-terraform-digitalocean
15 terraform digitalocean
- Loading branch information
Showing
34 changed files
with
836 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[defaults] | ||
ssh_args = -o ControlMaster=auto -o ControlPersist=30m | ||
host_key_checking = no | ||
record_host_keys = no |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
DIGITALOCEAN_REGION=${DIGITALOCEAN_REGION:-lon1} | ||
DIGITALOCEAN_SSH_KEY=${DIGITALOCEAN_SSH_KEY:?"Need to set DIGITALOCEAN_SSH_KEY non-empty"} | ||
DIGITALOCEAN_SSH_FINGERPRINT=${DIGITALOCEAN_SSH_FINGERPRINT:?"Need to set DIGITALOCEAN_SSH_FINGERPRINT non-empty"} | ||
DIGITALOCEAN_API_TOKEN=${DIGITALOCEAN_API_TOKEN:?"Need to set DIGITALOCEAN_API_TOKEN non-empty"} | ||
DO_CLIENT_ID=${DO_CLIENT_ID:?"Need to set DO_CLIENT_ID non-empty"} | ||
DO_API_KEY=${DO_API_KEY:?"Need to set DO_API_KEY non-empty"} | ||
|
||
ATLAS_TOKEN=${ATLAS_TOKEN:?"Need to set ATLAS_TOKEN non-empty"} | ||
ATLAS_INFRASTRUCTURE=${ATLAS_INFRASTRUCTURE:-capgemini/infrastructure} | ||
MASTER_SIZE=${MASTER_SIZE:-512mb} | ||
SLAVE_SIZE=${SLAVE_SIZE:-512mb} | ||
NUM_SLAVES=${NUM_SLAVES:-1} | ||
MASTER_IMAGE=${MASTER_IMAGE:-11147507} | ||
SLAVE_IMAGE=${SLAVE_IMAGE:-11147507} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
# Use the config file specified in $APOLLO_CONFIG_FILE, or default to | ||
# config-default.sh. | ||
APOLLO_ROOT=$(dirname "${BASH_SOURCE}")/../.. | ||
source "${APOLLO_ROOT}/bootstrap/digitalocean/${APOLLO_CONFIG_FILE-"config-default.sh"}" | ||
|
||
verify_prereqs() { | ||
if [[ "$(which terraform)" == "" ]]; then | ||
echo -e "${color_red}Can't find terraform in PATH, please fix and retry.${color_norm}" | ||
exit 1 | ||
fi | ||
if [[ "$(which ansible-playbook)" == "" ]]; then | ||
echo -e "${color_red}Can't find ansible-playbook in PATH, please fix and retry.${color_norm}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
apollo_launch() { | ||
terraform_apply | ||
ansible_playbook_run | ||
open_urls | ||
} | ||
|
||
ansible_playbook_run() { | ||
pushd $APOLLO_ROOT | ||
DO_CLIENT_ID=$DO_CLIENT_ID DO_API_KEY=$DO_API_KEY ansible-playbook --user=root --inventory-file=$APOLLO_ROOT/inventory/digitalocean --extra-vars "consul_atlas_infrastructure=${ATLAS_INFRASTRUCTURE} consul_atlas_join=true consul_atlas_token=${ATLAS_TOKEN}" site.yml | ||
popd | ||
} | ||
|
||
apollo_down() { | ||
pushd $APOLLO_ROOT/terraform/digitalocean | ||
terraform destroy -var "do_token=${DIGITALOCEAN_API_TOKEN}" \ | ||
-var "key_file=${DIGITALOCEAN_SSH_KEY}" \ | ||
-var "ssh_fingerprint=${DIGITALOCEAN_SSH_FINGERPRINT}" \ | ||
-var "region=${DIGITALOCEAN_REGION}" | ||
popd | ||
} | ||
|
||
terraform_apply() { | ||
pushd $APOLLO_ROOT/terraform/digitalocean | ||
terraform apply -var "do_token=${DIGITALOCEAN_API_TOKEN}" \ | ||
-var "key_file=${DIGITALOCEAN_SSH_KEY}" \ | ||
-var "ssh_fingerprint=${DIGITALOCEAN_SSH_FINGERPRINT}" \ | ||
-var "instance_size.master=${MASTER_SIZE}" \ | ||
-var "instance_size.slave=${SLAVE_SIZE}" \ | ||
-var "image.master=${MASTER_IMAGE}" \ | ||
-var "image.slave=${SLAVE_IMAGE}" \ | ||
-var "slaves=${NUM_SLAVES}" \ | ||
-var "region=${DIGITALOCEAN_REGION}" | ||
popd | ||
} | ||
|
||
open_urls() { | ||
pushd $APOLLO_ROOT/terraform/digitalocean | ||
/usr/bin/open "http://$(terraform output master.1.ip):5050" | ||
/usr/bin/open "http://$(terraform output master.1.ip):8080" | ||
/usr/bin/open "http://$(terraform output master.1.ip):8500" | ||
popd | ||
} |
Oops, something went wrong.