# "import\_role" vs "roles"

**URL:** <https://forum.ansible.com/t/import-role-vs-roles/28734>\
**Category:** Ansible Project\
**Created:** [October 5, 2018, 8:30pm UTC](https://forum.ansible.com/t/import-role-vs-roles/28734 "2018-10-05T20:30:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimon](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Dimon](https://forum.ansible.com/u/Dimon)\
**Post date:** [October 5, 2018, 8:30pm UTC](https://forum.ansible.com/t/import-role-vs-roles/28734/1 "2018-10-05T20:30:08Z")

</div>

Hi, I would like to clarify things relating to new “import\_role” statement - documentation mentions it as a “new syntax” however it does not mention about the plans for the “roles” syntax. What’s the plan moving forward. I see both statements as distinct entities, however some of my colleagues seem to be confused about the state of affairs so we’d like some clarification on the matter.

So, to re-phrase my question differently:

is there a merit in abandoning “roles:” statement from our playbooks moving forward in favor of “import\_role” to future-proof our code?

---

<div class="post-metadata">

**Author:** ![Will\_Weber](https://avatars.discourse-cdn.com/v4/letter/w/ecd19e/32.png) [@Will\_Weber](https://forum.ansible.com/u/Will_Weber)\
**Post date:** [October 6, 2018, 2:36am UTC](https://forum.ansible.com/t/import-role-vs-roles/28734/2 "2018-10-06T02:36:40Z")

</div>

In my experience, I’ve really only used `import_role` as a task-level declaration, Occasionally after some preliminary setup tasks.

The `roles` declaration at the top of the playbook will always execute before the set of tasks in a given playbook.

It’s possible there are other, potentially larger, facets that I’m missing but for the most part the only _significant_ distinctions I’ve been able to make between the two of them is ordering, specifically that:

- roles declared in the roles heading will be executed before all tasks in a playbook

- tasks that use the import\_role module(?) are able to be arranged wherever the playbook writer chooses in the task list, giving a lot more flexibility on the side of playbook designers.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 6, 2018, 6:56am UTC](https://forum.ansible.com/t/import-role-vs-roles/28734/3 "2018-10-06T06:56:13Z")

</div>

It's a little more refined since you have pre\_tasks, tasks and post\_tasks and the execution order is pre\_tasks, roles, tasks and post\_tasks.

---

<div class="post-metadata">

**Author:** ![Trammael](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@Trammael](https://forum.ansible.com/u/Trammael)\
**Post date:** [January 13, 2019, 7:41pm UTC](https://forum.ansible.com/t/import-role-vs-roles/28734/4 "2019-01-13T19:41:53Z")

</div>

Additional question: Can "import\_role: " or "include\_role: ", accept a list of roles? Examples appear to only have one role. "Roles: " examples usually show a list of one or more roles.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 13, 2019, 7:52pm UTC](https://forum.ansible.com/t/import-role-vs-roles/28734/5 "2019-01-13T19:52:32Z")

</div>

No, if it could it would be documented under the name parameter in the documentation.

You can use loops but there are differences about how they work on import vs include, but this behavior is documented under Synopsis under the respective modules.
