What's really the purpose of pre_tasks and post_tasks?

What exactly is the purpose of pre_tasks/post_tasks when one can just put "pre" tasks before the main tasks and "post" tasks after the main tasks in the "tasks" directive?

I've read the documentation many times and I can't understand the need for them. I must be missing something here, right?

Primarily they were introduced to provide execution order when using roles:. post_tasks is probably mostly useless. The execution order is:

pre_tasks
roles
tasks
post_tasks

What exactly is the purpose of roles then? :sweat_smile:

I mean, is there a difference between roles and use include_role / import_role inside tasks?

roles: existed long before include_role and import_role. Many on the core team would say that import_role and include_role are the future. I personally would like to see pre_tasks, roles, and post_tasks deprecated. Time will tell…

So, in other words, with include_role, import_role, and tasks, one can do pretty much anything that roles, pre_tasks and post_tasks can do as well, right?

Thank you so much for your help, that clarifies things for me :slight_smile:

Stay safe!