How to make mandatory variables if variable is defined

7 views
Skip to first unread message

Javier Martí

unread,
Apr 5, 2018, 2:57:46 AM4/5/18
to Ansible Project
Hi, I want to make sure before execution of the role that if a variable is defined you have to define another variables, can I do that?

I have a template:

{% if variable1 != '' %}
variable1 = {{ variable1 }}
variable2 = {{ variable2 }}
variable3 = {{ variable3 }}
{% endif %}

How to make mandatory variable2 and variable3 if variable1 is defined?

Kai Stian Olstad

unread,
Apr 5, 2018, 3:25:47 AM4/5/18
to ansible...@googlegroups.com
- assert:
that:
- variable2 is defined
- variable3 is defined
when: variable1 is defined


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages