logic855 / ansible-consul-demo

Demo of Consul & Ansible @ AnsibleFest NY, 2015. Accompanying slide deck:

Home Page:http://www.slideshare.net/irakli/ansible-fest-irakli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ansible-consul-demo

Demo of Consul and Ansible. This is the source-code of on-stage demo created for Ansible Fest NY, 2015.

You can view the accompanying slidedeck of the presentation at: http://www.slideshare.net/irakli/ansible-fest-irakli

Installation

  1. Spin-up some Ubuntu servers on AWS (or any other hosting)

  2. Edit the IPs of the servrs in the provided hosts file (present at the same level as this README). Please make sure to indicate public IPs.

  3. Make sure to also edit group_vars/all.yml and enter the IP(s) of all servers that you allocated as consul servers. The entries in hosts and group_vars.all.yml must correspond to each other!

  4. While you are in group_vars/all.yml you may also want to change the shell_user variable. By default it is set to "ubuntu" because that's what AWS wants to log into your Ubuntu servers in as, but another user may make sense to you.

  5. In AWS EC2, the root username for Ubuntu servers is called: ubuntu. If you spin your servers up somewhere where that is not the case, edit group_vars/all.yml and modify the value of the ansible_ssh_user: ubuntu variable.

  6. Create ssh folder under this checkout (same level as README)

  7. Save a private SSH key that corresponds to the root user on all your new servers under: ssh/private-key.pem

  8. Make sure your private key permissions are valid:

    ```consul
    chmod 700 ssh
    chmod 600 ssh/*
    ```
    
  9. You are probably going to need following ports open (based on https://www.consul.io/docs/agent/options.html customize as you see fit):

Quickstart

To make sure your ssh and hosts setup is correct and you can login to all required servers:

ansible all -m ping -i hosts

To install basic Linux tools (curl, vim etc.) on all servers:

ansible-playbook basics.yml -i hosts

To install consul server and clients:

ansible-playbook bootstrap.yml -i hosts

To install everything, including the sample "hello world" microservice in Node.js:

ansible-playbook webheads.yml -i hosts

Consul User Interface

http://<ip-of-a-consul-server>:8500/

Debugging

Consul logs are under: /var/log/upstart/consul.log

To see current members of Consul cluster:

consul members

To make sure that consul leadership election succeeded (bootstrapping), you can run the following on a consul server:

consul info

and analyze the raft: section of the response.

About

Demo of Consul & Ansible @ AnsibleFest NY, 2015. Accompanying slide deck:

http://www.slideshare.net/irakli/ansible-fest-irakli