Last active
August 24, 2016 13:34
-
-
Save bluk/a94551f54863e96ee78e to your computer and use it in GitHub Desktop.
Consul Bootstrap on CoreOS
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 | |
# From https://gist.github.com/philips/56fa3f5dae9060fbd100 | |
source /etc/environment | |
name=$(cat /etc/machine-id) | |
if [ ! -f /opt/consul ]; then | |
mkdir /opt | |
mkdir /var/lib/consul | |
cd /tmp | |
wget https://dl.bintray.com/mitchellh/consul/0.4.0_linux_amd64.zip | |
unzip 0.4.0_linux_amd64.zip | |
mv consul /opt/consul | |
chmod +x /opt/consul | |
wget https://gist.githubusercontent.com/bluk/76911335faf4008c18ed/raw/2169ad1b886e929802387229bd3159a742ae7c69/consul-config.json | |
mv consul-config.json /opt/consul-config.json | |
fi | |
FLAGS="-help " | |
if etcdctl mk /consul.io/bootstrap/started true; then | |
flags="${flags} -bootstrap" | |
else | |
echo "This cluster has already been bootstrapped" | |
fi | |
etcdctl set /consul.io/bootstrap/machines/${name} ${COREOS_PRIVATE_IPV4} | |
flags=$(etcdctl ls /consul.io/bootstrap/machines | while read line; do | |
ip=$(etcdctl get ${line}) | |
echo ${flags} -join ${ip} | |
done) | |
flags="${flags} -config-file /opt/consul-config.json" | |
echo ${flags} | |
/opt/consul agent -data-dir /var/lib/consul -server ${flags} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment