Debian Codegraph @

test/integration/targets/set_stats/test_simple.yml

raw
1 ---
2 - hosts: testhost
3 gather_facts: false
4 tasks:
5 - name: test simple data with defaults
6 set_stats:
7 data:
8 my_int: 42
9 my_string: "foo"
10 register: result
11
12 - name: assert simple data return
13 assert:
14 that:
15 - result is succeeded
16 - not result.changed
17 - '"ansible_stats" in result'
18 - '"data" in result.ansible_stats'
19 - result.ansible_stats.data.my_int == 42
20 - result.ansible_stats.data.my_string == "foo"
21 - '"per_host" in result.ansible_stats'
22 - not result.ansible_stats.per_host
23 - '"aggregate" in result.ansible_stats'
24 - result.ansible_stats.aggregate
25
26 - name: test per_host and aggregate settings
27 set_stats:
28 data:
29 my_int: 42
30 per_host: yes
31 aggregate: no
32 register: result
33
34 - name: assert per_host and aggregate changes
35 assert:
36 that:
37 - result is succeeded
38 - not result.changed
39 - '"ansible_stats" in result'
40 - '"per_host" in result.ansible_stats'
41 - result.ansible_stats.per_host
42 - '"aggregate" in result.ansible_stats'
43 - not result.ansible_stats.aggregate
44
45 - name: Test bad call
46 block:
47 - name: "EXPECTED FAILURE - test invalid data type"
48 set_stats:
49 data:
50 - 1
51 - 2
52
53 - fail:
54 msg: "should not get here"
55 rescue:
56 - assert:
57 that:
58 - ansible_failed_task.name == "EXPECTED FAILURE - test invalid data type"
59 - ansible_failed_result.msg == "The 'data' option needs to be a dictionary/hash"
60
61 - name: Test options from template
62 set_stats:
63 data:
64 my_string: "foo"
65 aggregate: "x"
66
67 - name: Test bad data
68 block:
69 - name: "EXPECTED FAILURE - bad data"
70 set_stats:
71 data:
72 .bad: 1
73 - fail:
74 msg: "should not get here"
75 rescue:
76 - assert:
77 that:
78 - ansible_failed_task.name == "EXPECTED FAILURE - bad data"
79 - ansible_failed_result.msg is contains "Invalid variable name '.bad'"