An Ansible playbook includes multiple roles. The administrator wants to ensure that a specific role's tasks are executed before any other roles, even if the roles are listed in a different order in the playbook. Which approach should be used?
pre_tasks run before any roles, guaranteeing execution order.
Why this answer
The 'pre_tasks' section in an Ansible playbook runs before any roles listed in the 'roles' section, regardless of the order in which roles are defined. This allows the administrator to execute a specific role's tasks first by calling it within 'pre_tasks', ensuring it runs before all other roles.
Exam trap
The trap here is that candidates may think role ordering can be controlled via a parameter within the role definition itself, but Ansible relies on the playbook section order ('pre_tasks', 'roles', 'post_tasks') to enforce execution sequence.
How to eliminate wrong answers
Option A is wrong because 'any_errors_fatal' is a play-level keyword that stops execution on any task failure, not a mechanism to control task ordering. Option B is wrong because role dependencies with 'allow_duplicates: no' control whether a role can be included multiple times, not the execution order relative to other roles. Option C is wrong because there is no 'order' parameter in a role definition; Ansible roles do not support a built-in ordering parameter.