Tasks based on variable definition
It's a duplicate of Ansible - Use default if a variable is not defined

version: "{{ ver | default('default_version') }}"


To use default_version in case ver is empty

- set_fact:
    version: "{{ default_version }}"
  when: ver == ""


or (Ansible Galaxy warning-free option)

  when: ver | length &gt; 0