I’m trying to switch from winrm to pypsrp in my ansible files to try to make connection more smooth and not getting timed out sometimes when working with Windows machines.
So I added this to my group-vars/all.yml file: ansible_connection: psrp ansible_port: 5985 ansible_psrp_transport: ntlm ansible_psrp_server_cert_validation: ignore ansible_psrp_shell: powershell
Then I did: pip install pypsrp pip install ntlm-auth
But when running my ansible scripts, I get:
pypsrp or depdencies are not installed. No module named pypsrp
But it’s installed so not sure why I get this, how can I fix this?
Is pypsrp installed in the same python environment as ansible and related tools? That could be your system environment, a python virtualenv, or the ee that you’re using.
I tried install pypsrp in a virtualenv where ansible is also installed, but I still get the problem.
If I type: ansible --version
It shows ansible core 2.18.8, and python version 3.12.3
If I’m not inside virtualenv, then I install pypsrp with:
pipx install pypsrp --include-deps --force
But still I get the probelm after that that “pypsrp is not found”.
I got it to work when going inside the virtualenv and then running pip install ansible, to reinstall it inside the venv so it gets its own installation.
But now, I’m not quite sure which pypsrp settings I need. Do I need a file all.yml inside group_vars folder with these contents:
Or do I need to add setting sto my inventory.ini file like this:
[windows_dc:vars]
ansible_connection=psrp
...
Because I’m using inventory.ini file where I have the credentials and IP addresses of each machine which I am referring to in my ansible file. But I’m a bit confused where I should put the psrp settings and in which file.
Setting those values either in group_vars/all.yml or inventories/inventory.ini will work (note that the syntax will differ slightly depending on which flavor you choose).
If you’re going to use the same settings for all hosts in the inventory file (which is what an all.yml would imply), I personally find it more readable to keep it all in the inventory.ini file, so that all the information about connecting to a host is located in the same place.