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