Set up of a real time production scenario of various Linux hosts (distros) which can be managed centrally with Ansible Master. Test the set-up by running modules and playbooks.
-
Instal virtual box and download latest versions (64bit) of Debian, Ubuntu & Cent OS VDI's from OS Box images for virtual box.
-
Follow the steps to install a host for each distro (debian, centos & ubuntu).
-
Follow the steps carefully to ensure internet access for all the VDI's. Ubuntu and Debian would work fine but CentOS might give issues and this video will resolve the problem. If the earlier video is followed then CentOS will also work fine. If not refer the second video.
-
For CentOS download the "Workstation" (not the server).
-
Start the servers and SSH into them (e.g. MobaXterm).
-
Make any one of the server as Ansible master and install Ansible.. Verify by running the command "ansible --version".
-
In Ansible master create any folder (e.g. ansible_test) and change directory to it (mkdir ansible_test & cd ansible_test).
-
Create file ansible.cfg and enter the below two commands.
$ nano ansible.cfg
-
Create a file "inventory.txt" in the folder created above and group your remote hosts as per OS and enter the login credentials in the ":vars" section as below. Change the IP addresses with your's. For sudo user password add "ansible_become_password".
-
To check connectivity run the playbook ping_test.yaml with below command & the output will be similar to image below. Source code uploaded in this repository.
$ ansible-playbook ping_test.yaml
-
Connectivity can also be checked by running the below adhoc command and output would be like image below.
-
To check OS releases of each remote hosts run the below ansible playbook and output will be similar to the image below (playbook source code uploaded).
$ ansible-playbook os-release1.yaml -
OS release can also be checked by running the below adhoc command and the output will be as the image.
$ ansible all -a "cat /etc/os-release"
-
The enviornment set-up is now successful. The machines can be shut down from virtual box and restarted anytime later. More complex ansible automation tasks (e.g. patching the different servers automatically) can be performed in this set-up as it mimics a production environment with different linux distros.