Bootstrap FreeKB - Ansible - Resolve "ERROR! Could not find specified file in role"
Ansible - Resolve "ERROR! Could not find specified file in role"

Updated:   |  Ansible articles

Let's say something like this is being returned.

TASK [include_role 'nfs' stop.yml]
ERROR! Could not find specified file in role: tasks/stop.yml

 

Notice in this example this is occurring when using include_role to include the role named "nfs" to run the tasks in the YAML file named stop.yml. Check out my article Ansible - Invoking a role using the include_role module.

For example, let's say you have the following structure.

├── /usr/local
│   ├── main.yml
│   ├── roles
│   │   ├── nfs
│   │   ├── ├── tasks
│   │   ├── ├── ├── start.yml
│   │   ├── ├── ├── stop.yml

 

And your main.yml playbook has the following, to include the tasks in the stop.yml file in the nfs role.

---
- hosts: localhost
  tasks:
  - name: include_role 'nfs' stop.yml
    include_role:
      name: nfs
      tasks_from: stop.yml
...

 

This github issue speaks to this issue -> https://github.com/ansible/ansible/issues/22571

You can change include_role to import_role, like this.

---
- hosts: localhost
  tasks:
  - name: import_role 'nfs' stop.yml
    import_role:
      name: nfs
      tasks_from: stop.yml
...

 

Or, you can try adding static: no.

---
- hosts: localhost
  tasks:
  - name: include_role 'nfs' stop.yml
    include_role:
      name: nfs
      tasks_from: stop.yml
    static: no
...

 

Or you can change the name of your playbook from stop.yml (since this is a common keyword) to something more unique, such as stop_nfs.yml.

---
- hosts: localhost
  tasks:
  - name: include_role 'nfs' stop.yml
    include_role:
      name: nfs
      tasks_from: stop_nfs.yml
...

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 509803 in the box below so that we can be sure you are a human.