# Documenting variables expected by a role

**URL:** <https://forum.ansible.com/t/documenting-variables-expected-by-a-role/16190>\
**Category:** Ansible Project\
**Created:** [September 12, 2014, 9:22am UTC](https://forum.ansible.com/t/documenting-variables-expected-by-a-role/16190 "2014-09-12T09:22:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Leclercq](https://avatars.discourse-cdn.com/v4/letter/g/e9bcb4/32.png) [@Greg\_Leclercq](https://forum.ansible.com/u/Greg_Leclercq)\
**Post date:** [September 12, 2014, 9:22am UTC](https://forum.ansible.com/t/documenting-variables-expected-by-a-role/16190/1 "2014-09-12T09:22:36Z")

</div>

Dear Ansible enthousiasts,

When I write a role, I’d like to tell what are the variables that tasks and templates will use. To prevent the interruption of the playbook in the middle of the execution of a role because a variable is not set, I also want to ensure that the playbook defines all mandatory variables.

My current approach is to provide a file `tasks/init.yml` in the role with an assert command such as:

```yaml
- assert:
that:
- var != ''
tags: ["check"]

```

Then I include the file in `tasks/main.yml`:

```yaml
- include: init.yml
- ...

```

I can check the role with `ansible-playbook -i inventory playbook.yml -t check`.

What do you think about that? Do you have best practices to solve the same problems?  
Your feedback is welcome :).

Cheers,

- Greg

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 12, 2014, 1:51pm UTC](https://forum.ansible.com/t/documenting-variables-expected-by-a-role/16190/2 "2014-09-12T13:51:36Z")

</div>

Assert would be fine to use here.

(For future reference, the mailing list doesn’t format things in Markdown)
