Skip to content

Troubleshooting

Molecule 25.2+ introduced breaking changes.

Failed to set permissions ... when becoming an unprivileged user

ACL management utilities are required for become: user. These may be left out for minimal install images.

[ERROR]: Task failed: Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chmod: invalid mode: ‘A+user:{USER}:rx:allow’

# Always install ACL packages as part of role dependencies.
apt install acl

YAML files reverted on test execution

File linking or caching issue with IDE or Molecule.

Suspected causes

  • SSHFS connection drops.
  • Rebooting while molecule testing instances are running.
  • IDE environment using stale file handle.

Clear all caches and re-open affected file:

  1. CLOSE the file with the issue in the editor and reopen/save. Re-run tests.
  2. Remove all molecule test state from all tested roles. Re-run tests.
    for x in $(ls -1); do pushd ${x} && molecule destroy --all && popd; done
  3. Clean out all ansible caches. Re-run tests.
    molecule destroy --all
    molecule reset
    rm -rfv ~/.cache/molecule/*
    rm -rfv /tmp/ansible-tmp*
    rm -rfv /tmp/ansible-cache/*
    rm -rfv ~/.ansible/*
    rm -rfv ~/.ansible_async/*

ERROR! Could not find or access

Molecule uses galaxy roles as dependencies when testing.

ERROR! Could not find or access '.../ansible_collection_srv/roles/{ROLE}/molecule/{TEST}/{TASK_FROM_FILE}.yml on the Ansible Controller.

fatal: [{INSTANCE}]: FAILED! => {
    "changed": false,
    "include": "{TASK_FROM_FILE}.yml",
    "reason": "Could not find or access '/var/git/ansible_collection_srv/roles/debian/molecule/network/global.yml' on the Ansible Controller."
}
# Use FQCN (Fully Qualified Collection Name)
- name: 'include full role'
  ansible.builtin.include_role:
    name: 'r_pufky.deb.os'

# Use tasks_from when no other tasks are sourced within.
- name: 'include task from role if there are no additional include_roles'
  ansible.builtin.include_role:
    name: 'r_pufky.deb.os'
    tasks_from: 'optimizations/firmware.yml'

ERROR! the role '{ROLE}' was not found ...

Molecule uses galaxy roles as dependencies when testing.

ERROR! the role 'r_pufky.{COLLECTION}.{ROLE}' was not found in ...

The offending line appears to be:

      ansible.builtin.include_role:
        name: 'r_pufky.deb.apt'
              ^ here
# Force install updated collection.
ansible-galaxy collection build -f
ansible-galaxy collection install {COLLECTION}-X.X.X.tar.gz -f

CRITICAL Idempotence test failed

Not all operations are idempotent.

molecule.yml

0644 {USER}:{USER}

# Explicitly disable when idempotence cannot be guaranteed.
scenario:
  test_sequence:
    # - 'idempotence'  # Reason for disable.

Gathering Facts failed

Leftover state from previous or interrupted test.

TASK [Gathering Facts] *********************************************************
fatal: [{HOST}]: 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
# Destroy and re-create.
molecule destroy --all

# Red herring. Resets internal molecule cache without destroying. If destroy
# did not fix the issue there's something else wrong.
molecule reset
    containers.