summaryrefslogtreecommitdiffstats
path: root/examples/playbooks/block.yml
blob: 6194cc62d7c02e9d2358d064099575ab0200a099 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
- hosts: all

  pre_tasks:
    - { import_tasks: does-not-exist.yml }

  tasks:
    - block:
        - name: Successful debug message
          debug: msg='i execute normally'
        - name: Failure command
          ansible.builtin.command: /bin/false
          changed_when: false
        - name: Never reached debug message
          debug: msg='i never execute, cause ERROR!'
      rescue:
        - name: Exception debug message
          ansible.builtin.debug: msg='I caught an error'
        - name: Another failure command
          ansible.builtin.command: /bin/false
          changed_when: false
        - name: Another missed debug message
          debug: msg='I also never execute :-('
      always:
        - name: Always reached debug message
          ansible.builtin.debug: msg="this always executes"