2017-07-31 04:48:57 +02:00
|
|
|
# Test code for the vmware_guest_find module.
|
2017-11-06 17:28:15 +01:00
|
|
|
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
|
2017-07-31 04:48:57 +02:00
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
2019-04-24 19:58:09 +02:00
|
|
|
- import_role:
|
|
|
|
name: prepare_vmware_tests
|
|
|
|
vars:
|
|
|
|
setup_attach_host: true
|
|
|
|
setup_datastore: true
|
|
|
|
setup_virtualmachines: true
|
2017-06-22 19:49:58 +02:00
|
|
|
- name: find folders for each vm
|
|
|
|
vmware_guest_find:
|
|
|
|
validate_certs: False
|
2019-04-24 19:58:09 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2019-05-16 15:36:48 +02:00
|
|
|
name: "{{ item.name }}"
|
2019-04-24 19:58:09 +02:00
|
|
|
datacenter: "{{ dc1 }}"
|
2019-05-16 15:36:48 +02:00
|
|
|
with_items: "{{ virtual_machines }}"
|
2017-06-22 19:49:58 +02:00
|
|
|
register: folders
|
|
|
|
|
|
|
|
- debug: var=item
|
|
|
|
with_items: "{{ folders.results }}"
|
|
|
|
|
|
|
|
# We only care that each VM was found, not that the folder path
|
|
|
|
# is completely accurate. Eventually the test should be extended
|
|
|
|
# to validate the full path for each VM.
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "{{ 'folders' in item }}"
|
|
|
|
- "{{ item['folders']|length == 1 }}"
|
|
|
|
with_items: "{{ folders.results }}"
|
2017-06-27 17:58:57 +02:00
|
|
|
|
2019-04-24 19:58:09 +02:00
|
|
|
- name: get fact of the first VM
|
2019-08-26 20:45:34 +02:00
|
|
|
vmware_guest_info:
|
2019-04-24 19:58:09 +02:00
|
|
|
validate_certs: False
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter: "{{ dc1 }}"
|
2019-05-16 15:36:48 +02:00
|
|
|
name: "{{ virtual_machines[0].name }}"
|
|
|
|
folder: "{{ virtual_machines[0].folder }}"
|
2019-08-26 20:45:34 +02:00
|
|
|
register: guest_info_0001
|
2019-04-24 19:58:09 +02:00
|
|
|
|
2019-08-26 20:45:34 +02:00
|
|
|
- debug: var=guest_info_0001
|
2017-06-27 17:58:57 +02:00
|
|
|
|
|
|
|
- name: find folders for each vm using UUID
|
|
|
|
vmware_guest_find:
|
|
|
|
validate_certs: False
|
2019-04-24 19:58:09 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2019-08-26 20:45:34 +02:00
|
|
|
uuid: "{{ guest_info_0001['instance']['hw_product_uuid'] }}"
|
2019-04-24 19:58:09 +02:00
|
|
|
register: folder_uuid
|
2017-06-27 17:58:57 +02:00
|
|
|
|
2019-04-24 19:58:09 +02:00
|
|
|
- debug: var=folder_uuid
|
2017-06-27 17:58:57 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-04-24 19:58:09 +02:00
|
|
|
- "{{ 'folders' in folder_uuid }}"
|
|
|
|
- "{{ folder_uuid['folders']|length == 1 }}"
|