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
-
Spin-up some Ubuntu servers on AWS (or any other hosting)
-
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. -
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! -
While you are in
group_vars/all.yml
you may also want to change theshell_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. -
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, editgroup_vars/all.yml
and modify the value of theansible_ssh_user: ubuntu
variable. -
Create
ssh
folder under this checkout (same level as README) -
Save a private SSH key that corresponds to the root user on all your new servers under:
ssh/private-key.pem
-
Make sure your private key permissions are valid:
```consul chmod 700 ssh chmod 600 ssh/* ```
-
You are probably going to need following ports open (based on https://www.consul.io/docs/agent/options.html customize as you see fit):
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
http://<ip-of-a-consul-server>:8500/
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.