mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
e4cca4e40a
Refactoring of the following roles to make use of the new `prepare_vmware_tests` role. - `vmware_guest` - `vmware_guest_boot_facts` - `vmware_guest_custom_attribute_defs` - `vmware_guest_customization_facts` - `vmware_guest_disk_facts` - `vmware_guest_facts` - `vmware_guest_find` - `vmware_guest_move` - `vmware_guest_powerstate` - `vmware_guest_snapshot` - `vmware_guest_snapshot_facts` - `vmware_guest_tools_wait` This patch depends on: https://github.com/ansible/ansible/pull/55719 Original PR: https://github.com/ansible/ansible/pull/54882
61 lines
1.8 KiB
YAML
61 lines
1.8 KiB
YAML
# Test code for the vmware_guest_find module.
|
|
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
- import_role:
|
|
name: prepare_vmware_tests
|
|
vars:
|
|
setup_attach_host: true
|
|
setup_datastore: true
|
|
setup_virtualmachines: true
|
|
- name: find folders for each vm
|
|
vmware_guest_find:
|
|
validate_certs: False
|
|
hostname: "{{ vcenter_hostname }}"
|
|
username: "{{ vcenter_username }}"
|
|
password: "{{ vcenter_password }}"
|
|
name: "{{ item }}"
|
|
datacenter: "{{ dc1 }}"
|
|
with_items: "{{ infra.vm_list }}"
|
|
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 }}"
|
|
|
|
- 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
|
|
|
|
- name: find folders for each vm using UUID
|
|
vmware_guest_find:
|
|
validate_certs: False
|
|
hostname: "{{ vcenter_hostname }}"
|
|
username: "{{ vcenter_username }}"
|
|
password: "{{ vcenter_password }}"
|
|
uuid: "{{ guest_facts_0001['instance']['hw_product_uuid'] }}"
|
|
register: folder_uuid
|
|
|
|
- debug: var=folder_uuid
|
|
|
|
- assert:
|
|
that:
|
|
- "{{ 'folders' in folder_uuid }}"
|
|
- "{{ folder_uuid['folders']|length == 1 }}"
|