winrm or requests is not installed: No module named winrm

Has anyone properly documented the correct packages that needs to be installed to manage a windows host?

ansible 2.4.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/home/vagrant/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

WINHOST1 | FAILED! => {
“failed”: true,
“msg”: “winrm or requests is not installed: No module named winrm”
}
WINHOST2 | FAILED! => {
“failed”: true,
“msg”: “winrm or requests is not installed: No module named winrm”
}
WINHOST3 | FAILED! => {
“failed”: true,
“msg”: “winrm or requests is not installed: No module named winrm”
}
WINHOST4 | FAILED! => {
“failed”: true,
“msg”: “winrm or requests is not installed: No module named winrm”
}

[vagrant@localhost ~]$ sudo pip install paramiko PyYAML Jinja2 httplib2
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Requirement already satisfied: paramiko in /usr/lib/python2.6/site-packages
Requirement already satisfied: PyYAML in /usr/lib64/python2.6/site-packages
Requirement already satisfied: Jinja2 in /usr/lib/python2.6/site-packages/Jinja2-2.6-py2.6.egg
Requirement already satisfied: httplib2 in /usr/lib/python2.6/site-packages
Requirement already satisfied: pycrypto>=1.9 in /usr/lib64/python2.6/site-packages (from paramiko)
[vagrant@localhost ~]$ pip install “pywinrm>=0.1.1”
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting pywinrm>=0.1.1
/usr/lib/python2.6/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication)

extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a

newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents

urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see

https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Using cached pywinrm-0.2.2-py2.py3-none-any.whl
Requirement already satisfied: requests>=2.9.1 in /usr/lib/python2.6/site-packages (from pywinrm>=0.1.1)
Requirement already satisfied: xmltodict in /usr/lib/python2.6/site-packages (from pywinrm>=0.1.1)
Requirement already satisfied: six in /usr/lib/python2.6/site-packages (from pywinrm>=0.1.1)
Collecting requests-ntlm>=0.3.0 (from pywinrm>=0.1.1)
Using cached requests_ntlm-1.1.0-py2.py3-none-any.whl
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python2.6/site-packages (from requests>=2.9.1->pywinrm>=0.1.1)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python2.6/site-packages (from requests>=2.9.1->pywinrm>=0.1.1)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/lib/python2.6/site-packages (from requests>=2.9.1->pywinrm>=0.1.1)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/lib/python2.6/site-packages (from requests>=2.9.1->pywinrm>=0.1.1)
Collecting cryptography>=1.3 (from requests-ntlm>=0.3.0->pywinrm>=0.1.1)
Using cached cryptography-2.1.4.tar.gz
Complete output from command python setup.py egg_info:
error in cryptography setup command: Invalid environment marker: platform_python_implementation != ‘PyPy’

Hi

It’s definitely possible to install the winrm requirements with Ansible, a few things to note regarding your outputs

  • Look at upgrading your host to a new version so that it at least has Python 2.7 installed by default (2.6 is old and not supported by Python itself but it should still work)
  • Instead of installing in the system Python, use a virtualenv so you don’t have to play around with sudo https://docs.python.org/3/library/venv.html, really you should be doing this, it’s as simple as running virtualenv ansible-venv; source ansible-venv/bin/activate
  • pip install pywinrm and pip install http://github.com/diyan/pywinrm/archive/master.zip#egg=pywinrm didn’t work because you pip and setuptools version is too old, run sudo pip install -U pip setuptools to make sure you are on the latest version (note you did this already but I would also try and upgrade pip at the same time)
  • Finally your last error is because it needs root privileges to install the pycparser (and probably others) in the system Python packages, you would either run it with pip install --user … or sudo pip install …, or better yet use a venv and you won’t have to worry about this issue
  • Not related but it makes it a lot easier to see what commands you ran by using the code block formatting with Google Groups posts, the button with the 2 braces { } will do the highlighting for you and it is best to put each command in it’s own code block

Looking at some of the warnings, it seems like SSL isn’t configured correctly with the Python 2.6 install so I would really look at my first point and try a newer host, as you are using Vagrant I don’t see why this should be avoided and you can potentially save yourself some more trouble down the road.

Thanks

Jordan