It is running AWX no problem and Ansible no problem as far as LINUX servers are concerned.
I am trying to communicate to a w2k16 server via winrm from my linux server.
The linux box has python3, and pip3 and supposedly pywinrm is installed.
The windows box appears to be setup correctly to listen for winrm requests.
When I try to run “sudo ansible -i inventory windows -m win_ping” I get the error that everyone else gets:
10.125.8.56 | FAILED! => {
“msg”: “winrm or requests is not installed: No module named winrm”
If I check installed packages for requests - it say dependencies are met.
It also say that pywinrm dependencies are met.
What does it take to get the winrm module to be found by python?
I will try this PIP command (again) but I do not have an RH subscription.
Also a new symptom, I can run a python program that imports winrm, but I get an error “no winrm” if I try
to run the program as a regular user. If I run it as sudo - the python program runs, no errors and returns the command from the windows machine.
I was running the “ifconfig /all” . So as sudo, and running a python program that imports winrm, I can access the windows box.
If I try a basic command line progarm “ansible windows -i hosts -m win_ping” as a regular user or as sudo I get the same error:
“no winrm or request module available” What does ansible need to find winrm??? Supposedly I have pywinrm installed but cannot
access it.
This sounds like a problem that I ran into before. Please check your umask setting. I suspect it is not 0022. If it isn’t, then trying uninstalling pywinrm and requests, set the umask to 022, and then reinstall pywinrm and requests with the umask set. The modules should then have the appropriate file and directory permissions so that non-root users can acccess.
Hello,
Thanks for the ;reply. I am wondering where I would change the umask value? Just at user level? or system wide?
I have a similar install with pywinrm, python2, and ansible, and installed pywinrm, and it works fine. It is the red hat server that does not
find the winrm, urllib3 modules, etc - I can run a python progarm but it needs to be run as sudo.
When I try to install pywinrm (02.2.) on the redhat system it says all dependencies are already met. I am still stumped on how to get redhat winrm to work.
You only need to change the umask temporarily from the command line before reinstalling pywinrm and any other packages that don’t have the right file and directory permissions. You can just type “umask 022” before doing the package reinstallation to set it. That will only change the umask temporarily in the current session so that you can do the pip install. If you want to change the default umask, there are a few ways to do it that are easily found with a web search.
You need to install the pywinrm and requests, and maybe some other packages separately for each of the different Python instances on your server that you use for Ansible. Is Ansible configured to use the Python 3 instance that you mentioned? Or is it a Python 2.7 instance?
Either way, make sure that you install it for the Python instance that you’re running Ansible with (the instance that ansible_python_interpreter is set to). Once you have the permissions right, Ansible should be able to access those Python modules.
Below is a SO posting that deals with the permissions issue. I think if you were to look at the files in the Python site-packages directory, you’d find that the permissions were set to something like “-rw-r-----". On RedHat, I think that will be under /usr/lib/pythonX.x/site-packages/ (adjust for your Python instance)
It would confirm that we’re on the right track if those permissions don’t permit ‘read’ for others/public user class, as in “-rw-r–r–”.
I have also fixed the permissions issue before by doing a “chmod -R 644” on a module’s directory and files in site-packages. Be careful doing this though.
Also, any other packages you installed with pip likely have the wrong permissions if the umask wasn’t set to 022 at the time of the installation. So you might need to fix them as well. And remember in the future to always set the umask to 022 before doing a pip install.
Hello EJ,
This is helpful info - also thanks for the reply. I does seem that it is a permissions issue.
I almost got thing going - as root user i was able to insure that python3 (3.6) was installed - for python I have to use python3 mypythonfile.py.
As root, and umask 022, i installed anisible using pip3 install ansible (when connected to internet)
As root I was able to verify that ansible was using python3 - ansible --version, etc.
the path for ansible is now: /usr/local/bin/ansible.
So I thought I had it fixed - I logged off as root, logged on as standard user.
tried to run ansible and I get this error:
Traceback (most recent call last):
File “/usr/local/bin/ansible”, line 34, in
from ansible import context
ModuleNotFoundError: No module named ‘ansible’
I the UMASK is back to 077 - I will check your suggestions on permissions in the /usr/local/lib/python3.6/site-packages/ansible file/directory and in /usr/local/bin/ansible area.