Coder Social home page Coder Social logo

ansible-registrator-consul's Introduction

ansible-registrator-consul

Ansible role for Consul + Registrator. Currently uses gliderlabs/consul:legacy.

Consul = service registry that can also be used for DNS lookup

Registrator = automatic registration+deregistration of Docker containers

Requirements

Dependencies of the docker module, which are presently:

  • python >= 2.6
  • docker-py >= 0.3.0
  • The docker server >= 0.10.0

Role Variables

These variables are only needed for the initial bootstrap process. See the README from gliderlabs/docker-consul for more info.

consul_cluster_size: The total size of the Consul cluster before it attempts to bootstrap. Needs to be specified on the leader host only.

consul_leader_ip: The private IP of the leader host. Needs to be specified on all follower hosts.

Note that once initial bootstrap is complete, the leader is constantly reelected and even if one or more nodes go bad, they will maintain a quorum as long as there are 3 or more nodes.

Dependencies

Example Playbook

Here's a sample setup for 5 Docker hosts in AWS EC2. First, write a playbook service_discovery.yml

- hosts: all
  roles:
  - { role: smoll.registrator-consul }

And a requirements.yml

- src: smoll.registrator-consul

And a inventory file /etc/ansible/hosts that looks like

[consul_leader]
ec2-54-204-214-172.compute-1.amazonaws.com consul_cluster_size=5

[consul_followers]
ec2-54-235-59-210.compute-1.amazonaws.com consul_leader_ip=169.254.169.254
ec2-54-83-161-83.compute-1.amazonaws.com consul_leader_ip=169.254.169.254
ec2-54-91-78-105.compute-1.amazonaws.com consul_leader_ip=169.254.169.254
ec2-54-82-227-223.compute-1.amazonaws.com consul_leader_ip=169.254.169.254

Then run

$ ansible-galaxy install -r requirements.yml
$ ansible-playbook -i /etc/ansible/hosts service_discovery.yml

Note that consul_leader_ip is the private IP of the consul leader. This playbook also assumes that the private IP is the IP of the eth1 interface ({{ansible_default_ipv4.address}}) -- I'm not sure if this is correct; feel free to submit a PR if it doesn't work for you.

Vagrant test

(NOTE: if you clone this repo, the parent directory must be named registrator-consul -- not ansible-registrator-consul -- or Ansible won't be able to find this role for the Vagrant test!)

First, install playbook dependencies by running

sudo ansible-galaxy install -r test_requirements.yml # --force

Then bring up the vagrant hosts and run the plays against them

vagrant up

# separately:
vagrant up --no-provision

# then
vagrant provision

# or, a more realistic simulation:
ansible-playbook --private-key=~/.vagrant.d/insecure_private_key -u vagrant -i test_hosts -s test.yml

License

MIT

Author Information

Shujon Mollah (@smoll)

ansible-registrator-consul's People

Contributors

jpgrace avatar smoll avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.