Vagrant is a tool for building and managing virtual machine environments in a single workflow. Following the instructions here in order to install it.
Download and install Virtual Box as virtualization provider.
Hostname | Role |
---|---|
CONTROL | Configuration management |
LB01 | Load Balancer |
DB01 | Database |
APP01 | Webserver |
APP02 | Webserver |
- Clone this project
- Access the project directory
- Using the system CLI, run the following Vagrant commands in order to create and provisioning the Virtual Machines.
3.1. Provisioning VM's:
$ vagrant up --provisioning
3.2. Access the control VM (Machine where Ansible has installed previously):
$ vagrant ssh control
3.3. Since you've got access to control VM, validate if Ansible has been installed successfully.
vagrant@control:~$ ansible --version
3.4. Now, from the control VM you can have access to another machines by using ssh command.
vagrant@control:~$ ssh lb01
vagrant@control:~$ ssh db01
vagrant@control:~$ ssh app01
vagrant@control:~$ ssh app02
Run all following commands in control Machine.
- Pre-install (ALL MACHINES)
vagrant@control:~$ ansible-playbook -i /etc/ansible/inventories/hosts /etc/ansible/playbooks/pre-install.yml
- Setting up Load Balance (LB01)
vagrant@control:~$ ansible-playbook -i /etc/ansible/inventories/hosts /etc/ansible/playbooks/nginx.yml
- Setting up web servers (APP01, APP02)
vagrant@control:~$ ansible-playbook -i /etc/ansible/inventories/hosts /etc/ansible/playbooks/apache2.yml
- Setting up Database (DB01)
vagrant@control:~$ ansible-playbook -i /etc/ansible/inventories/hosts /etc/ansible/playbooks/mysql.yml
Run the following command in control machine.
vagrant@control:~$ ansible-playbook -i /etc/ansible/inventories/hosts /etc/ansible/playbooks/app.yml
From web browser access: http://192.168.135.101/page.html
Reload the page and check if the HTTP traffic was redirected to another web server by NGINX.