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
| $ sudo systemctl stop consul socorro-processor | |
| # run local single-node consul server | |
| $ consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul & | |
| # ensure that no data is in local consul server | |
| $ consulate kv backup | |
| [] | |
| # should only be a single member of this "cluster" | |
| $ consul members | |
| # load new config to test | |
| $ cat socorro.consul.config.json | consulate kv restore |
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 |
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
| [/etc/consul-template]$ cat config/config.json | |
| consul = "localhost:8500" | |
| token = "" | |
| retry = "10s" | |
| log_level = "debug" | |
| template { | |
| source = "/etc/consul-template/clusterit.ctmpl" | |
| destination = "/etc/clusterit.consul" | |
| command = "true" |
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
| --- | |
| # This Playbook bounces a consul cluster that is unable to elect a leader | |
| # push peers.json to the consul/raft data directory, change single quotes to doubles, restart consul servers | |
| - hosts: consulservers | |
| become: yes | |
| # update the peers.json file with the correct consul server ip addresses and port | |
| tasks: | |
| - include_vars: roles/consul/vars/main.yml |
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
| Grab the two node vagrant set up from here: | |
| https://github.com/hashicorp/consul/tree/master/demo/vagrant-cluster | |
| Install consul | |
| wget https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip | |
| Copy consul into /usr/local/bin |
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 | |
| hostname="consul-$(curl -s http://169.254.169.254/latest/meta-data/instance-id)" | |
| CONF=/etc/consul/config/000-consul.json | |
| TEMPLATE="/mnt/dashboard/consul-config/config.json" | |
| x=0 | |
| rm -f $CONF | |
| rm -f /tmp/instances $$ rm -f /tmp/*.json | |
| restart consul |
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
| sudo useradd consul | |
| sudo mkdir -p /etc/consul.d/{bootstrap,server,client} | |
| sudo mkdir /var/consul | |
| sudo chown consul:consul /var/consul | |
| wget -nc -nv https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip 1&>2 | |
| unzip -o consul_0.6.4_linux_amd64.zip | |
| sudo cp consul /usr/local/bin | |
| if [ "$HOSTNAME" = mesos-master ]; then | |
| echo "on master" |
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 | |
| # <bitbar.title>Consul Services</bitbar.title> | |
| # <bitbar.version>v1.0</bitbar.version> | |
| # <bitbar.author>Ben Brooks</bitbar.author> | |
| # <bitbar.author.github>bbrooks</bitbar.author.github> | |
| # <bitbar.desc>Displays services in Consul, along with their port numbers</bitbar.desc> | |
| # <bitbar.image>https://i.imgur.com/RB7z44c.png</bitbar.image> | |
| # <bitbar.dependencies>jq,curl</bitbar.dependencies> | |
| # <bitbar.abouturl>https://github.com/matryer/bitbar-plugins/blob/master/Dev/Consul/consul_services.5s.sh</bitbar.abouturl> | |
| # |
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
| consulmasterserver: | |
| command: -server -bootstrap-expect 3 -config-file /etc/configs/acl.json | |
| image: progrium/consul:latest | |
| hostname: node_1 | |
| name: node_1 | |
| ports: | |
| - "27017:27017" | |
| volumes: | |
| - ~/docker-consul/config:/etc/configs:ro |
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
| #! /usr/bin/python | |
| # Sanity check that consul-template is writing the services in Consul to the | |
| # nginx config file. | |
| import requests | |
| HOST = '10.1.1.13' | |
| CONSUL_PORT = 8500 | |
| NGINX_CONFIG_PATH = '/etc/nginx/sites-enabled/consul_template.conf' | |