Love Ansible, but wondering how to get it running on Windows?
Ansible is one of the most popular configuration administration and infrastructure automation tools. It helps to automate infrastructure configuration/provisioning, software deployments, and general infrastructure management.
Ansible was initially available on Linux. However, with Microsoft’s new viewpoint on open source, their community improvements, and their acceptance of a more agile, DevOps-minded software development method, Windows support is gradually catching up with the pace.
Although Windows support requires a slight bit more configuration, it’s not very bad once the initial setup is done. There are two possible ways to get it installed.
Installing Ansible Using Cygwin
Have you heard of Cygwin?
It is a POSIX-compatible environment to run on Windows. This means – you can run many things on Windows, which you usually do on UNIX-based OS.
If its the first time you heard about Cygwin then I would refer to their official website to get more understanding.
The default Cygwin installation doesn’t cover Ansible. Hence, you got to select them during installation, as explained below manually.
- Download Cygwin (Chose 32 bit or 64 bit Cygwin package as per your system)
- Run the Cygwin installation file which you downloaded above and follow the screen.
- Select download source as “Install from Internet.”
- Set a root directory where you would like your application installed
- Select a directory where you would like to install your Cygwin packages
- Select Direct connection if you’re not using a proxy.
- Select a mirror to download your packages. You can choose any from the list.
- Packages available for installation will be shown; this is where we have to select ansible – select view as Full explicitly and then search for “ansible” and then select the latest version as shown below.
- Ansible-doc is optional, click next
- Review and confirm changes by clicking next
- It will download and install the necessary packages.
- Once done, you will get a success message, click Finish
Congratulation! You have installed Cygwin with Ansible on Windows. Let’s verify it.
- Double click on Cygwin Terminal icon from the desktop and type
ansible --version
And, as you can see, it has successfully installed.
Go ahead and play around with it. If you are interested in learning Ansible, then check out this Udemy course.
Installing Ansible Using Ubuntu on Windows 10
Thanks to Microsoft. Now it is possible to install Ubuntu on Windows 10.
Let’s get it started.
- Search for Windows features in the search box. And when the “Turn Windows features on or off ” appears, click on that.
- A window will open with a bunch of features. Scroll down and check the box of Windows Subsystem for the Linux option. And after that, click on the OK button.
- Open the Microsoft Store and search for Ubuntu to install the latest version.
- After the installation, you will see a launch button, use that to open the Ubuntu bash.
- On Ubuntu bash, it will ask you to set the username and password for the default user. You can also set the root account password from here by typing
sudo passwd root
- Its time to get the Ansible installed with the following 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
- Press Y when it asks for…
After the installation, let’s test whether by creating and running a demo playbook.
- Create a file called testbook.yml
nano testbook.yml
- Add the following lines and save the file
- name: testing ansible
hosts: localhost
tasks:
- name: echo a message
debug: msg=”this is working"
And, finally, run the playbook.
ansible playbook testbook.yml --connection=local
Conclusion
I hope this helps you to install Ansible on Windows. Check out this blog post to learn about the playbook to automate the tasks.