Created
April 22, 2015 07:14
-
-
Save darron/93d64a999746cfb4bb4b to your computer and use it in GitHub Desktop.
User-data for Third Node.
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 | |
export CONNECT_TO="ip-address-of-first-node" | |
export PRIVATE_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/address) | |
export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address) | |
export CONSUL_KEY="from-the-first-node" | |
export SWARM_TOKEN="from-the-first-node" | |
ufw allow 8300 | |
ufw allow 8301 | |
ufw allow from $CONNECT_TO | |
service consul stop | |
rm -rf /var/cache/octohost/* | |
sudo cat > /etc/consul.d/default.json << EOL | |
{ | |
"data_dir": "/var/cache/octohost", | |
"server": true, | |
"client_addr": "0.0.0.0", | |
"advertise_addr": "$PRIVATE_IPV4", | |
"datacenter": "nyc3", | |
"node_name": "octo3", | |
"enable_syslog": true, | |
"encrypt": "$CONSUL_KEY" | |
} | |
EOL | |
sudo cat > /etc/default/consul << EOL | |
# Options for Consul | |
# See https://consul.io for more details | |
GOMAXPROCS=4 | |
CONSUL_OPTIONS="-bootstrap-expect 3" | |
EOL | |
service consul start | |
sleep 5 | |
consul join $CONNECT_TO | |
service docker stop | |
rm -f /etc/docker/key.json | |
service docker start | |
docker run -d swarm join --addr=$PRIVATE_IPV4:4243 token://$SWARM_TOKEN | |
docker run --rm swarm list token://$SWARM_TOKEN | |
docker run -e SETTINGS_FLAVOR=s3 -e AWS_BUCKET=octoregistry -e AWS_KEY=KEY_GOES_HERE -e AWS_SECRET=SECRET_KEY_GOES_HERE -e SEARCH_BACKEND=sqlalchemy -p 5000:5000 -d registry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment