Answer the question
In order to leave comments, you need to log in
How to execute task by default, adjusting with a (not) set variable?
Good afternoon everyone!
I want to pass a variable to the ansible playbook, for example ansible-playbook -e "myvar=true" myplaybook.yml
in the playbook there are task1 and task2 tasks
how to make it so that if the variable is not set, it will be considered false by default and task1 will be executed ( default)
and if it is set to true, then task2 was executed
thanks
Answer the question
In order to leave comments, you need to log in
Jinja2 templates hasn't gone through yet?)
- name: Create user
user:
name: "{{ my_variable | default('default_value') }}"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question