Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Last active July 14, 2018 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YumaInaura/a7ed9cca63be318457f5d938ac5639e3 to your computer and use it in GitHub Desktop.
Save YumaInaura/a7ed9cca63be318457f5d938ac5639e3 to your computer and use it in GitHub Desktop.
Ansible playbook example of script module using creates / removes args
- hosts:
- example
tasks:
- name: This task will be run because trigger.txt not exists
script: files/echo.sh
args:
creates: trigger.txt # run only when file exist
changed_when: no
- name: This task will be skipped because trigger.txt not exists
script: files/echo.sh
args:
removes: trigger.txt # run only when file not exist
changed_when: no
- name: Touch trigger.txt
file:
path: trigger.txt
state: touch
- name: This task will be skipped because trigger.txt exists
script: files/echo.sh
args:
creates: trigger.txt # run only when file exist
changed_when: no
- name: This task will be run because trigger.txt exists
script: files/echo.sh
args:
removes: trigger.txt # run only when file exist
changed_when: no
- name: Cleanup trigger.txt
file:
path: trigger.txt
state: absent
@YumaInaura
Copy link
Author

I will not able to remember stand creates / removes act...

@YumaInaura
Copy link
Author

ENV

  • ansible 2.6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment