Skip to content

Instantly share code, notes, and snippets.

View byteshiva's full-sized avatar
🎯
Focusing

Siva byteshiva

🎯
Focusing
View GitHub Profile
$ 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
@byteshiva
byteshiva / bootstrap-consul.sh
Created August 24, 2016 13:34 — forked from bluk/bootstrap-consul.sh
Consul Bootstrap on CoreOS
#!/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
[/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"
@byteshiva
byteshiva / cluster_bounce.yml
Created August 24, 2016 13:35 — forked from rmullinnix/cluster_bounce.yml
Ansible playbook for consul cluster bounce - ansible-playbook -i hosts.dev cluster_bounce.yml --ask-become-pass (peers.tmpl is in roles/consul/templates; sedfile is in roles/consul/files; main.yml is in roles/consul/vars)
---
# 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
@byteshiva
byteshiva / notes.txt
Created August 24, 2016 13:35 — forked from d-smith/notes.txt
Consul Notes
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
#!/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
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"
@byteshiva
byteshiva / consul.5s.sh
Created August 24, 2016 13:38 — forked from bbrks/consul.5s.sh
Get a list of clickable consul services in BitBar
#!/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>
#
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
#! /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'