In ansible playbook, how skip task if file already exist in block task?
---
- name: register status of /tmp/toolbox.tar.gz
stat:
path: /tmp/toolbox.tar.gz
register: toolbox_path
- name: install jetbrains toolbox
# check if toolbox_path is a regular file
when: "not toolbox_path.stat.exists"
block:
- name: download toolbox
get_url:
url: "https://download.jetbrains.com/toolbox/jetbrains-toolbox-{{ toolbox_version }}.tar.gz"
dest: /tmp/toolbox.tar.gz
- name: open toolbox
unarchive:
src: /tmp/toolbox.tar.gz
dest: /opt/jetbrains-toolbox
You might also want to include checksums in the download as you know the exact version you want to download.