AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Ansible Fix 'Role Not Found' Error: Path & Resolution Guide — Video Tutorial
Fix Ansible role not found error. Configure roles_path, install from Galaxy, check directory structure, and resolve common role loading issues.
What You'll Learn
- Introduction
- Playbook
- error code
- error execution
- fix code
- fix execution
- Conclusion
- The Error
- Quick Fixes
- Install Missing Role
Full Tutorial Content
Introduction
Today we're going to talk about Ansible troubleshooting, specifically about the "role not found" error.
I'm Luca Berton and welcome to today's episode of Ansible Pilot.
Playbook
The best way of talking about Ansible troubleshooting is to jump in a live Playbook to show you practically the `role not found errror` and how to solve it!
error code
- role.yml
```yaml
---
- name: role Playbook
hosts: all
become: true
roles:
- role: lucab85.ansible_role_log4shell
detector_path: "/var"
```
error execution
```bash
$ ansible-playbook -i virtualmachines/demo/inventory troubleshooting/role/role.yml
ERROR! the role 'lucab85.ansible_role_log4shell' was not found in /Users/lberton/prj/github/ansible-pilot/troubleshooting/role/roles:/Users/lberton/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/Users/lberton/prj/github/ansible-pilot/troubleshooting/role
The error appears to be in '/Users/lberton/prj/github/ansible-pilot/troubleshooting/role/role.yml': line 6, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
roles:
- role: lucab85.ansible_role_log4shell
^ here
ansible-pilot $ ls -al ~/.ansible/roles
total 0
drwxr-xr-x 2 lberton staff 64 Jan 7 08:19 .
drwxr-xr-x 8 lberton staff 256 Jan 7 08:19 ..
ansible-pilot $
```
fix code
- requirements.yml
```yaml
---
roles:
- name: lucab85.ansible_role_log4shell
```
fix execution
```bash
$ ansible-galaxy install -r troubleshooting/role/requirements.yml
Starting galaxy role install process
- downloading role 'ansible_role_log4shell', owned by lucab85
- downloading role from https://github.com/lucab85/ansible-role-log4shell/archive/v0.6.1.tar.gz
- extracting lucab85.ansible_role_log4shell to /Users/lberton/.ansible/roles/lucab85.ansible_role_log4shell
- lucab85.ansible_role_log4shell (v0.6.1) was installed successfully
ansible-pilot $ ls -al ~/.ansible/roles
total 0
drwxr-xr-x 3 lberton staff 96 Jan 7 08:24 .
drwxr-xr-x 8 lberton staff 256 Jan 7 08:19 ..
drwxr-xr-x 12 lberton staff 384 Jan 7 08:24 lucab85.ansible_role_log4shell
ansible-pilot $ ls -al ~/.ansible/roles/lucab85.ansible_role_log4shell
total 32
drwxr-xr-x 12 lberton staff 384 Jan 7 08:24 .
drwxr-xr-x 3 lberton staff 96 Jan 7 08:24 ..
-rw-rw-r-- 1 lberton staff 96 Jan 6 11:22 .ansible-lint
drwxr-xr-x 5 lberton staff 160 Jan 7 08:24 .github
-rw-rw-r-- 1 lberton staff 121 Jan 6 11:22 .yamllint
-rw-rw-r-- 1 lberton staff 1068 Jan 6 11:22 LICENSE
-rw-rw-r-- 1 lberton staff 3739 Jan 6 11:22 README.md
drwxr-xr-x 3 lberton staff 96 Jan 7 08:24 defaults
drwxr-xr-x 4 lberton staff 128 Jan 7 08:24 meta
drwxr-xr-x 3 lberton staff 96 Jan 7 08:24 molecule
drwxr-xr-x 3 lberton staff 96 Jan 7 08:24 tasks
drwxr-xr-x 3 lberton staff 96 Jan 7 08:24 vars
ansible-pilot $ ls -al ~/.ansible/roles/lucab85.ansible_role_log4shell/*
-rw-rw-r-- 1 lberton
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 8 min
- Category: installation
Read the full written article: Ansible Fix 'Role Not Found' Error: Path & Resolution Guide