ansible Installing Ansible On Any OS(windows) Machine Using Virtual Box+Vagrant


Example

My laptop is having Windows 10. Here i am giving steps that you can follow to test and learn Ansible.

SOME THEORY

For Ansible you need a Control Machine and a host(or hosts) to run the Playbook.

  • Control Machine should be Linux based or MacOS(windows not allowed) and need Python (2.6 or higher version). Here Ansible will be installed.
  • Target machine (host/node) can be Linux/MacOS/windows. This needs only Python to be installed. No agent software required.

SETUP

Step 1: Install Virtual Box

Virtual box is a software to create virtual computers of different OS. It is like having multiple computers each or different OS and different versions.

Download Virtual Box according to the OS in your system and install it.

Step 2: Install Vagrant

Vagrant is Command Line Interface to create virtual machines in virtual box. This makes things easy. You need to learn basic Vagrant commands.

Step 3: Create a folder where you want your virtual machine

Step 4: Create Virtual Machine using Vagrant

Open terminal and go to the path where you created folder, and run the following two commands.

You need to select Virtual Box. I am installing Ubuntu for example. You can choose anything from the list. You need to run these two commands under "virtual box" category: vagrant init ubuntu/trusty64 and vagrant up --provider virtualbox. Other categories might be: hyperv, vmware_desktop etc. (this will take some time, as it will download the necessary files)

Step 4: Install Ansible

For UbuntuOS: sudo apt-get install ansible


Alternative solution:

You can use Katacoda to practice ansible. No need to install or setup anything. Run two commands given in step 2 and after that, you are good to go.