Debian Codegraph @

test/integration/targets/inventory_generator/verify.yml

raw
1 - hosts: localhost
2 gather_facts: no
3 vars:
4 expected_host_names:
5 - build_api_dev_runner
6 - build_api_prod_runner
7 - build_api_test_runner
8 - build_web_dev_runner
9 - build_web_prod_runner
10 - build_web_test_runner
11 - launch_api_dev_runner
12 - launch_api_prod_runner
13 - launch_api_test_runner
14 - launch_web_dev_runner
15 - launch_web_prod_runner
16 - launch_web_test_runner
17 expected_group_names:
18 - all
19 - api
20 - api_dev
21 - api_prod
22 - api_test
23 - build
24 - build_api
25 - build_api_dev
26 - build_api_prod
27 - build_api_test
28 - build_web
29 - build_web_dev
30 - build_web_prod
31 - build_web_test
32 - dev
33 - launch
34 - launch_api
35 - launch_api_dev
36 - launch_api_prod
37 - launch_api_test
38 - launch_web
39 - launch_web_dev
40 - launch_web_prod
41 - launch_web_test
42 - prod
43 - runner
44 - test
45 - ungrouped
46 - web
47 - web_dev
48 - web_prod
49 - web_test
50 tasks:
51 - name: verify the shape and contents of inventory from the plugin
52 assert:
53 that:
54 - groups.all | sort == expected_host_names
55 - groups.runner | sort == expected_host_names
56 - groups.keys() | sort == expected_group_names
57 # and now some spot checks...
58 - groups.api | length == 6
59 - groups.api_dev | length == 2
60 - groups.build | length == 6
61 - groups.build_api | length == 3
62 - groups.dev | length == 4
63 - groups.launch | length == 6
64 - groups.test | length == 4
65 - groups.web | length == 6
66
67 - name: dump inventory for a broken plugin configuration
68 command: ansible-inventory -i parent_without_name.yml --list --export
69 register: result
70
71 - assert:
72 that:
73 - (result.stdout | from_json(profile="inventory_legacy"))._meta.hostvars == {}
74 - (result.stdout | from_json(profile="inventory_legacy")).all.children == ["ungrouped"]
75 - result.stderr is contains('Element host_with_unnamed_parent has a parent with no name.')
76
77 - hosts: all
78 gather_facts: no
79 vars:
80 defined_on_play: alive # host vars have templates that refer to this
81 tasks:
82 - name: spot check host vars
83 assert:
84 that:
85 - my_dict.hello == 'alive'
86 - my_list[0] == 'alive'
87 - environment is defined