# Role creation in Tower

**URL:** <https://forum.ansible.com/t/role-creation-in-tower/9029>\
**Category:** Get Help\
**Created:** [September 28, 2024, 9:47am UTC](https://forum.ansible.com/t/role-creation-in-tower/9029 "2024-09-28T09:47:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![M-K](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@M-K](https://forum.ansible.com/u/M-K)\
**Post date:** [September 28, 2024, 9:47am UTC](https://forum.ansible.com/t/role-creation-in-tower/9029/1 "2024-09-28T09:47:27Z")

</div>

Hello,

I am new to Ansible. If I were asked to build a role that provides some fields (database columns - server name and event name) to another playbook and get back data such as creation date and resolved date; i.e required to mock the other person’s code; what folders do I have to include?

I understand that Ansible code for role usually has 1 or more of 8 folders - tasks, handlers, templates, files, vars, defaults, meta, library, module\_utils, lookup\_plugins;

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [September 29, 2024, 3:07pm UTC](https://forum.ansible.com/t/role-creation-in-tower/9029/2 "2024-09-29T15:07:39Z")

</div>

> [@M-K](#):
>
> I am new to Ansible.

In that case, welcome to Ansible, and to _the Forum_.

> [@M-K](#):
>
> If I were asked to build a role […] what folders do I have to include?

Skipping the elided parts of your question (which I’ll get to shortly), you can leave out any part of a role that you aren’t using. The only ways to invoke a role that I know of expect at least one task file in the role’s `tasks/` folder, so I’d guess the strict answer to your question is a `tasks/` folder.

The more interesting part of your question is the “build a role that provide some [data] to another playbook and get [other data] back” bit. The “tech support” answer (technically accurate but totally useless) is, “You don’t.” That is, roles don’t invoke playbooks. However:

1. _Roles_ can invoke other _roles_ through either:

- declaration in a role’s `dependencies:` dictionary in that role’s `meta/main.yml` file
- `ansible.builtin.include_role` and `ansible.builtin.import_role` modules, invoked through tasks.

1. _Playbooks_ can invoke _roles_:

- statically in the playbook’s `roles:` section
- statically by the `ansible.builtin.import_role` module or dynamically by the `ansible.builtin.include_role` module in the playbook’s `tasks:` section.

1. And finally, _playbooks_ can invoke other _playbooks_

- by [ansible.builtin.import\_playbook](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_playbook_module.html#ansible-builtin-import-playbook-module-import-a-playbook) module. Unlike the other modules above, `import_playbook` can’t appear in a `tasks:` list; it can only be used at the outermost playbook level.

But your topic title mentions “Tower”, a.k.a. “AWX”, in which case some other options are available to you. An AWX _Project_ can have multiple job _Templates_, each of which defines a way to invoke one of the playbooks contained in the project. These AWX job templates are roughly equivalent to running `ansible-playbook` at the CLI.

But at a higher level, AWX also allows you to create _Workflows_ – networks of job templates to be invoked serially or in parallel, and optionally dependent on the success of prior jobs in the workflow. (This _sounds like_ what your question is about, what with having “Tower” in the topic title and mentioning passing data to other playbooks, but I expect this is far beyond what you actually need.)

So back to your question. It’s possible all you need are a couple of roles, and your first role invokes the second via `ansible.builtin.include_role` with some variables defined. The second role does its work and returns data either by `register:` on its task(s) or by `ansible.builtin.set_fact:`. All of this could live within the same _Project_. (I’m hopeful for your sake that’s the case, because you’ve got a lot to learn before you see progress otherwise.)

Alternatively, you may need to invoke playbooks from other projects (highly unlikely at this stage), in which case you would need AWX _Workflows_ running playbooks from one or more _Projects_.

I didn’t mean to turn this into an _Intro to Ansible -101_ course. Maybe it gives you what you need to refine your questions a bit.

And we do look forward to your questions!  
Again, welcome to Ansible!
