How to Install and Configure Ansible on Windows

September 29, 2020

Introduction

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.

How to install and configure Ansible on Windows

Prerequisites

  • 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.

Starting Cygwin installation required for Installing Ansible on Windows

3. Select Install from Internet as the download source and click Next.

Download source for Cygwin instalation

4. In the Root Directory field, specify where you want the application installed, then click Next.

Root directory for Cygwin setup

5. In the Local Package Directory field, select where you want to install your Cygwin packages, then click Next.

Selecting local package directory for Cygwin

6. Choose the appropriate Internet connection option.

If you aren’t using a proxy, select Direct Connection.

Setting up internet connection

If you are using a proxy, select Use System Proxy Settings or enter the proxy settings manually with the Use HTTP/FTP Proxy.

Proxy settings for Cygwin

Click Next to continue.

7. Choose one of the available mirrors to download the installation files, then click Next.

Choosing a download website

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.

Selecting Ansible package

9. This screen lets you review the installation settings. To confirm and begin the install process, click on Next.

Finishing instalation of Ansible through Cygwin

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.

Creating shortcuts for Cygwin environment

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.

VirtualBox installation wizard screen

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.

Configuring VM VirtualBox instalation required for Ansible instalation on Ubuntu virtual machine

4. Choose whether you want to add Desktop, Start Menu, and Quick Launch Bar shortcuts and add file associations. Click Next to continue.

Creating shortcuts for Virtualbox

5. A new screen will warn you that the install wizard needs to reset your network connection. Click Yes to continue.

Installing Network Interfaces for VirtualBox required for setting up Ansible

6. On the next screen, click Install to begin the installation process.

Finishing up installation of VirtualBox

7. The install wizard might prompt you to add a VirtualBox USB device. Click Yes to continue.

8. Click Finish to complete the installation.

Starting VirtualBox required for installing Ansible on Windows virtual machine

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.

Creating a new Linux virtual machine in VirtualBox

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.

Select a name and operating system for your new VM to Install Ansible on Ubuntu virtual machine

4. Set the amount of RAM you want the virtual machine to have.

Click Next to continue.

Set the amount of RAM for your new VM

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.

Set up a hard disk for your new VM

6. Choose the type of virtual hard disk you want to create. Click Next.

Choose the type of hard disk for your new VM

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.

Choose if the hard disk for your new VM has fixed or dynamic size

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.

Select the location and size of the hard disk for your new VM

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.

Start up your 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.

Use Disk Selector to load up a startup disk

11. In the Optical Disk Selector, click Add.

Add a new disk in the optical Disk Selector

12. Find the Ubuntu 20.04 desktop image you downloaded in a previous step. Select the image and click Open.

Add the Ubuntu disk image

13. In the Optical Disk Selector, highlight the image you just added and click Choose.

Choose the new image in the Disk Selector

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.

Refreshing the system's package index with the 'sudo apt update' command

3. To install Ansible, use the command:

$ sudo apt install ansible -y
Installing Ansible with the 'sudo apt install ansible -y' command

The rest of the install process is automated.

After you install it on you virtual machine, you can configure Ansible by setting up the hosts inventory file and checking the connections.

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.

Turn Windows features on or off.

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.

Turning Windows Subsystem for Linux on, to install Ansible on Windows

3. Open the Microsoft Store. Search for Ubuntu and click on Get to install the latest version.

Get Ubuntu from the Windows Store

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.

Conclusion

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.

Was this article helpful?
YesNo
Aleksandar Kovačević
With a background in both design and writing, Aleksandar Kovacevic aims to bring a fresh perspective to writing for IT, making complicated concepts easy to understand and approach.
Next you should read
How to Install and Configure Ansible on Ubuntu 20.04
September 10, 2020

Ansible is a management system that helps you manage a large number of servers without the need for any...
Read more
How to Install phoenixNAP BMC Ansible Module
July 24, 2020

Learn how to successfully install the Bare Metal Cloud Ansible module on your control machine. Take a look at...
Read more
What is Bare Metal Cloud
May 20, 2020

This article provides answers to everything you wanted to know about Bare Metal Cloud and how it compares to...
Read more
How to Edit Hosts File in Linux, Windows, or Mac
October 22, 2018

The hosts file in Windows, Mac, or Linux maps hostnames to IP addresses. This could be in an intranet, like a...
Read more