In an Ansible playbook I want to run tasks if a directory does not exists.
- 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
But what must I do to ensure that the following tasks runs only if this dir does not exist?
- name: Extract java if dir not existing
command: tar xzf /tmp/jdk1.8.0_71 chdir=/opt
- name: Extract java if dir not existing
command: tar xzf /tmp/jdk1.8.0_71 chdir=/opt
when: not p.stat.exists