Debian Codegraph @

test/integration/targets/register_projections/tasks/lazy.yml

raw
1 - name: Verify register projections are lazy
2 debug:
3 loop: [1, 2, 3]
4 register:
5 # If this variable is resolved during task execution, it will fail.
6 # It will only resolve without error after the task has been completed, which is the only time it should be evaluated.
7 not_used_during_execution: 1 if _task.loop_result.results | length == 3 else 1 / 0
8
9 - name: Verify projection was evaluated after task completion
10 assert:
11 that: not_used_during_execution == 1
12
13 - name: Verify register projections are not visible to non-loop tasks
14 debug:
15 msg: "rp_value is {{ rp_value | default('not defined') }}"
16 register:
17 rp_value: "1"
18 result: _task.result
19
20 - name: Verify the result
21 assert:
22 that:
23 - result.msg == "rp_value is not defined"
24
25 - name: Verify register projections can be defined in any order
26 debug:
27 register:
28 rp_answer: rp_two + rp_three
29 rp_two: rp_one * 2
30 rp_three: rp_one * 3
31 rp_expected: rp_two + rp_three
32 rp_one: 1
33
34 - name: Verify the result
35 assert:
36 that:
37 - rp_answer == rp_expected
38 - rp_answer == 5