Created
February 9, 2016 01:27
-
-
Save cliffom/97905344ca35bc032745 to your computer and use it in GitHub Desktop.
Docker Cloud AWS Kickstart Script
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
#!/bin/bash | |
DEPLOYMENT_TIMEOUT="5m" | |
METADATA_SERVICE_URL="http://169.254.169.254/latest/meta-data" | |
apt-get update | |
# apt-get upgrade -y | |
apt-get install -y jq python-pip | |
pip install docker-cloud awscli | |
export DOCKERCLOUD_USER=<DOCKERCLOUD_USER> | |
export DOCKERCLOUD_PASS=<DOCKERCLOUD_PASS> | |
export AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID> | |
export AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY> | |
export AWS_DEFAULT_REGION=$(curl -fs ${METADATA_SERVICE_URL}/placement/availability-zone | sed 's/.$//') | |
docker-cloud node byo | sed -n 4p | source /dev/stdin | |
export DOCKERCLOUD_UUID=$(cat /etc/dockercloud/agent/dockercloud-agent.conf | jq -r .UUID) | |
echo "Waiting for node to be deployed..." | |
timeout $DEPLOYMENT_TIMEOUT bash -c "while [ \"\$(docker-cloud node inspect $DOCKERCLOUD_UUID | jq -r .state)\" != \"Deployed\" ]; do sleep 10; done;" | |
if [ $? != 0 ]; then echo "Node never came up"; exit 2; fi | |
INSTANCE_ID=$(curl -fs ${METADATA_SERVICE_URL}/instance-id) | |
EC2_TAGS=$(aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" | jq -r '.Tags | map(select(.Key)) | .[].Value') | |
for TAG in $EC2_TAGS | |
do | |
docker-cloud tag add -t $TAG $DOCKERCLOUD_UUID | |
done | |
usermod -a -G docker ubuntu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to @revett for the initial gist for Tutum: https://gist.github.com/revett/b2bf66e95589139529b5