1
---
# 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
  • While this may not answer the question, a colon is lacking in your path c\temp, should be: c:\temp. Maybe that is confusing Ansible. But it's not clear why you need to set ansible_remote_tmp in the first place.
    – Kate
    Commented Sep 3, 2022 at 19:04

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.