Assert would be fine to use here.

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


On Fri, Sep 12, 2014 at 5:22 AM, Greg Leclercq <[email protected]> wrote:

> 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b0d0e1b3-2337-44c3-9bf3-bdb1de5332c9%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/b0d0e1b3-2337-44c3-9bf3-bdb1de5332c9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgxsXR%3Driy-QyOoZv9N_zU8EWHzMyP-pwfn_SW28e56ZSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to