ansible if then task


tasks:
- shell: if [[ -f "/etc/passwd" ]]; then /bin/true; else /bin/false; fi
register: result
ignore_errors: True

- command: /bin/something
when: result|failed

- command: /bin/something_else
when: result|success

- command: /bin/still/something_else
when: result|skipped

Leave a Reply

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