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 }}"
|
|
|
|
name: "{{ item }}"
|
|
|
|
datacenter: "{{ dc1 }}"
|
|
|
|
with_items: "{{ infra.vm_list }}"
|
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
|
|
|
|
vmware_guest_facts:
|
|
|
|
validate_certs: False
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter: "{{ dc1 }}"
|
|
|
|
name: "{{ infra.vm_list[0] }}"
|
|
|
|
folder: "{{ f0 }}"
|
|
|
|
register: guest_facts_0001
|
|
|
|
|
|
|
|
- debug: var=guest_facts_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 }}"
|
|
|
|
uuid: "{{ guest_facts_0001['instance']['hw_product_uuid'] }}"
|
|
|
|
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 }}"
|