Thanks @Kevin C for the tip, trying out now ...
As you wrote, the "pip under windows" solution is working BUT ... useless to some degree, because ansible really needs to be executed in a linux environment to fully work as designed.
To try out install python 3.8 via MS Store e.g. and pip install the cloned ansible git repo from here
As you suggested using the Windows Subsystem for Linux (WSL) will work.
See below my
Summary
It is possible to install ansible on Win10 + Windows Subsystem for linux rather than in a docker container, you have to decide youself if it fits your purpose better or worse. The setup time is also very reasonable, and e.g. integration into Visual Studio code works in order to test ansible development locally (ansible-lint or ansible-playbook --syntax-check e.g.). Also, other commands, like ansible-galaxy and ansible-inventory commands work as expected, basic tests done...
Walkthrough
You might want to make sure you are running the most recent Windows 10 release; At the time of writing I am using Windows 10 pro, Version 2004. WSL2 is available for this Windows Version.
WSL2 installation
via Admin powershell as per MS instructions:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --set-default-version 2
you might still have to update the wsl kernel image if the last command tells you to, so follow the wsl2kernel update guide that is shown there if you see this message:
WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel
... after installing that, the above message should not be shown any more.
At the time of writing installing any linux "distribution" from the Microsoft store directly via powershell is not possible .
[EDIT] @2021-02: previously, https://aka.ms/wslstore worked... not any more. BUT you can now still either use the store and search or follow the instructions for manual installation e.g.:
Invoke-WebRequest -Uri https://aka.ms/wsl-debian-gnulinux
-OutFile Debian.appx -UseBasicParsing
Add-AppxPackage .\Debian.appx
...as microsoft documents here.
Finally: install ansible
So after initial configuration which takes maybe 5 minutes (download times may broadly differ), there you already have a Linux shell under Windows available.
As with every usual Ubuntu or Debian, now you can install ansible easily with
sudo apt install ansible
which should install a recent version of ansible (ansible version is 2.9.12 @2020-08).
This should be it.
Optionally if you also want to use Visual Studio Code:
Visual Studio code configuration
To use this setup with VS Code, download here and install (... in Windows 10, not in Debian / WSL) (... you could also use chocolatey for that installation, but VS code usually updates itself whenever possible per default).
As per the originally linked article VS code & WSL "Configure VS Code to use Bash"
2 refinements there:
- the settings are nowadays (Win 10 2004, 64 bit, Date 2020-08) found under:
File -> Preferences -> Settings
or reachable directly via the keys
[CTRL] + [,]
- The complete path to start bash has also changed also a little bit:
"terminal.integrated.shell.windows": "C:\Windows\System32\bash.exe"
Still, you have to make yourself familiar as per the original VS code & WSL article where what is mounted where in WSL - you need to find your ansible project location in order to proceed...
Also you may want to install git as mentioned there. Additionally the VS Code Extensions that the ansible project recommends might come in handy. For a feature presentation of the basic "ansible" extension see here.
Happy ansible coding & testing (with VS Code)!