Files
sib_11_gestion_erreurs/fail_when.yml
2021-03-16 21:17:06 +01:00

30 lines
569 B
YAML

---
- hosts: centos
tasks:
- name: print a message
debug:
msg: "OS on {{ inventory_hostname }} is {{ ansible_distribution }}"
- name: send script
copy:
src: "{{ item }}"
dest: /tmp/
mode: 0750
loop:
- random.sh
- bad.sh
- name: execute bad script
command: "/tmp/bad/sh"
ignore_errors: true
- name: execute random script
command: /tmp//random.sh
register: result
failed_when: 2|string in result.stdout
- name: display result
debug:
var: result
when: 1|string in result.stdout