# Failed to create temporary directory

**URL:** <https://forum.ansible.com/t/failed-to-create-temporary-directory/5061>\
**Category:** Get Help\
**Tags:** windows\
**Created:** [April 22, 2024, 9:00am UTC](https://forum.ansible.com/t/failed-to-create-temporary-directory/5061 "2024-04-22T09:00:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrien2300](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Adrien2300](https://forum.ansible.com/u/Adrien2300)\
**Post date:** [April 22, 2024, 9:00am UTC](https://forum.ansible.com/t/failed-to-create-temporary-directory/5061/1 "2024-04-22T09:00:35Z")

</div>

Hello,

I am a student and I have an assignment on ansible.

The project is to mount network disks on my windows machine via ansible.

I’ve created a powershell script that I’ve put on ansible which is launched via a playbook.

The problem is that when I run the command :

```auto
ansible-playbook -vvv -i inventaire.ini --user root --become --ask-pass -e "ansible_shell_type=powershell" mount-windows.yml

```

I get this error :

```auto
ansible-playbook [core 2.16.5]
  config file = /root/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/ansible/lib/python3.11/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/ansible/bin/ansible-playbook
  python version = 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] (/root/ansible/bin/python)
  jinja version = 3.1.3
  libyaml = True
Using /root/ansible.cfg as config file
SSH password: 
host_list declined parsing /root/inventaire.ini as it did not pass its verify_file() method
script declined parsing /root/inventaire.ini as it did not pass its verify_file() method
auto declined parsing /root/inventaire.ini as it did not pass its verify_file() method
yaml declined parsing /root/inventaire.ini as it did not pass its verify_file() method
Parsed /root/inventaire.ini inventory source with ini plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: mount-windows.yml ****************************************************
1 plays in mount-windows.yml

PLAY [Run powershell script] ***************************************************

TASK [Start Windows Update] ****************************************************
task path: /root/mount-windows.yml:5
<10.0.1.101> ESTABLISH SSH CONNECTION FOR USER: root
<10.0.1.101> SSH: EXEC sshpass -d12 ssh -o ControlMaster=no -o 'User="root"' -o ConnectTimeout=10 10.0.1.101 'chcp.com 65001 > $null ; PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARQBuAGMAbwBkAGUAZABDAG8AbQBtAGEAbgBkACAAVQB3AEIAbABBAEgAUQBBAEwAUQBCAFQAQQBIAFEAQQBjAGcAQgBwAEEARwBNAEEAZABBAEIATgBBAEcAOABBAFoAQQBCAGwAQQBDAEEAQQBMAFEAQgBXAEEARwBVAEEAYwBnAEIAegBBAEcAawBBAGIAdwBCAHUAQQBDAEEAQQBUAEEAQgBoAEEASABRAEEAWgBRAEIAegBBAEgAUQBBAEMAZwBBAGsAQQBIAFEAQQBiAFEAQgB3AEEARgA4AEEAYwBBAEIAaABBAEgAUQBBAGEAQQBBAGcAQQBEADAAQQBJAEEAQgBiAEEARgBNAEEAZQBRAEIAegBBAEgAUQBBAFoAUQBCAHQAQQBDADQAQQBSAFEAQgB1AEEASABZAEEAYQBRAEIAeQBBAEcAOABBAGIAZwBCAHQAQQBHAFUAQQBiAGcAQgAwAEEARgAwAEEATwBnAEEANgBBAEUAVQBBAGUAQQBCAHcAQQBHAEUAQQBiAGcAQgBrAEEARQBVAEEAYgBnAEIAMgBBAEcAawBBAGMAZwBCAHYAQQBHADQAQQBiAFEAQgBsAEEARwA0AEEAZABBAEIAVwBBAEcARQBBAGMAZwBCAHAAQQBHAEUAQQBZAGcAQgBzAEEARwBVAEEAYwB3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3AEEAYgBBAEIATwBBAEcARQBBAGIAUQBCAGwAQQBBAG8AQQBTAFEAQgBtAEEAQwBBAEEASwBBAEEAdABBAEcANABBAGIAdwBCADAAQQBDAEEAQQBKAEEAQQAvAEEAQwBrAEEASQBBAEIANwBBAEMAQQBBAFMAUQBCAG0AQQBDAEEAQQBLAEEAQgBIAEEARwBVAEEAZABBAEEAdABBAEYAWQBBAFkAUQBCAHkAQQBHAGsAQQBZAFEAQgBpAEEARwB3AEEAWgBRAEEAZwBBAEUAdwBBAFEAUQBCAFQAQQBGAFEAQQBSAFEAQgBZAEEARQBrAEEAVgBBAEIARABBAEUAOABBAFIAQQBCAEYAQQBDAEEAQQBMAFEAQgBGAEEASABJAEEAYwBnAEIAdgBBAEgASQBBAFEAUQBCAGoAQQBIAFEAQQBhAFEAQgB2AEEARwA0AEEASQBBAEIAVABBAEcAawBBAGIAQQBCAGwAQQBHADQAQQBkAEEAQgBzAEEASABrAEEAUQB3AEIAdgBBAEcANABBAGQAQQBCAHAAQQBHADQAQQBkAFEAQgBsAEEAQwBrAEEASQBBAEIANwBBAEMAQQBBAFoAUQBCADQAQQBHAGsAQQBkAEEAQQBnAEEAQwBRAEEAVABBAEIAQgBBAEYATQBBAFYAQQBCAEYAQQBGAGcAQQBTAFEAQgBVAEEARQBNAEEAVAB3AEIARQBBAEUAVQBBAEkAQQBCADkAQQBDAEEAQQBSAFEAQgBzAEEASABNAEEAWgBRAEEAZwBBAEgAcwBBAEkAQQBCAGwAQQBIAGcAQQBhAFEAQgAwAEEAQwBBAEEATQBRAEEAZwBBAEgAMABBAEkAQQBCADkAQQBBAD0APQA='
<10.0.1.101> (1, b'', b'Le format du param\x8atre est incorrect - ;.\r\n')
[DEPRECATION WARNING]: Non UTF-8 encoded data replaced with "?" while 
displaying text to stdout/stderr, this is temporary and will become an error. 
This feature will be removed in version 2.18. Deprecation warnings can be 
disabled by setting deprecation_warnings=False in ansible.cfg.
<10.0.1.101> Failed to connect to the host via ssh: Le format du param?tre est incorrect - ;.
fatal: [10.0.1.101]: 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: PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgAkAHQAbQBwAF8AcABhAHQAaAAgAD0AIABbAFMAeQBzAHQAZQBtAC4ARQBuAHYAaQByAG8AbgBtAGUAbgB0AF0AOgA6AEUAeABwAGEAbgBkAEUAbgB2AGkAcgBvAG4AbQBlAG4AdABWAGEAcgBpAGEAYgBsAGUAcwAoACcAJQBUAEUATQBQACUAJwApAAoAJAB0AG0AcAAgAD0AIABOAGUAdwAtAEkAdABlAG0AIAAtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgACQAdABtAHAAXwBwAGEAdABoACAALQBOAGEAbQBlACAAJwBhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADcAMQAzADcANwA0ADYANgA3AC4AOAA5ADUAMQA3ADcALQAzADEANgAxAC0AMgAxADUANwA2ADgANgA2ADIANAAxADEAOQAwADcAJwAKAFcAcgBpAHQAZQAtAE8AdQB0AHAAdQB0ACAALQBJAG4AcAB1AHQATwBiAGoAZQBjAHQAIAAkAHQAbQBwAC4ARgB1AGwAbABOAGEAbQBlAAoASQBmACAAKAAtAG4AbwB0ACAAJAA/ACkAIAB7ACAASQBmACAAKABHAGUAdAAtAFYAYQByAGkAYQBiAGwAZQAgAEwAQQBTAFQARQBYAEkAVABDAE8ARABFACAALQBFAHIAcgBvAHIAQQBjAHQAaQBvAG4AIABTAGkAbABlAG4AdABsAHkAQwBvAG4AdABpAG4AdQBlACkAIAB7ACAAZQB4AGkAdAAgACQATABBAFMAVABFAFgASQBUAEMATwBEAEUAIAB9ACAARQBsAHMAZQAgAHsAIABlAHgAaQB0ACAAMQAgAH0AIAB9AA==, exited with result 1",
    "unreachable": true
}

PLAY RECAP *********************************************************************
10.0.1.101 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0   

```

I’d like to point out that I’ve given my windows user root rights to read and write the tmp folder.

Here is my ansible.cfg file :

```auto
[ssh_connection]
ssh_args = -o ControlMaster=no

[defaults]
inventory = inventaire.ini

remote_tmp = C:\Users\root\tmp

```

Thank you for your help

---

<div class="post-metadata">

**Author:** ![jrglynn2](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jrglynn2](https://forum.ansible.com/u/jrglynn2)\
**Post date:** [April 22, 2024, 2:54pm UTC](https://forum.ansible.com/t/failed-to-create-temporary-directory/5061/2 "2024-04-22T14:54:00Z")

</div>

> [@Adrien2300](#):
>
> ```auto
> Failed to connect to the host via ssh: Le format du param?tre est incorrect - ;.
> fatal: [10.0.1.101]: UNREACHABLE!
> 
> ```

The issue is that you can’t reach the intended server, per error above.

Can you use the SSH command outside of ansible? Might be an access issue.

---

<div class="post-metadata">

**Author:** ![Adrien2300](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Adrien2300](https://forum.ansible.com/u/Adrien2300)\
**Post date:** [April 22, 2024, 8:18pm UTC](https://forum.ansible.com/t/failed-to-create-temporary-directory/5061/3 "2024-04-22T20:18:18Z")

</div>

Yes, I can connect with the command: ssh [root@10.0.1.101](mailto:root@10.0.1.101)

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [April 22, 2024, 9:26pm UTC](https://forum.ansible.com/t/failed-to-create-temporary-directory/5061/4 "2024-04-22T21:26:14Z")

</div>

> [@Adrien2300](#):
>
> `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\",`

This is caused by permissions (or storage) issues relating to the `remote_tmp` directory. Either the partition is full, the file system is read-only, or the user has insufficient permissions to create and use the directory. SELinux can restrict permissions even for the `root` user, for example. Setting `remote_tmp: '/tmp'` can sometimes alleviate this problem, since the `/tmp` directory is typically world writable.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [April 22, 2024, 10:39pm UTC](https://forum.ansible.com/t/failed-to-create-temporary-directory/5061/5 "2024-04-22T22:39:38Z")

</div>

You need to set the shell to either powershell or cmd, what one you choose depends on the default shell configured on your Windows host. See `ansible_shell_type` in [Setting up a Windows Host — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/os_guide/windows_setup.html#configuring-ansible-for-ssh-on-windows).

The error you received indicates that you have the shell configured as `powershell` but in reality your default shell is `cmd`.
