molecule: Failed to create temporary directory
Issue Type
- Bug report
Molecule and Ansible details
ansible --version && molecule --version
ansible [core 2.14.1]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /root/.local/share/virtualenvs/ansible_netdata-Np7YJUAj/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /root/.local/share/virtualenvs/ansible_netdata-Np7YJUAj/bin/ansible
python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/root/.local/share/virtualenvs/ansible_netdata-Np7YJUAj/bin/python)
jinja version = 3.1.2
libyaml = True
molecule 4.0.4 using python 3.9
ansible:2.14.1
azure:23.0.0 from molecule_plugins
containers:23.0.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
delegated:4.0.4 from molecule
docker:23.0.0 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
ec2:23.0.0 from molecule_plugins
gce:23.0.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
podman:23.0.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
vagrant:23.0.0 from molecule_plugins
Molecule installation method (one of):
- pip
Ansible installation method (one of):
- pip
Detail any linters or test runners used:
Actual Behaviour
PLAY [Prepare] *****************************************************************
TASK [Gathering Facts] *********************************************************
fatal: [bookworm]: 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 ~/.ansible/tmp `\"&& mkdir \"` echo ~/.ansible/tmp/ansible-tmp-1674825123.6768813-82852-281344622743994 `\" && echo ansible-tmp-1674825123.6768813-82852-281344622743994=\"` echo ~/.ansible/tmp/ansible-tmp-1674825123.6768813-82852-281344622743994 `\" ), exited with result 1", "unreachable": true}
fatal: [bullseye]: 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 ~/.ansible/tmp `\"&& mkdir \"` echo ~/.ansible/tmp/ansible-tmp-1674825123.6879113-82853-251487814663029 `\" && echo ansible-tmp-1674825123.6879113-82853-251487814663029=\"` echo ~/.ansible/tmp/ansible-tmp-1674825123.6879113-82853-251487814663029 `\" ), exited with result 1", "unreachable": true}
fatal: [buster]: 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 ~/.ansible/tmp `\"&& mkdir \"` echo ~/.ansible/tmp/ansible-tmp-1674825123.7105093-82854-194659650698251 `\" && echo ansible-tmp-1674825123.7105093-82854-194659650698251=\"` echo ~/.ansible/tmp/ansible-tmp-1674825123.7105093-82854-194659650698251 `\" ), exited with result 1", "unreachable": true}
rm -rf /root/.cache/molecule
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 11
- Comments: 18
Commits related to this issue
- Work around 'Failed to create temporary directory' https://github.com/ansible-community/molecule/issues/3818#issuecomment-1599179293 — committed to tmtde/ansible-playbooks by waja 3 years ago
- Work around 'Failed to create temporary directory' https://github.com/ansible-community/molecule/issues/3818#issuecomment-1599179293 — committed to waja/ansible-role-docker-config by waja 3 years ago
- Work around 'Failed to create temporary directory' https://github.com/ansible-community/molecule/issues/3818#issuecomment-1599179293 — committed to waja/ansible-role-docker-tools by waja 3 years ago
- add ansible molecule options - fix unable to create tmp dir issue - see this for more https://github.com/ansible/molecule/issues/3818\#issuecomment-1599179293 — committed to onaio/ansible-nginx by machariamuguku 3 years ago
I was running into this issue on a new role when invoking Molecule via GitHub Actions. Turned out I had accidentally copied in an old version of
molecule.ymlfrom another role which was missing a couple ofplatformsoptions:Changing the cgroup volume to
rwand addingcgroupns_mode: hostresolved the issue for me:This occurs for me with a ~ 10% probability when running role tests with Jenkins on a number of worker nodes using the podman driver and different OS images. Could this be some timing problem like container is not ready up when trying to access? Current workaround is to repeat failed tests a couple of times, which “works” most times as the error does not seem to depend on either the used OS image, worker node, scenario or time of the day.
Also this annoys hell out of me as I try to find a cause or solution for a couple of weeks now.
Edit:
Worker host OS:
Ubuntu 20.04
Versions used:
Example of failing step:
Interestingly the error message suggests using a remote temp path rooted in /tmp which is obviously already the case?
Corresponding section in the molecule.yml files:
Try removing the
create.ymlfile located in the same folder as yourmolecule.ymlfile. It helped me. From what I understand, it contains an old workaround for gathering facts. I found this solution here.I was just updating multiple roles. an earlier molecule.yml functioned on many of them:
then hit this “failed to create temporary directory” for one repo. why only one repo? It required the suggested update:
(unless the issue occurs ‘randomly’, in which case the fix was accidental)
Edit: This update is discussed in https://www.jeffgeerling.com/blog/2022/docker-and-systemd-getting-rid-dreaded-failed-connect-bus-error “Docker recently switched from cgroups v1 to cgroups v2”.
I have the same error, but ONLY if I have
command:in themolecule/default/molecule.yml. When this isn’t there I don’t get the error. Although other errors occur at that point in relation to systems.Edit: The bug disappears when I replace
volume_mountswithvolumes, the following just works…