Ansible: running command only if the file doesn’t exist

In order to achieve this, you have to use Ansible module, ‘command’ . You also have to make sure that the file that you want to execute is already in the remote host.

Command module has ‘creates’ parameter that checks if the folder already been created, if it doesn’t it will run this command, otherwise Ansible will skip this command.

 
- name: Install Intel Compilers (Skip if it's already been installed) 
  command: /tmp/install_compilers.sh creates=/opt/intel 

5 thoughts on “Ansible: running command only if the file doesn’t exist

  1. Chick-fil-A is indeed known for its focus on customer satisfaction, and the MyCFAVisit survey is a great way for customers to provide feedback. This approach helps the company understand customer experiences and make improvements. Their commitment to service quality and guest experience sets them apart in the fast food industry. Have you participated in the survey before?
    https://www.mycfavisit.org/

Leave a Reply

Your email address will not be published. Required fields are marked *