1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/vmware_guest_find/tasks/main.yml

62 lines
1.8 KiB
YAML
Raw Normal View History

# 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 }}"