Short version: add the vars below to inventory
This error happens because Ansible needs a temp directory when connecting with SSH. The default location is “/tmp” which makes Windows a sad panda.
You’ll need to create c:\temp on the windows host and add a few vars to your inventory file on the ansible server. The default location is /etc/ansible/hosts
sudo nano /etc/ansible/hosts
The server in this example is server2019-test which is in the windows group so I’m adding a [windows:vars] entry to set variables for the windows group
You can change the path in remote_tmp if you don’t want to use c:\temp
[windows:vars] remote_tmp = c:\temp become_method = runas ansible_connection = ssh ansible_shell_type = cmd shell_type = cmd
Here’s how it looks after adding vars
The full error for search results
server2019-test | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \”/tmp\”, for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \”` echo ~/.ansible/tmp `\”&& mkdir \”` echo ~/.ansible/tmp/ansible-tmp-1697165824.226963-30720-2470561171736 `\” && echo ansible-tmp-1697165824.226963-30720-2470561171736=\”` echo ~/.ansible/tmp/ansible-tmp-1697165824.226963-30720-2470561171736 `\” ), exited with result 1″,
“unreachable”: true
}