2

I'm using this command to ping a Windows host from my CentOS 8 Ansible server

ansible windows -m win_ping

But I get this output when executing it

windows | FAILED! => {
      "msg": "winrm or requests is not installed: No module named winrm"
}

This is the entry for the Windows machine on my Ansible hosts file

[w10]
windows ansible_host=10.0.10.15
[w10:vars]
ansible_user=someuser
ansible_password=somepassword
ansible_connection=winrm
ansible_port=5986

Winrm is enabled on the Windows machine. I also installed the pywinrm module with the following command, but it didn't solve my problem

pip3 install pywinrm

What am I doing wrong?

1 Answers1

2

Module or plugin requirements must be installed to the python that uses them. As this is for a plugin, it must be to the python running the ansible or ansible-playbook script.

List the installed version of pywinrm with this:

ansible -m python_requirements_info -a dependencies=winrm localhost

If the Python module could be found, it will be returned under a valid key.

Also confirm that the python returned is the same as what you run ansible with, head -n1 $(which ansible)

John Mahowald
  • 32,050
  • 2
  • 19
  • 34
  • 1
    This was helpful. On RedHat 7.9, ansible version 2.9.15, python 2.7.5, this works as described above. However on MacOS/homebrew, ansible version 2.11.5, python 3.9.7, I had to change winrm to pywinrm to get a valid key. – Kim Taylor Oct 22 '21 at 15:46