In the ansible docs for Playbook Roles and Include Statements 
<http://docs.ansible.com/ansible/playbooks_roles.html>, it says that once 
you set up a role x and reference it in a playbook:


>    - Any copy tasks can reference files in roles/x/files/ without having 
>    to path them relatively or absolutely
>    - Any script tasks can reference scripts in roles/x/files/ without 
>    having to path them relatively or absolutely 
>    - Any template tasks can reference files in roles/x/templates/ without 
>    having to path them relatively or absolutely 
>    - Any include tasks can reference files in roles/x/tasks/ without 
>    having to path them relatively or absolutely
>
>
 This was misleading to me, I assumed I could just create a playbook, call 
in the role, and reference files and templates in the role without 
qualification.

The truth is: Any tasks WITHIN THE ROLE'S DIRECTORY STRUCTURE can reference 
files without having to path them.  *Not* "Any tasks".

I finally figured this out by finding this GitHub issue 
<https://github.com/ansible/ansible/issues/11566>, within which it is 
pointed out by jimi-c that "the role_path is only searched when the task 
itself comes from a role". 

Upon reflection, it makes sense, because a playbook can have multiple 
roles, and which one should it search? But for a newbie, this is quite 
confusing.

It would be nice if the documentation were updated.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/02072080-313f-4e4c-98c8-f3636e7d28fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to