How to perform a task, by default, adjust with (not) of a given variable?

Good afternoon everyone!

want to transfer to playbook ansible variable, e.g. ansible-playbook -e "myvar=true" myplaybook.yml

in playbut tasks task1 and task2

how to make if the variable has not set to it by default, was considered false and was run task1 (default)

and if it is set to true, then run task2

March 23rd 20 at 19:41
2 answers
March 23rd 20 at 19:43
Jinja2 templates are not yet passed?)
- name: Create user
 name: "{{ my_variable | default('default_value') }}"
March 23rd 20 at 19:45
In variables you define it as false by default
and then override during a call, playbook. As: ansible-playbook -e "myvar=true" myplaybook.yml - Winfield_Remp commented on March 23rd 20 at 19:48

Find more questions by tags Ansible