Last active
March 15, 2016 15:41
-
-
Save burdandrei/205ef481a7298fa885a0 to your computer and use it in GitHub Desktop.
User data for starting consul on node start
This file contains hidden or 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 | |
# | |
# Bring ECS Agent config and start consul | |
DC=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone/ | rev | cut -c 2- | rev) | |
ADVERTISE_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) | |
ECS_CLUSTER='example' | |
yum install -y aws-cli | |
aws s3 cp s3://ops-yotpo/docker/ecs/ecs.config /etc/ecs/ecs.config | |
echo ECS_CLUSTER=$ECS_CLUSTER >> /etc/ecs/ecs.config | |
docker run -d \ | |
--restart always \ | |
--name consul \ | |
-h $HOSTNAME \ | |
-p 8300:8300 \ | |
-p 8301:8301 \ | |
-p 8301:8301/udp \ | |
-p 8302:8302 \ | |
-p 8302:8302/udp \ | |
-p 8400:8400 \ | |
-p 8500:8500 \ | |
-p 8600:8600/udp \ | |
gliderlabs/consul-agent \ | |
-advertise=$ADVERTISE_IP \ | |
-dc="${DC}" \ | |
-join=0.${DC}.consul.example.com \ | |
-join=1.${DC}.consul.example.com \ | |
-join=2.${DC}.consul.example.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment