Last active
April 11, 2017 03:41
-
-
Save garystafford/f2469d55d2a206b23ea648ebfbc0a343 to your computer and use it in GitHub Desktop.
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
# Advertised Consul IP | |
export ec2_server1_private_ip=$(aws ec2 describe-instances \ | |
--filters Name='tag:Name,Values=tf-instance-consul-server-1' \ | |
--output text --query 'Reservations[*].Instances[*].PrivateIpAddress') | |
echo "consul-server-1 private ip: ${ec2_server1_private_ip}" |
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
# Deploy Consul Server 1 | |
ec2_public_ip=$(aws ec2 describe-instances \ | |
--filters Name='tag:Name,Values=tf-instance-consul-server-1' \ | |
--output text --query 'Reservations[*].Instances[*].PublicIpAddress') | |
consul_server="consul-server-1" | |
ssh -oStrictHostKeyChecking=no -T \ | |
-i ~/.ssh/consul_aws_rsa \ | |
ubuntu@${ec2_public_ip} << EOSSH | |
docker run -d \ | |
--net=host \ | |
--hostname ${consul_server} \ | |
--name ${consul_server} \ | |
--env "SERVICE_IGNORE=true" \ | |
--env "CONSUL_CLIENT_INTERFACE=eth0" \ | |
--env "CONSUL_BIND_INTERFACE=eth0" \ | |
--volume /home/ubuntu/consul/data:/consul/data \ | |
--publish 8500:8500 \ | |
consul:latest \ | |
consul agent -server -ui -client=0.0.0.0 \ | |
-bootstrap-expect=3 \ | |
-advertise='{{ GetInterfaceIP "eth0" }}' \ | |
-data-dir="/consul/data" | |
sleep 5 | |
docker logs consul-server-1 | |
docker exec -i consul-server-1 consul members | |
EOSSH |
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
# Deploy Consul Server 2 | |
ec2_public_ip=$(aws ec2 describe-instances \ | |
--filters Name='tag:Name,Values=tf-instance-consul-server-2' \ | |
--output text --query 'Reservations[*].Instances[*].PublicIpAddress') | |
consul_server="consul-server-2" | |
ssh -oStrictHostKeyChecking=no -T \ | |
-i ~/.ssh/consul_aws_rsa \ | |
ubuntu@${ec2_public_ip} << EOSSH | |
docker run -d \ | |
--net=host \ | |
--hostname ${consul_server} \ | |
--name ${consul_server} \ | |
--env "SERVICE_IGNORE=true" \ | |
--env "CONSUL_CLIENT_INTERFACE=eth0" \ | |
--env "CONSUL_BIND_INTERFACE=eth0" \ | |
--volume /home/ubuntu/consul/data:/consul/data \ | |
--publish 8500:8500 \ | |
consul:latest \ | |
consul agent -server -ui -client=0.0.0.0 \ | |
-advertise='{{ GetInterfaceIP "eth0" }}' \ | |
-retry-join="${ec2_server1_private_ip}" \ | |
-data-dir="/consul/data" | |
sleep 5 | |
docker logs consul-server-2 | |
docker exec -i consul-server-2 consul members | |
EOSSH |
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
# Deploy Consul Server 3 | |
ec2_public_ip=$(aws ec2 describe-instances \ | |
--filters Name='tag:Name,Values=tf-instance-consul-server-3' \ | |
--output text --query 'Reservations[*].Instances[*].PublicIpAddress') | |
consul_server="consul-server-3" | |
ssh -oStrictHostKeyChecking=no -T \ | |
-i ~/.ssh/consul_aws_rsa \ | |
ubuntu@${ec2_public_ip} << EOSSH | |
docker run -d \ | |
--net=host \ | |
--hostname ${consul_server} \ | |
--name ${consul_server} \ | |
--env "SERVICE_IGNORE=true" \ | |
--env "CONSUL_CLIENT_INTERFACE=eth0" \ | |
--env "CONSUL_BIND_INTERFACE=eth0" \ | |
--volume /home/ubuntu/consul/data:/consul/data \ | |
--publish 8500:8500 \ | |
consul:latest \ | |
consul agent -server -ui -client=0.0.0.0 \ | |
-advertise='{{ GetInterfaceIP "eth0" }}' \ | |
-retry-join="${ec2_server1_private_ip}" \ | |
-data-dir="/consul/data" | |
sleep 5 | |
docker logs consul-server-3 | |
docker exec -i consul-server-3 consul members | |
EOSSH |
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
# Output Consul Web UI URL | |
ec2_public_ip=$(aws ec2 describe-instances \ | |
--filters Name='tag:Name,Values=tf-instance-consul-server-1' \ | |
--output text --query 'Reservations[*].Instances[*].PublicIpAddress') | |
echo " " | |
echo "*** Consul UI: http://${ec2_public_ip}:8500/ui/ ***" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment