title: How can I use a condition to set a variable value in Ansible?
body: <p>I have two variables: <code>a</code>, <code>b</code>.</p>
  
  <p>I want to assign a value to a variable <code>c</code> based on which: <code>a</code> or <code>b</code> contains greater numerical value.</p>
  
  <p>This what I tried:</p>
  
  <pre><code>- set_fact:
      c: "test1"
    when: a &lt;= b
  
  - set_fact:
      c: "test2"
    when: b &lt;= a
  </code></pre>
  
  <p>Look like it always sets <code>c</code> to <code>test1</code> not <code>test2</code>.</p>