Failed to create temporary directory

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 :

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

I get this error :

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 UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQ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AFIAQQBCAEYAQQBDAEEAQQBMAFEAQgBGAEEASABJAEEAYwBnAEIAdgBBAEgASQBBAFEAUQBCAGoAQQBIAFEAQQBhAFEAQgB2AEEARwA0AEEASQBBAEIAVABBAEcAawBBAGIAQQBCAGwAQQBHADQAQQBkAEEAQgBzAEEASABrAEEAUQB3AEIAdgBBAEcANABBAGQAQQBCAHAAQQBHADQAQQBkAFEAQgBsAEEAQwBrAEEASQBBAEIANwBBAEMAQQBBAFoAUQBCADQAQQBHAGsAQQBkAEEAQQBnAEEAQwBRAEEAVABBAEIAQgBBAEYATQBBAFYAQQBCAEYAQQBGAGcAQQBTAFEAQgBVAEEARQBNAEEAVAB3AEIARQBBAEUAVQBBAEkAQQBCADkAQQBDAEEAQQBSAFEAQgBzAEEASABNAEEAWgBRAEEAZwBBAEgAcwBBAEkAQQBCAGwAQQBIAGcAQQBhAFEAQgAwAEEAQwBBAEEATQBRAEEAZwBBAEgAMABBAEkAQQBCADkAQQBBAD0APQA='
<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 :

[ssh_connection]
ssh_args = -o ControlMaster=no

[defaults]
inventory = inventaire.ini


remote_tmp = C:\Users\root\tmp

Thank you for your help

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.

Yes, I can connect with the command: ssh root@10.0.1.101

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.

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.

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

3 Likes