molecule: "fatal: [instance]: UNREACHABLE! Failed to create temporary directory" within in role created by 'molecule init role'

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version && molecule --version

ansible 2.10.7
  config file = None
  configured module search path = ['/home/bryant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/bryant/.pyenv/versions/vst-ansible-deployment/lib/python3.9/site-packages/ansible
  executable location = /home/bryant/.pyenv/versions/vst-ansible-deployment/bin/ansible
  python version = 3.9.1 (default, Feb 16 2021, 14:25:16) [GCC 9.3.0]

molecule 3.3.0 using python 3.9 
    ansible:2.10.7
    delegated:3.3.0 from molecule
    docker:0.2.4 from molecule_docker

Molecule installation method (one of):

  • pip (in a pyenv virtual environment)

Ansible installation method (one of):

  • pip (in a pyenv virtual environment)

Detail any linters or test runners used:

None.

Desired Behavior

Please give some details of the feature being requested or what should happen if providing a bug report.

I would like to be able to connect to the default molecule instance that is created, using the docker engine.

I have installed docker using the official doc, and my local user is member of the docker group.

I created a role using molecule init role and would like to run molecule converge with all the default settings only (later I will changed the docker image). I’ve also had this issue every time I’ve tried to use molecule on any role, even on entire playbooks, and on both Ubuntu 20.04 LTS desktop PopOS (current system) as well as a remote Ubuntu 20.02 LTS server.

I’ve tried molecule destroy as well as deleting my entire ~/.cache/molecule directory, as well as restarting docker.service, and putting remote_tmp = /tmp/ansible in my ansible.cfg, all with no change or resolution. I only have:

defaults]
inventory = inventory
vault_password_file = blah
host_key_checking = False
private_key_file = blah
callback_whitelist = ansible.posix.timer
remote_user = ubuntu

in my project’s ansible.cfg, and I’ve tried commenting out remote_user with no effect.

Actual Behaviour

Please give some details of what is actually happening. Include a minimum complete verifiable example with output of running molecule --debug.

molecule --debug converge
DEBUG    Validating schema /home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/molecule/default/molecule.yml.
INFO     default scenario test matrix: dependency, create, prepare, converge
INFO     Performing prerun...
WARNING  Computed fully qualified role name of redis_aws_init does not follow current galaxy requirements.
Please edit meta/main.yml and assure we can correctly determine full role name:

galaxy_info:
role_name: my_name  # if absent directory name hosting role is used instead
namespace: my_galaxy_namespace  # if absent, author is used instead

Namespace: https://galaxy.ansible.com/docs/contributing/namespaces.html#galaxy-namespace-limitations
Role: https://galaxy.ansible.com/docs/contributing/creating_role.html#role-names

As an alternative, you can add 'role-name' to either skip_list or warn_list.

INFO     Using ../../.cache/roles/redis_aws_init symlink to current repository in order to enable Ansible to find the role using its expected full name.
INFO     Added ANSIBLE_ROLES_PATH=~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:../../.cache/roles
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > create
WARNING  Skipping, instances already created.
INFO     Running default > prepare
WARNING  Skipping, prepare playbook not configured.
INFO     Running default > converge
INFO     Sanity checks: 'docker'
DEBUG: ANSIBLE ENVIRONMENT:
ANSIBLE_COLLECTIONS_PATH: /home/bryant/.cache/molecule/redis_aws_init/default/collections:/home/bryant/.ansible/collections:/usr/share/ansible/collections:/etc/ansible/collections
ANSIBLE_CONFIG: /home/bryant/.cache/molecule/redis_aws_init/default/ansible.cfg
ANSIBLE_FILTER_PLUGINS: /home/bryant/.pyenv/versions/vst-ansible-deployment/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/filter:/home/bryant/.cache/molecule/redis_aws_init/default/plugins/filter:/home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/plugins/filter:/home/bryant/.ansible/plugins/filter:/usr/share/ansible/plugins/filter
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_LIBRARY: /home/bryant/.pyenv/versions/vst-ansible-deployment/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/modules:/home/bryant/.cache/molecule/redis_aws_init/default/library:/home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/library:/home/bryant/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
ANSIBLE_ROLES_PATH: /home/bryant/.cache/molecule/redis_aws_init/default/roles:/home/bryant/src/api_guys/ansible-deploy-vst/roles:/home/bryant/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:../../.cache/roles

DEBUG: MOLECULE ENVIRONMENT:
MOLECULE_DEBUG: 'True'
MOLECULE_DEPENDENCY_NAME: galaxy
MOLECULE_DRIVER_NAME: docker
MOLECULE_ENV_FILE: /home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/.env.yml
MOLECULE_EPHEMERAL_DIRECTORY: /home/bryant/.cache/molecule/redis_aws_init/default
MOLECULE_FILE: /home/bryant/.cache/molecule/redis_aws_init/default/molecule.yml
MOLECULE_INSTANCE_CONFIG: /home/bryant/.cache/molecule/redis_aws_init/default/instance_config.yml
MOLECULE_INVENTORY_FILE: /home/bryant/.cache/molecule/redis_aws_init/default/inventory/ansible_inventory.yml
MOLECULE_PROJECT_DIRECTORY: /home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init
MOLECULE_PROVISIONER_NAME: ansible
MOLECULE_SCENARIO_DIRECTORY: /home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/molecule/default
MOLECULE_SCENARIO_NAME: default
MOLECULE_STATE_FILE: /home/bryant/.cache/molecule/redis_aws_init/default/state.yml
MOLECULE_VERIFIER_NAME: ansible
MOLECULE_VERIFIER_TEST_DIRECTORY: /home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/molecule/default/tests

