I'm trying to authenticate to a REST API with using NTLM authentication. First I tried uri module but that didn't have support for NTLM. So I installed win_uri because looks like its supporting ntlm https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_uri_module.html#parameter-use_default_credential
However when I use win_uri. Somehow its trying to run commands on localhost using Powershell. I somehow need to seperate connecting to localhost and connecting to REST api part. But not sure how I can do this?
---
# playbooks/pki.yaml
- name: Playbook for cert automation
gather_facts: no
hosts: localhost
tasks:
- name: Get values
win_uri:
url: https://{{ api_url }}/SearchRequests
method: POST
src: body.json
body_format: json
validate_certs: no
url_username: {{ user }}
url_password: {{ password }}
return_content: true
And the result is
PLAY [Playbook for cert automation] ********************************************************************************************************************************
TASK [Get values] **********************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/bin/sh: 1: powershell: not found\n", "module_stdout": "", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127}
PLAY RECAP *********************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0