title: ansible if else construct
body: <p>Heres my if else Ansible logic ..</p>
  <pre><code>- name: Check certs exist
    stat: path=/etc/letsencrypt/live/{{ rootDomain }}/fullchain.pem
    register: st
  
  - include: ./_common/check-certs-renewable.yaml
    when: st.stat.exists
  
  - include: ./_common/create-certs.yaml
    when: not st.stat.exists
  </code></pre>
  <p>This code boils down to:</p>
  <blockquote>
  <p>IF certs exist</p>
  <p>renew certs</p>
  <p>ELSE</p>
  <p>create certs</p>
  <p>END IF</p>
  </blockquote>
  <p>Is this the correct approach or is there a better approach to the IF ELSE construct in ansible?</p>