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--".
https://stackoverflow.com/questions/36898474/how-to-install-a-module-for-all-users-with-pip-on-linux
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.
Hope this helps,
ej