---
# This is a basic playbook for testing
- hosts: WindowsSandbox
#gather_facts: no
vars:
ansible_remote_tmp: c\temp
remote_tmp: c\temp
tasks:
- win_shell: cd c:\temp
Here is the error:
fatal: [WindowsServer1]: 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 c\\temp `\"&& mkdir \"` echo c\\temp/ansible-tmp-1661983610.31-13-149784338894642 `\" && echo ansible-tmp-1661983610.31-13-149784338894642=\"` echo c\\temp/ansible-tmp-1661983610.31-13-149784338894642 `\" ), exited with result 1", "unreachable": true}
Why is ansible using Linux commands for my Windows server?
1 Answer
Add the below lines in the host file(not config file).
[windows:vars]
remote_tmp = C:\Users\ans_user\Tmp
become_method = runas
ansible_shell_type = powershell
shell_type = powershell
c\temp
, should be:c:\temp
. Maybe that is confusing Ansible. But it's not clear why you need to setansible_remote_tmp
in the first place.