How to install Ansible in Windows 10
Today we're going to talk about the easier way to install and maintain Ansible inside Windows 10 using the Windows Subsystem for Linux.
I'm Luca Berton and welcome to today's episode of Ansible Pilot.
How to install Ansible in Windows 10
Today we're talking about How to install Ansible in Windows 10.
Officially Windows is not a supported operating system for the control node even if RedHat is working really hard to eliminate barriers to native Windows controllers.
The reason behind this is that there are a lot of UNIX-isms deeply baked into most of Ansible that prevents it from working on native Windows, basically, Windows doesn't have the fork() syscall implementation. Ansible controller worker model as of 2.10 makes heavy use of the POSIX fork() syscall.
- Cygwin
Some people used Cygwin POSIX-compatibility projects but sometimes it just breaks so it's not a reliable solution.
- Windows Subsystem for Linux
The best alternative is to use Windows Subsystem for Linux, also known as WSL. Run WSL version 2 if Windows 10 later than build 2004 or Windows 11.
Ansible works great on WSL and WSL2.
Links
More technical information:
- https://docs.microsoft.com/en-us/windows/wsl/compare-versions
- https://docs.ansible.com/ansible/latest/user_guide/windows_faq.html
## Playbook
Let's jump in a quick live Playbook of how to install the latest and a specific version of Ansible in Windows using Windows Subsystem for Linux.
You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.
code
- install_wsl.ps1
``PowerShell
wsl --help
wsl --list -o
wsl --install
`
execution
output
- install WSL
`PowerShell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\user> wsl --install
Installing: Virtual Machine Platform
Virtual Machine Platform has been installed.
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Downloading: WSL Kernel
Installing: WSL Kernel
WSL Kernel has been installed.
Downloading: Ubuntu
The requested operation is successful. Changes will not be effective until the system is rebooted.
PS C:\Users\user>
`
- setup Ubuntu 20.04 LTS WSL and install ansible
``PowerShell
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: ansiblepilot
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 20.04 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Syste