Bootstrap FreeKB - Ansible - Resolve "winrm or requests is not installed: No module named winrm"
Ansible - Resolve "winrm or requests is not installed: No module named winrm"

Updated:   |  Ansible articles

Let's say you get the following when attempting to run an Ansible Playbook against Windows hosts.

fatal: [server1.example.com]: FAILED! => {"msg": "winrm or requests is not installed: No module named winrm"}

 

Use the ansible --version command to determine the version of Python being used by Ansible.

ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/your_username/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible playbook module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, mm dd yyyy, hh:mm:ss) [GCC 4.8.5 yyyymmdd (Red Hat 4.8.5-39)]

 

Use the pip --version command to determine the version of Python being used by pip.

~]$ pip --version
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

 

If the version of Python being used by Ansible and pip are the same, use the pip install command to install pywimrm and requests.

pip install pywinrm 
pip install requests

 

If the version of Python being used by Ansible and pip are different, use the python --version command to determine the version of Python being used by /usr/bin/python. In this example, since the python --version command is using the same version of Python that is being used by Ansible (2.7.5), we should be able to setup Python with the winrm module.

~]# python --version
Python 2.7.5

 

Downloaded pywinrm and xmltodict tar archives and then extract the tar archives. For example, let's say you download pywinrm-0.4.3.tar.gz to the /tmp directory on your Ansible server. Use the tar extract command to extract the tar archive.

tar -zxpf /tmp/pywinrm-0.4.3.tar.gz --directory /tmp

 

In this example, this should create a directory named /tmp/pywinrm-0.4.3. Move into this directory and run setup.py to install pywimrm. In this example, the "python" command is used to install wimrm on version 2.7.5 of Python.

cd /tmp/pywinrm-0.4.3
sudo python setup.py install

 

Then do the same for XML to dict.

tar -zxpf /tmp/xmltodict-0.13.0.tar.gz --directory /tmp
cd /tmp/xmltodict-0.13.0
sudo python setup.py install

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 5ed6b7 in the box below so that we can be sure you are a human.