I have a simple build script which installs wkhtmltophf on a server. However I only want this script to be run if the software isn’t already installed. Essentially, I want an if statement or check statement in Ansible. I.e. If file doesn’t exist then run this command.
I have read the Ansible documentation multiple times and it isn’t completely clear how to do this. Anyhow, here is the answer:
- name: If file don't exist run command command: /root/installer.sh creates=/usr/bin/wkhtmltopdf
This is command say “This command creates this file and so if the file doesn’t exist then run the command”.
I hope this helps someone