| layout | title | date | author |
|---|---|---|---|
post |
Ansible on vagrant VMs |
2017-11-07 10:00:39 -0400 |
Ali Kanso |
This repo provides a basic introduction to ansible
The target audience are developers/admins that wish to automate their infrastructure.
In this lab we will create a vagrant cluster of 1 master-node with ansible installed and a number of worker-nodes
We will also create ansible playbook consisting of multiple roles deploying multiple applications
Make sure you have virtualbox installed on your machine (tested on versions >= 5.1.26r117224).
Make sure you have vagrant installed (tested on 1.8 and 2.0).
Note: check if the hostmanager plug in is installed using:
vagrant plugin install vagrant-hostmanager
Even if it is not installed, the vagrant up command below will install it for you.
Start by cloning this repo:
git clone git@github.com:akanso/lab-ansible.git
Then, simply move to the directory where the Vagrantfile resides and execute a vagrant up command:
cd lab-ansible
vagrant upThis should take a few minutes, after which one master and 2 worker nodes will be provisoned
vagrant status
master-node running (virtualbox)
worker-node1 running (virtualbox)
worker-node2 running (virtualbox)you can ssh into the master-node and check the cluster status:
vagrant ssh master-node
cd /vagrant
ansible all -i hosts -m pingyou should see a response from both nodes
worker-node1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
worker-node2 | SUCCESS => {
"changed": false,
"ping": "pong"
}The configuration file vg_config.rb
You can change the values of all the variables in this file, e.g.:
cat vg_config.rb
$worker_vm_count=2
$worker_vm_memory=1536
$worker_vm_cpu=1
...After the change, you can re-run vagrant up from you workstation