<p>Add the below lines in the host file(not config file).</p>
<pre><code>[windows:vars] 
remote_tmp = C:\Users\ans_user\Tmp 
become_method = runas 
ansible_shell_type = powershell 
shell_type = powershell
</code></pre>

CC BY-SA 4.0
2023-01-23T14:11:24.930Z
2023-07-08T05:14:47.517Z
2023-07-08T05:14:47.517Z
Abhishek
<pre><code>---
# 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! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;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 \&quot;/tmp\&quot;, for more error information use -vvv. Failed command was: ( umask 77 &amp;&amp; mkdir -p \&quot;` echo c\\temp `\&quot;&amp;&amp; mkdir \&quot;` echo c\\temp/ansible-tmp-1661983610.31-13-149784338894642 `\&quot; &amp;&amp; echo ansible-tmp-1661983610.31-13-149784338894642=\&quot;` echo c\\temp/ansible-tmp-1661983610.31-13-149784338894642 `\&quot; ), exited with result 1&quot;, &quot;unreachable&quot;: true}

Why is ansible using Linux commands for my Windows server?
</code></pre>

CC BY-SA 4.0
2022-09-03T19:04:29.793Z
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
<ansible>
Ansible playbook fails on Windows server
Adam
# Ansible playbook fails on Windows server

(Asked by: username_0 on 2022-08-31)

---
# 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?

**Tags:** ansible

> **Comments:**
> **username_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.  

---

## 1 answers

### Answer by username_2 on 2023-01-23. Score: 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


---

