2018-08-13 15:21:33 +02:00
|
|
|
---
|
|
|
|
- hosts: testhost
|
|
|
|
gather_facts: no
|
|
|
|
vars:
|
|
|
|
foo: foo bar
|
|
|
|
tasks:
|
|
|
|
- name: Changed task
|
|
|
|
command: echo foo
|
|
|
|
changed_when: true
|
|
|
|
notify: test handlers
|
|
|
|
|
|
|
|
- name: Ok task
|
|
|
|
command: echo foo
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: Failed task
|
|
|
|
fail:
|
|
|
|
msg: no reason
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Skipped task
|
|
|
|
command: echo foo
|
|
|
|
when: false
|
|
|
|
|
|
|
|
- name: Task with var in name ({{ foo }})
|
|
|
|
command: echo foo
|
|
|
|
|
|
|
|
- name: Loop task
|
|
|
|
command: echo foo
|
|
|
|
loop:
|
|
|
|
- 1
|
|
|
|
- 2
|
|
|
|
- 3
|
|
|
|
loop_control:
|
|
|
|
label: foo-{{ item }}
|
2019-02-20 04:00:47 +01:00
|
|
|
|
2019-10-11 00:24:31 +02:00
|
|
|
# detect "changed" debug tasks being hidden with display_ok_tasks=false
|
|
|
|
- name: debug loop
|
|
|
|
debug:
|
|
|
|
msg: debug-{{ item }}
|
|
|
|
changed_when: item == 1
|
|
|
|
failed_when: item == 2
|
|
|
|
when: item != 4
|
|
|
|
ignore_errors: yes
|
|
|
|
loop:
|
|
|
|
- 1
|
|
|
|
- 2
|
|
|
|
- 3
|
|
|
|
- 4
|
|
|
|
loop_control:
|
|
|
|
label: debug-{{ item }}
|
|
|
|
|
2019-02-20 04:00:47 +01:00
|
|
|
- block:
|
|
|
|
- name: EXPECTED FAILURE Failed task to be rescued
|
|
|
|
fail:
|
|
|
|
rescue:
|
|
|
|
- name: Rescue task
|
|
|
|
command: echo rescued
|
|
|
|
|
2020-04-09 20:27:58 +02:00
|
|
|
- include_tasks: include_me.yml
|
|
|
|
loop:
|
|
|
|
- 1
|
|
|
|
|
2018-08-13 15:21:33 +02:00
|
|
|
handlers:
|
|
|
|
- name: Test handler 1
|
|
|
|
command: echo foo
|
|
|
|
listen: test handlers
|
|
|
|
|
|
|
|
- name: Test handler 2
|
|
|
|
command: echo foo
|
|
|
|
changed_when: false
|
|
|
|
listen: test handlers
|
|
|
|
|
|
|
|
- name: Test handler 3
|
|
|
|
command: echo foo
|
|
|
|
listen: test handlers
|
|
|
|
|
|
|
|
# An issue was found previously for tasks in a play using strategy 'free' after
|
|
|
|
# a non-'free' play in the same playbook, so we protect against a regression.
|
|
|
|
- hosts: testhost
|
|
|
|
gather_facts: no
|
|
|
|
strategy: free
|
|
|
|
tasks:
|
|
|
|
- name: First free task
|
|
|
|
command: echo foo
|
|
|
|
|
|
|
|
- name: Second free task
|
|
|
|
command: echo foo
|