Debian Codegraph @

ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/tasks/main.yml

raw
1 # Test code for the vmware_guest_find module.
2 # Copyright: (c) 2017, James Tanner <[email protected]>
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 - import_role:
6 name: prepare_vmware_tests
7 vars:
8 setup_attach_host: true
9 setup_datastore: true
10 setup_virtualmachines: true
11 - name: find folders for each vm
12 vmware_guest_find:
13 validate_certs: false
14 hostname: "{{ vcenter_hostname }}"
15 username: "{{ vcenter_username }}"
16 password: "{{ vcenter_password }}"
17 name: "{{ item.name }}"
18 with_items: "{{ virtual_machines }}"
19 register: folders
20
21 - debug: var=item
22 with_items: "{{ folders.results }}"
23
24 # We only care that each VM was found, not that the folder path
25 # is completely accurate. Eventually the test should be extended
26 # to validate the full path for each VM.
27 - assert:
28 that:
29 - "{{ 'folders' in item }}"
30 - "{{ item['folders']|length == 1 }}"
31 with_items: "{{ folders.results }}"
32
33 - name: get fact of the first VM
34 vmware_guest_info:
35 validate_certs: false
36 hostname: "{{ vcenter_hostname }}"
37 username: "{{ vcenter_username }}"
38 password: "{{ vcenter_password }}"
39 datacenter: "{{ dc1 }}"
40 name: "{{ virtual_machines[0].name }}"
41 folder: "{{ virtual_machines[0].folder }}"
42 register: guest_info_0001
43
44 - debug: var=guest_info_0001
45
46 - name: find folders for each vm using UUID
47 vmware_guest_find:
48 validate_certs: false
49 hostname: "{{ vcenter_hostname }}"
50 username: "{{ vcenter_username }}"
51 password: "{{ vcenter_password }}"
52 uuid: "{{ guest_info_0001['instance']['hw_product_uuid'] }}"
53 register: folder_uuid
54
55 - debug: var=folder_uuid
56
57 - assert:
58 that:
59 - "{{ 'folders' in folder_uuid }}"
60 - "{{ folder_uuid['folders']|length == 1 }}"