add file-test.yml
This commit is contained in:
37
file-test.yml
Normal file
37
file-test.yml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
- name: Verify file existance and handle errors if needed
|
||||||
|
hosts: all
|
||||||
|
gather_facts: no
|
||||||
|
become: no
|
||||||
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Run file test
|
||||||
|
block:
|
||||||
|
- name: "Test #3 - induce failure (but only for a specified host)"
|
||||||
|
command:
|
||||||
|
cmd: cat /tmp/hello-ansible.txt
|
||||||
|
register: r_check_file
|
||||||
|
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Exception caught!
|
||||||
|
debug:
|
||||||
|
msg:
|
||||||
|
- "host : {{ inventory_hostname }}"
|
||||||
|
- "rc : {{ r_check_file.rc }}"
|
||||||
|
- "stdout : {{ r_check_file.stdout }}"
|
||||||
|
- "stderr : {{ r_check_file.stderr }}"
|
||||||
|
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Job complete
|
||||||
|
debug:
|
||||||
|
msg:
|
||||||
|
- "host : {{ inventory_hostname }}"
|
||||||
|
- "rc : {{ r_check_file.rc }}"
|
||||||
|
- "stdout : {{ r_check_file.stdout }}"
|
||||||
|
- "stderr : {{ r_check_file.stderr }}"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
Reference in New Issue
Block a user