Ansible role not found during apply phase

Last updated: November 24, 2026

If an Ansible run fails with an error like the role 'role-name' was not found, and your repository's ansible.cfg sets roles_path, Ansible may not be reading that file.

Check the run log

Look for a warning near the start of the run saying Ansible is in a world-writable directory and is ignoring it as an ansible.cfg source. This is an Ansible security rule: Ansible won't load ansible.cfg from a world-writable working directory. When it skips the file, settings in it, such as roles_path, have no effect.

Fix 1: Set ANSIBLE_CONFIG or ANSIBLE_ROLES_PATH

Ansible always loads a config file named in the ANSIBLE_CONFIG environment variable. Add one of these environment variables to the stack or to an attached context:

Name

Example value

ANSIBLE_CONFIG

/mnt/workspace/source/ansible.cfg

ANSIBLE_ROLES_PATH

/mnt/workspace/source/roles

Your repository is cloned to /mnt/workspace/source. If your stack has a project root, include it in the path, for example /mnt/workspace/source/ansible/ansible.cfg.

Fix 2: Install roles from a requirements file

If your roles come from Ansible Galaxy or a Git repository, list them in a requirements file, and Spacelift installs them during the Initialization phase. To find which file locations are supported. To use a file in another location, set SPACELIFT_ANSIBLE_REQUIREMENTS_FILE to its path.

Fix 3: Keep roles next to your playbook

Ansible always searches a roles/ directory next to the playbook. Committing your roles to roles/role-name/ alongside the playbook works without any extra setup.

Role found during plan but missing during apply

When a run waits for confirmation, Spacelift saves the workspace (/mnt/workspace) after planning and restores it for the apply. Anything stored outside the workspace during planning is not kept, for example roles installed to ~/.ansible/roles. Keep your roles paths and install locations under /mnt/workspace.

Sources: