Ansible installation error on windows 10

I am getting below strange error after installing ansible on windows 10.

ansible
Traceback (most recent call last):
File “”, line 198, in run_module_as_main
File “”, line 88, in run_code
File "C:\Tools\Python312\Scripts\ansible.exe_main
.py", line 4, in
File "C:\Tools\Python312\Lib\site-packages\ansible\cli_init
.py", line 42, in
check_blocking_io()
File “C:\Tools\Python312\Lib\site-packages\ansible\cli_init_.py”, line 34, in check_blocking_io
if not os.get_blocking(fd):
^^^^^^^^^^^^^^^^^^^
OSError: [WinError 1] Incorrect function

Below is the output of python version and installed modules

python --version
Python 3.12.2

pip list
Package Version


ansible-compat 4.1.11
ansible-core 2.16.3
ansible-lint 6.8.7
argcomplete 3.2.2
attrs 23.2.0
black 24.2.0
bracex 2.4
cffi 1.16.0
click 8.1.7
colorama 0.4.6
cryptography 42.0.3
filelock 3.13.1
Jinja2 3.1.3
jsonschema 4.21.1
jsonschema-specifications 2023.12.1
markdown-it-py 3.0.0
MarkupSafe 2.1.5
mdurl 0.1.2
mypy-extensions 1.0.0
packaging 23.2
pathspec 0.12.1
pip 24.0
platformdirs 4.2.0
pycparser 2.21
Pygments 2.17.2
PyYAML 6.0.1
referencing 0.33.0
resolvelib 1.0.1
rich 13.7.0
rpds-py 0.18.0
ruamel.yaml 0.17.40
ruamel.yaml.clib 0.2.8
subprocess-tee 0.4.1
wcmatch 8.5
yamllint 1.35.1

Am I doing anything wrong. Can someone help with it ?

Hi, Ansible can manage Windows based hosts, but installing Ansible on Windows without WSL is not supported.

Refer to the docs:

For your control node (the machine that runs Ansible), you can use nearly any UNIX-like machine with Python installed. This includes Red Hat, Debian, Ubuntu, macOS, BSDs, and Windows under a Windows Subsystem for Linux (WSL) distribution. Windows without WSL is not natively supported as a control node; see Matt Davis’ blog post for more information.
Installing Ansible — Ansible Documentation

3 Likes

Thanks for reply @kurokobo …!!

I do know that windows server can’t act as controller for ansible.
I am using VS Code to write ansible playbooks and it requires ansible plugin to be installed which I did as well but keep on getting ansible related errors. I tried installing it and got this error.

Is there any way to make ansible work for development through VS Code

Hi, the extension page also has helpful note for Windows users:

Requirements

For Windows users, this extension works perfectly well with extensions such as Remote - WSL and Remote - Containers.
Ansible - Visual Studio Marketplace

Therefore, to use Ansible extension with VSCode on Windows, there should be UNIX-like environment as well, since it requres Ansible 2.9+ that can’t be installed on Windows natively.
If you are familier (or want to be so) with WSL or Podman on Windows, you can use it with VSCode over Remote - WSL or Remote - Containers.

Alternatively, I personally like to use Remote - SSH with VSCode to connect to controller node for Ansible and develop directly on the controller.

2 Likes