Home

Awesome

Ansible Demo

This Ansible demo contains some servers that will provide you an idea that really Ansible product works and also Tower.

Requirements:

Pre-Deployment

To prepare the environment to execute this demo you must execute some commands (we will asume that you already have installed Virtualbox and Vagrant or if you want to use Libvirt you also need vagrant-mutate plugin to convert Virtualbox boxes into Libvirt compatible image):

vagrant box add tower-2.4.3 http://vms.ansible.com/ansible-tower-2.4.3-virtualbox.box
vagrant box add geerlingguy/centos7
vagrant plugin install vagrant-hostmanager
vagrant plugin install vagrant-triggers

Demo execution

This demo have manual part to show other ones how Tower works and how configure inventories, Job Templates and execute jobs and the automatic one that you will see how ansible works from console and how the changes are made.

Pre-phase

Into repository root folder execute this:

vagrant up
vagrant ssh tower.localdomain
sudo su
bash /vagrant/utils/tower_adaptation.sh

NOTE: Copy the URL and Password to access Tower Server

Once inside of tower, go to 'Tools' image at top right corner and enter at Credentials menu, then create a new one with this details:

Name: vagrant
User that owns this credential: admin
Type: Machine
Username: vagrant
Password: vagrant

Submit the changes

NOTE: Before you continue, don't forget to download a WAR file and put into jboss-apps folder otherwise, the playbook will fail.

Inventory

When the nodes are up, get all the Ip's from everyone and create the inventory in Tower (Those ips are an example):

ansible_ssh_host: 192.168.1.51
ansible_ssh_pass: vagrant
ansible_ssh_port: 22
ansible_ssh_user: vagrant
ansible_ssh_host: 192.168.1.52
ansible_ssh_pass: vagrant
ansible_ssh_port: 22
ansible_ssh_user: vagrant
ansible_ssh_host: 192.168.1.53
ansible_ssh_pass: vagrant
ansible_ssh_port: 22
ansible_ssh_user: vagrant
ansible_ssh_host: 192.168.1.54
ansible_ssh_pass: vagrant
ansible_ssh_port: 22
ansible_ssh_user: vagrant

Project

Now is time to create the project into Tower:

Jobs

Create a new Job Template:

Name: HAproxy Deployment
Job Type: Run
Inventory: vagrant
Project: Ansible Demo
Playbook: site.yml
Machine Credential: vagrant
Limit: lbservers
Name: JBoss Deployment
Job Type: Run
Inventory: vagrant
Project: Ansible Demo
Playbook: site.yml
Machine Credential: vagrant
Limit: jboss-servers
Name: HA JBoss Deployment
Job Type: Run
Inventory: vagrant
Project: Ansible Demo
Playbook: site.yml
Machine Credential: vagrant
Limit: all
Name: Elastic Deployment
Job Type: Run
Inventory: vagrant
Project: Ansible Demo
Playbook: elastic.yml
Machine Credential: vagrant
Limit: all

With all templates created, now we can consume it ;), just press Run (rocket icon) and wait for it.

Elastic features

There is a playbook that shows how works the elasticity. To see how it works, just execute 'Elastic Deployment' Job-Template. This execution will take 2 actions:

To deactivate this feature, just execute 'HA JBoss Deployment' template, to reconfigure the HAproxy and deactivate JBoss on elastic nodes.

Disconnected_mode

At first time, in your home, office or w/e you need to download all packages and software to perform the demo, the first time execute it in a connected environment to fulfill this requirements. Remember to download also the Plugins and Vagrant boxes.

To use the disconnected_mode just change you branch pointing to 'disconnected_mode' and execute this:

vagrant up jboss01.localdomain
....wait for it
vagrant ssh jboss01.localdomain
sudo su
bash /vagrant/utils/download_content.sh

NOTE: Before you continue, don't forget to download a WAR file and put into jboss-apps folder otherwise, the playbook will fail.

Ensure that you have all rpms of haproxy, Jboss and the Jboss targz file in the disconnected folder. Now just logout from the VM.

Follow the demo from Pre-phase stage and don't change to master branch.

Known Errors

If an error appears about the network waking up the VM, just change at Vagrantfile the network mode from

to

Execute the download stage and change again to the first one network mode. Then wake up the VM's. Maybe will be necessary to destroy the 'jboss01.localdomain' vm before perform the changes at Vagrantfile

Error:

➜  ansible-demo git:(disconnected_mode) vagrant up jboss01.localdomain
Bringing machine 'jboss01.localdomain' up with 'virtualbox' provider...
==> jboss01.localdomain: Importing base box 'geerlingguy/centos7'...
==> jboss01.localdomain: Matching MAC address for NAT networking...
==> jboss01.localdomain: Checking if box 'geerlingguy/centos7' is up to date...
==> jboss01.localdomain: Setting the name of the VM: ansible-demo_jboss01localdomain_1460407294742_69126
==> jboss01.localdomain: Fixed port collision for 22 => 2222. Now on port 2200.
==> jboss01.localdomain: Clearing any previously set network interfaces...
The specified host network collides with a non-hostonly network!
This will cause your specified IP to be inaccessible. Please change
the IP or name of your host only network so that it no longer matches that of
a bridged or non-hostonly network.

References

Enjoy!