Ansible newbie, reporting misleading documentation on roles

35 views
Skip to first unread message

Spencer Brown

unread,
Dec 21, 2015, 1:08:14 PM12/21/15
to Ansible Project
In the ansible docs for Playbook Roles and Include Statements, 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, 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.

Brian Coca

unread,
Dec 21, 2015, 1:13:01 PM12/21/15
to Ansible Project
Reply all
Reply to author
Forward
0 new messages