Created
March 11, 2016 14:26
-
-
Save willscripted/2d625ba1ea092be0c129 to your computer and use it in GitHub Desktop.
Bootstrap consul on top of etcd
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
#!/usr/bin/env bash | |
source /etc/environment | |
# If I am able to contact etcd2 | |
/usr/bin/etcdctl mkdir /consul/leader | |
if [[ $? -eq 0 ]]; then | |
echo "Master lock created, bootstrapping" | |
/bin/bash -c "/usr/bin/docker run \ | |
--net=host gliderlabs/consul-server:0.6 \ | |
-server \ | |
-bootstrap \ | |
-advertise $COREOS_PRIVATE_IPV4" | |
else | |
echo "Could not create master lock, assume follower" | |
joins="$(/usr/bin/etcdctl members list \ | |
| etcdctl member list \ | |
| awk '{ print $3 }' \ | |
| sed 's/peerURLs=//g' \ | |
| sed 's/,\?http:\/\//-retry-join /g' \ | |
| sed 's/:2380/ \\/g')" | |
/bin/bash -c "/usr/bin/docker run \ | |
--net=host gliderlabs/consul-server:0.6 \ | |
-server \ | |
$joins | |
-advertise $COREOS_PRIVATE_IPV4" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment