Ansible is an Infrastructure as Code tool used for managing and monitoring remote servers.
Ansible requires a Linux-based system to run. This can be a problem if you want to use its features on a Windows 10 system. However, there are ways to install Ansible on Windows.
This tutorial will cover different ways you can install Ansible on Windows 10.
- A system running Windows 10
- A user account with administrator privileges
Install Ansible on Windows
There are three ways to run Ansible on Windows 10:
We shall explain all three methods of installing Ansible on Windows.
Method 1: Using Cygwin
Cygwin is a POSIX-compatible environment that lets you run tools and code designed for Unix-like operating systems on Microsoft Windows.
Even though the default Cygwin installation contains hundreds of tools for Unix-based systems, Ansible is not one of them. You must manually add Ansible during the installation process.
To install Ansible on Windows using Cygwin, follow these steps:
1. Download the Cygwin installation file. This file is compatible with both the 32-bit and 64-bit versions of Windows 10. It automatically installs the right version for your system.
2. Run the Cygwin installation file. On the starting screen of the installation wizard, click Next to continue.
3. Select Install from Internet as the download source and click Next.
4. In the Root Directory field, specify where you want the application installed, then click Next.
5. In the Local Package Directory field, select where you want to install your Cygwin packages, then click Next.
6. Choose the appropriate Internet connection option.
If you aren’t using a proxy, select Direct Connection.
If you are using a proxy, select Use System Proxy Settings or enter the proxy settings manually with the Use HTTP/FTP Proxy.
Click Next to continue.
7. Choose one of the available mirrors to download the installation files, then click Next.
8. On the Select Packages screen, change the View option to Full and type ‘ansible’ in the search bar.
Select both Ansible and Ansible Doc by checking the boxes under Src? and click Next to continue.
9. This screen lets you review the installation settings. To confirm and begin the install process, click on Next.
10. The install wizard will download and install all the selected packages, including Ansible.
11. Once the installation is complete, select whether you want to add a Cygwin desktop and Start Menu icon, then click on Finish to close the wizard.
Method 2: Using a Linux Virtual Machine
Another way to install Ansible on Windows 10 is to use a virtualization tool and a Linux virtual box.
In this example, we will use Oracle VM VirtualBox to set up an Ubuntu virtual machine and install Ansible.
Step 1: Setting Up VirtualBox
1. Download the VirtualBox installation file.
2. Run the VirtualBox installation file.
On the starting screen of the installation wizard, click Next to continue.
3. Use this screen to select which features of VirtualBox you want to install. This is also where you can set the install location. Click Next to continue.
4. Choose whether you want to add Desktop, Start Menu, and Quick Launch Bar shortcuts and add file associations. Click Next to continue.
5. A new screen will warn you that the install wizard needs to reset your network connection. Click Yes to continue.
6. On the next screen, click Install to begin the installation process.
7. The install wizard might prompt you to add a VirtualBox USB device. Click Yes to continue.
8. Click Finish to complete the installation.
Step 2: Creating an Ubuntu 20.04 Virtual Box
1. Download the Ubuntu 20.04 desktop image.
2. On the VirtualBox starting screen, click New.
3. Type in the name of your virtual machine. If the name contains the word ‘Ubuntu’, the operating system dropdown menu will automatically update to Ubuntu (64-bit). If not, you can select the operating system manually using the dropdown menu. Click Next to continue.
4. Set the amount of RAM you want the virtual machine to have.
Click Next to continue.
Note: By default, Oracle VM VirtualBox assigns 1024MB of RAM to every virtual box. Make sure you assign enough RAM to your new virtual box, or it will not work properly.
5. Select a hard disk option for your virtual machine.
Choose Create a virtual hard disk now if you are creating a brand new VM. Click Create to continue.
6. Choose the type of virtual hard disk you want to create. Click Next.
7. Choose if the new virtual hard disk has a fixed amount of space or if you want it to allocate space dynamically. Select Fixed size and click Next.
8. Select the location of the virtual hard disk on your computer and enter the size limit.
For this example, we will set the size limit to 10GB. Click Create to continue.
Note: Just like with RAM, you need to make sure you assign enough hard disk space to your virtual machine. VirtualBox sets the fixed-size hard disk at 10GB by default.
9. Select the new virtual machine you just created on the left-hand side of the VirtualBox starting screen. Click Start to run the new VM.
10. VirtualBox will prompt you to select a start-up disk. Click on the button next to the drop-down menu to open the optical Disk Selector.
11. In the Optical Disk Selector, click Add.
12. Find the Ubuntu 20.04 desktop image you downloaded in a previous step. Select the image and click Open.
13. In the Optical Disk Selector, highlight the image you just added and click Choose.
14. Click Start to begin the install process for Ubuntu 20.04.
Step 3: Installing Ansible
1. Once you are done installing Ubuntu 20.04, open the command terminal.
2. In the command terminal, enter the following command:
$ sudo apt update
This command refreshes the system’s package index and allows you to Install Ansible.
3. To install Ansible, use the command:
$ sudo apt install ansible -y
The rest of the install process is automated.
Method 3: Enabling Ubuntu on Windows 10
The third option is to use the Windows Subsystem for Linux to start up the Ubuntu terminal without setting up a virtual machine:
1. Open the Start menu and search for Turn Windows features on or off. Click on the shortcut when it appears.
2. Scroll down through the list of features until you see Windows Subsystem for Linux. Click on the checkbox, and then click OK to enable the feature.
3. Open the Microsoft Store. Search for Ubuntu and click on Get to install the latest version.
4. Once the installation is complete, click on Launch to start up the Ubuntu command terminal.
5. To install Ansible, enter the following set of commands:
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible -y
Note: Check out our tutorial on How to Install Ubuntu on Windows with Hyper-V. Hyper-V allows you to install a distribution of Linux on Windows 10, including Ubuntu.
If you followed the steps in this guide, you now have a copy of Ansible installed on your Windows 10 system.
Now you can use Ansible to manage and configure remote servers, and plan your CI/CD process.