title: How can I run a ansible task only if a file or directory does NOT exist?
body: <p>In an Ansible playbook I want to run tasks if a directory does <strong>not</strong> exists.</p>
  
  <pre><code>- name: Check for java exists in /opt     
    stat: path=/opt/jdk1.8.0_71
    register: p
    when: p.stat.isdir is defined and p.stat.isdir
  </code></pre>
  
  <p>But what must I do to ensure that the following tasks runs only if this dir does not exist?</p>
  
  <pre><code>- name: Extract java if dir not existing
    command: tar xzf /tmp/jdk1.8.0_71 chdir=/opt
  </code></pre>