Using roles at the play level
The classic (original) way to use roles is with therolesoption for a given play:
When you use therolesoption at the play level, each role ‘x’ looks for amain.yml(alsomain.yamlandmain) in the following directories:
roles/x/tasks/roles/x/handlers/roles/x/vars/roles/x/defaults/roles/x/meta/Any copy, script, template or include tasks (in the role) can reference files in roles/x/{files,templates,tasks}/ (dir depends on task) without having to path them relatively or absolutely.
When you use therolesoption at the play level, Ansible treats the roles as static imports and processes them during playbook parsing. Ansible executes each play in this order:
Anypre_tasksdefined in the play.Any handlers triggered by pre_tasks.Each role listed inroles:, in the order listed. Any role dependencies defined in the role’smeta/main.ymlrun first, subject to tag filtering and conditionals. SeeUsing role dependenciesfor more details.Anytasksdefined in the play.Any handlers triggered by the roles or tasks.Anypost_tasksdefined in the play.Any handlers triggered by post_tasks.
You can pass other keywords to therolesoption: