i have simple playbook that print hello world in windows 10 WSL ubuntu i invoke :
ansible-playbook hello-world.yml -vvv
the ansible.cfg:
[defaults]
remote_user = root
remote_tmp = /home/foo/projects/ansible_tmp
I'm getting the error:
foo@foo-LP:~/projects$ ansible-playbook hello-world.yml -vvv
ansible-playbook 2.9.9
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/foo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/foo/.local/lib/python3.8/site-packages/ansible
executable location = /home/foo/.local/bin/ansible-playbook
python version = 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAYBOOK: hello-world.yml *******************************************************************************************************************************************************************************************************************
1 plays in hello-world.yml
PLAY [Echo] *********************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
task path: /home/foo/projects/hello-world.yml:1
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: foo
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/foo/projects/ansible_tmp `"&& mkdir /home/foo/projects/ansible_tmp/ansible-tmp-1592072036.299761-1251-15575474283021 && echo ansible-tmp-1592072036.299761-1251-15575474283021="` echo /home/foo/projects/ansible_tmp/ansible-tmp-1592072036.299761-1251-15575474283021 `" ) && sleep 0'
fatal: [localhost]: 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 /home/foo/projects/ansible_tmp `\"&& mkdir /home/foo/projects/ansible_tmp/ansible-tmp-1592072036.299761-1251-15575474283021 && echo ansible-tmp-1592072036.299761-1251-15575474283021=\"` echo /home/foo/projects/ansible_tmp/ansible-tmp-1592072036.299761-1251-15575474283021 `\" ), exited with result 1, stdout output: ansible-tmp-1592072036.299761-1251-15575474283021=/home/foo/projects/ansible_tmp/ansible-tmp-1592072036.299761-1251-15575474283021\n",
"unreachable": true
}
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
here is the ansible_tmp directory as you can see files do created :
foo@foo-LP:~/projects/ansible_tmp$ ls -l
total 0
drwx------ 1 foo foo 512 Jun 13 20:58 ansible-tmp-1592071117.4568608-1061-140750827389855
drwx------ 1 foo foo 512 Jun 13 21:04 ansible-tmp-1592071482.7000341-1178-197961143036553
drwx------ 1 foo foo 512 Jun 13 21:05 ansible-tmp-1592071559.571779-1200-194490972570368
drwx------ 1 foo foo 512 Jun 13 21:13 ansible-tmp-1592072036.299761-1251-15575474283021
Are you on WSL1 and Ubuntu 20.04? I've had troubles with this too and fiddled around for a whole day. I only have this problem with using copy module on localhost only (copy locally a to b).
Here's the GitHub issue for it. https://github.com/microsoft/WSL/issues/4898
It was fixed in Fast build 19603. Beta Channel is in 19042. The fix is coming for stable (19041) but we don't know a date.
Lots of workaround ideas there include some patches. I used following as a workaround for now as it doesn't break sleep.
mv /bin/sleep /bin/sleep~
ln -s /bin/busybox /bin/sleep
/ARCHIVED: Then I stumbled over this: https://community.spiceworks.com/topic/2275812-ubuntu-wsl-ansible-permission-error-when-running-localhost-playbook
It seams as there is an issue with Glibc and WSL1 (https://discourse.ubuntu.com/t/ubuntu-20-04-and-wsl-1/15291).
You can verify that with:
$ sleep 5
sleep: cannot read realtime clock: Invalid argument
The "workaround" ...
mv /usr/bin/sleep /usr/bin/sleep.dist
ln -s /bin/true /usr/bin/sleep
stated in the first link worked for me. BUT it's of course suboptimal as sleep is then basically useless for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With