When using Ansible under WSL (Windows Subsystem for Linux) recently, I stumbled upon the following error:
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 rootet in "/tmp", for more error information use -vvv.
In this case, Ubuntu 20.04 was used but the issue can also occur on other Linux distributions or versions.
The root cause of this issue is that Ubuntu ships a GNU C library (glibc) that is not compatible with WSL. You can check this like this:
$ sleep 1337 sleep: cannot read realtime clock: Invalid argument
For some ressources, Ansible uses the sleep command – even though you’re not using any breaks.
As workaround, you can link the sleep command to /bin/true. But in this case, breaks are not possible anymore:
# mv /usr/bin/sleep /usr/bin/sleep.orig # ln -s /bin/true /usr/bin/sleep
Hopefully, there will be a permanent fix soon. Here you will find a discussion about the issue.
It also mentions that Ubuntu 18.04 seems not to be affected. There is also a patch available in the WSL development version.