title: How to use IF ELSE in YAML with variable?
body: <p>I am using a YAML file for the Ansible Tower with the following information</p>
  <pre class="lang-yaml prettyprint-override"><code>- name: &quot;Package Deployment&quot;
    block:
      - name: &quot;Update package {{ package }}&quot;
        yum:
          update_cache: True
          update_only: True
          name: &quot;{{ package }}{{ '' if (version is not defined or version == 'latest') else '-{{ version }}' }}&quot;
          state: &quot;{{ state|default('latest' if version == 'latest' else 'present') }}&quot;
        become: true
  </code></pre>
  <p>When I passed the YAML variables</p>
  <pre class="lang-yaml prettyprint-override"><code>package: package
  version: latest
  </code></pre>
  <p>then it prints <code>package</code> but if I pass YAML variables as</p>
  <pre class="lang-yaml prettyprint-override"><code>package: package
  version: 22
  </code></pre>
  <p>then it prints <code>package-{{ version }}</code> instead of <code>package-22</code>.</p>