ansible/test/integration/targets/vmware_guest_find/tasks/main.yml
Gonéri Le Bouder e4cca4e40a vmware: refactoring of vmware test roles -- part4
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
2019-05-01 11:22:14 -04:00

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