DEBUG: SHELL REPLAY:
ANSIBLE_COLLECTIONS_PATH=/home/bryant/.cache/molecule/redis_aws_init/default/collections:/home/bryant/.ansible/collections:/usr/share/ansible/collections:/etc/ansible/collections ANSIBLE_CONFIG=/home/bryant/.cache/molecule/redis_aws_init/default/ansible.cfg ANSIBLE_FILTER_PLUGINS=/home/bryant/.pyenv/versions/vst-ansible-deployment/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/filter:/home/bryant/.cache/molecule/redis_aws_init/default/plugins/filter:/home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/plugins/filter:/home/bryant/.ansible/plugins/filter:/usr/share/ansible/plugins/filter ANSIBLE_FORCE_COLOR=1 ANSIBLE_LIBRARY=/home/bryant/.pyenv/versions/vst-ansible-deployment/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/modules:/home/bryant/.cache/molecule/redis_aws_init/default/library:/home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/library:/home/bryant/.ansible/plugins/modules:/usr/share/ansible/plugins/modules ANSIBLE_ROLES_PATH=/home/bryant/.cache/molecule/redis_aws_init/default/roles:/home/bryant/src/api_guys/ansible-deploy-vst/roles:/home/bryant/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:../../.cache/roles MOLECULE_DEBUG=True MOLECULE_DEPENDENCY_NAME=galaxy MOLECULE_DRIVER_NAME=docker MOLECULE_ENV_FILE=/home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/.env.yml MOLECULE_EPHEMERAL_DIRECTORY=/home/bryant/.cache/molecule/redis_aws_init/default MOLECULE_FILE=/home/bryant/.cache/molecule/redis_aws_init/default/molecule.yml MOLECULE_INSTANCE_CONFIG=/home/bryant/.cache/molecule/redis_aws_init/default/instance_config.yml MOLECULE_INVENTORY_FILE=/home/bryant/.cache/molecule/redis_aws_init/default/inventory/ansible_inventory.yml MOLECULE_PROJECT_DIRECTORY=/home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init MOLECULE_PROVISIONER_NAME=ansible MOLECULE_SCENARIO_DIRECTORY=/home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/molecule/default MOLECULE_SCENARIO_NAME=default MOLECULE_STATE_FILE=/home/bryant/.cache/molecule/redis_aws_init/default/state.yml MOLECULE_VERIFIER_NAME=ansible MOLECULE_VERIFIER_TEST_DIRECTORY=/home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/molecule/default/tests

COMMAND: ansible-playbook --diff --inventory /home/bryant/.cache/molecule/redis_aws_init/default/inventory --skip-tags molecule-notest,notest /home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/molecule/default/converge.yml

PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
fatal: [instance]: 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-1618876867.7336655-2529030-224654731083847 `\" && echo ansible-tmp-1618876867.7336655-2529030-224654731083847=\"` echo ~/.ansible/tmp/ansible-tmp-1618876867.7336655-2529030-224654731083847 `\" ), exited with result 1", "unreachable": true}

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

CRITICAL Ansible return code was 4, command was: ansible-playbook --diff --inventory /home/bryant/.cache/molecule/redis_aws_init/default/inventory --skip-tags molecule-notest,notest /home/bryant/src/api_guys/ansible-deploy-vst/roles/redis_aws_init/molecule/default/converge.yml

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (3 by maintainers)

Most upvoted comments

Hi guys, if someone else is struggling with this, deleting the default create.yml playbook resolved my problems. I do not know why and i do not care why.

Jut an FYI I found this happens to me when I have a bad state, either I’ve restarted or Docker has crashed (macOS). The remedy has been to do:

molecule destroy

This file never existed for me, I don’t think it’s the root cause

Problem in the current Ubuntu I can confirm, plain install ran this from scratch and same problem.
ubuntu-22 amd64 docker-desktop Ran every suggested fix, nothing works.

Jut an FYI I found this happens to me when I have a bad state, either I’ve restarted or Docker has crashed (macOS). The remedy has been to do:

molecule destroy

This helped solve my issue, thank you

For ubuntu-2204(in which cgroup v2 is used by default), could you try the workaround in this PR? zhan9san/ansible-role-jenkins#14 (files)

Adding cgroupns_mode: host to every platform in molecule.yml seems to pretty reliably solve this error for me!

I have not touched Ansible or Molecule for more than a year now (switched jobs and stopped using that stuff), so I am not really the best person to judge if this last error is caused by the same error as the original one. In the original report, Ansible reported that the test instance is not reachable, so all that “cannot create tmp directory” error message was irrelevant since there was no instance to operate on. But all of the follow-up responses omit this information, so there is no way to tell what exactly is broken.

I would advice you to open a new issue if the instance is reachable since this is a different issue compared to the one described here.

I can replicate this on Ubuntu 20. Same issue as @RickS-C137

@tadeboro Please considering re-opening.

Jut an FYI I found this happens to me when I have a bad state, either I’ve restarted or Docker has crashed (macOS). The remedy has been to do:

molecule destroy

Good idea! When this doesn’t work, I’ve found molecule destroy --all to be helpful. But make sure you’re okay with destroying everything first 😃