diff --git a/test/integration/targets/prepare_vmware_tests/defaults/main.yml b/test/integration/targets/prepare_vmware_tests/defaults/main.yml deleted file mode 100644 index bb8ef983c1c..00000000000 --- a/test/integration/targets/prepare_vmware_tests/defaults/main.yml +++ /dev/null @@ -1,25 +0,0 @@ -dc1: DC0 -ccr1: DC0_C0 -ds1: LocalDS_0 -ds2: LocalDS_1 -f0: F0 -switch1: switch1 -dvswitch1: DVS0 -# The ESXi entries in the inventory -esxi1: "{{ groups['esxi-lab'][0] }}" -esxi2: "{{ groups['esxi-lab'][1] }}" -infra: - datastores: - LocalDS_0: - type: nfs - server: 192.168.123.1 - path: /srv/esx_lab/isos - ro: true - LocalDS_1: - type: nfs - server: 192.168.123.1 - path: /srv/esx_lab/vms - ro: false - vm_list: - - DC0_C0_RP0_VM0 - - DC0_C0_RP0_VM1 diff --git a/test/integration/targets/prepare_vmware_tests/tasks/init_real_lab.yml b/test/integration/targets/prepare_vmware_tests/tasks/init_real_lab.yml new file mode 100644 index 00000000000..6a540bba12e --- /dev/null +++ b/test/integration/targets/prepare_vmware_tests/tasks/init_real_lab.yml @@ -0,0 +1,23 @@ +--- +- name: load vars + include_vars: + file: real_lab.yml + +- include_tasks: teardown.yml + +- when: setup_esxi_instance is not defined + block: + - include_tasks: setup_datacenter.yml + - include_tasks: setup_cluster.yml + - include_tasks: setup_attach_hosts.yml + when: setup_attach_host is defined + - include_tasks: setup_datastore.yml + when: setup_datastore is defined + - include_tasks: setup_virtualmachines.yml + when: setup_virtualmachines is defined + - include_tasks: setup_switch.yml + when: setup_switch is defined + - include_tasks: setup_dvswitch.yml + when: setup_dvswitch is defined + - include_tasks: setup_resource_pool.yml + when: setup_resource_pool is defined diff --git a/test/integration/targets/prepare_vmware_tests/tasks/init_vcsim.yml b/test/integration/targets/prepare_vmware_tests/tasks/init_vcsim.yml new file mode 100644 index 00000000000..a73cc8fa537 --- /dev/null +++ b/test/integration/targets/prepare_vmware_tests/tasks/init_vcsim.yml @@ -0,0 +1,36 @@ +--- +- name: load vars + include_vars: + file: vcsim.yml + +- name: kill vcsim + uri: + url: http://{{ vcsim }}:5000/killall + +- name: start vcsim (all dressed) + uri: + url: http://{{ vcsim }}:5000/spawn?cluster=1&folder=1&ds=2 + register: vcsim_instance + when: setup_esxi_instance is not defined + +- name: start vcsim (ESXi only) + uri: + url: http://{{ vcsim }}:5000/spawn?esx=1 + register: vcsim_instance + when: setup_esxi_instance is defined + +# - name: get a list of Hosts from vcsim +# uri: +# url: http://{{ vcsim }}:5000/govc_find?filter=H +# register: vcsim_host_list + +# - name: get a list of Hosts from vcsim +# uri: +# url: http://{{ vcsim }}:5000/govc_find?filter=F +# register: vcsim_host_folder +# - debug: var=vcsim_host_folder + +- set_fact: + vcenter_hostname: "{{ vcsim }}" + vcenter_username: "user" + vcenter_password: "pass" diff --git a/test/integration/targets/prepare_vmware_tests/tasks/main.yml b/test/integration/targets/prepare_vmware_tests/tasks/main.yml index fec7d2e67ec..c8d1a893129 100644 --- a/test/integration/targets/prepare_vmware_tests/tasks/main.yml +++ b/test/integration/targets/prepare_vmware_tests/tasks/main.yml @@ -1,65 +1,6 @@ --- - when: vcsim is not defined - block: - - include_tasks: teardown.yml - -- when: vcsim is not defined and setup_esxi_instance is not defined - block: - - include_tasks: setup_datacenter.yml - - include_tasks: setup_cluster.yml - - include_tasks: setup_attach_hosts.yml - when: setup_attach_host is defined - - include_tasks: setup_datastore.yml - when: setup_datastore is defined - - include_tasks: setup_virtualmachines.yml - when: setup_virtualmachines is defined - - include_tasks: setup_switch.yml - when: setup_switch is defined - - include_tasks: setup_dvswitch.yml - when: setup_dvswitch is defined - + import_tasks: init_real_lab.yml - when: vcsim is defined - block: - - - name: kill vcsim - uri: - url: http://{{ vcsim }}:5000/killall - - - name: start vcsim (all dressed) - uri: - url: http://{{ vcsim }}:5000/spawn?cluster=1&folder=1&ds=2 - register: vcsim_instance - when: setup_esxi_instance is not defined - - - name: start vcsim (ESXi only) - uri: - url: http://{{ vcsim }}:5000/spawn?esx=1 - register: vcsim_instance - when: setup_esxi_instance is defined - - - name: get a list of Hosts from vcsim - uri: - url: http://{{ vcsim }}:5000/govc_find?filter=H - register: vcsim_host_list - - - name: get a list of Hosts from vcsim - uri: - url: http://{{ vcsim }}:5000/govc_find?filter=F - register: vcsim_host_folder - - debug: var=vcsim_host_folder - - - name: add the hosts in the inventory - add_host: - hostname: '{{ item | basename }}' - groups: - - 'esxi-lab' - with_items: '{{ vcsim_host_list.json }}' - - - debug: - var: vcsim_host_list - - - set_fact: - vcenter_hostname: "{{ vcsim }}" - vcenter_username: "user" - vcenter_password: "pass" + import_tasks: init_vcsim.yml diff --git a/test/integration/targets/prepare_vmware_tests/tasks/setup_attach_hosts.yml b/test/integration/targets/prepare_vmware_tests/tasks/setup_attach_hosts.yml index 5e85803ea0f..ee428dc5850 100644 --- a/test/integration/targets/prepare_vmware_tests/tasks/setup_attach_hosts.yml +++ b/test/integration/targets/prepare_vmware_tests/tasks/setup_attach_hosts.yml @@ -6,11 +6,11 @@ datacenter_name: '{{ dc1 }}' cluster_name: '{{ ccr1 }}' esxi_hostname: '{{ item }}' - esxi_username: '{{ hostvars[item].ansible_user }}' - esxi_password: '{{ hostvars[item].ansible_password }}' + esxi_username: '{{ esxi_user }}' + esxi_password: '{{ esxi_password }}' state: present validate_certs: no - with_items: "{{ groups['esxi-lab'] }}" + with_items: "{{ esxi_hosts }}" - name: Disable the Maintenance Mode vmware_maintenancemode: @@ -20,4 +20,4 @@ password: "{{ vcenter_password }}" esxi_hostname: '{{ item }}' state: absent - with_items: "{{ groups['esxi-lab'] }}" + with_items: "{{ esxi_hosts }}" diff --git a/test/integration/targets/prepare_vmware_tests/tasks/setup_datacenter.yml b/test/integration/targets/prepare_vmware_tests/tasks/setup_datacenter.yml index a9f74e080d3..7b655160459 100644 --- a/test/integration/targets/prepare_vmware_tests/tasks/setup_datacenter.yml +++ b/test/integration/targets/prepare_vmware_tests/tasks/setup_datacenter.yml @@ -6,3 +6,14 @@ datacenter_name: '{{ dc1 }}' state: present validate_certs: no + +- name: Create a VM folder on given Datacenter + vcenter_folder: + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter: '{{ dc1 }}' + folder_name: '{{ f0 }}' + folder_type: vm + state: present + validate_certs: no diff --git a/test/integration/targets/prepare_vmware_tests/tasks/setup_datastore.yml b/test/integration/targets/prepare_vmware_tests/tasks/setup_datastore.yml index e2e0779c23a..6a04fc690cd 100644 --- a/test/integration/targets/prepare_vmware_tests/tasks/setup_datastore.yml +++ b/test/integration/targets/prepare_vmware_tests/tasks/setup_datastore.yml @@ -1,34 +1,33 @@ --- -- debug: var=datastores - name: Mount NFS (ds1) datastores to ESXi vmware_host_datastore: hostname: '{{ item }}' - username: '{{ hostvars[item].ansible_user }}' - password: '{{ hostvars[item].ansible_password }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' + esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516 datastore_name: '{{ ds1 }}' datastore_type: '{{ infra.datastores[ds1].type }}' nfs_server: '{{ infra.datastores[ds1].server }}' nfs_path: '{{ infra.datastores[ds1].path }}' nfs_ro: '{{ infra.datastores[ds2].ro }}' - esxi_hostname: '{{ item }}' state: present validate_certs: no - with_items: "{{ groups['esxi-lab'] }}" + with_items: "{{ esxi_hosts }}" - name: Mount NFS (ds2) datastores on the ESXi vmware_host_datastore: hostname: '{{ item }}' - username: '{{ hostvars[item].ansible_user }}' - password: '{{ hostvars[item].ansible_password }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' + esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516 datastore_name: '{{ ds2 }}' datastore_type: '{{ infra.datastores[ds2].type }}' nfs_server: '{{ infra.datastores[ds2].server }}' nfs_path: '{{ infra.datastores[ds2].path }}' nfs_ro: '{{ infra.datastores[ds2].ro }}' - esxi_hostname: '{{ item }}' state: present validate_certs: no - with_items: "{{ groups['esxi-lab'] }}" + with_items: "{{ esxi_hosts }}" - name: The vcenter needs a bit of time to refresh the DS list vmware_datastore_facts: @@ -36,6 +35,7 @@ hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' + cluster: '{{ ccr1 }}' register: setup_datastore_datatstore_facts failed_when: setup_datastore_datatstore_facts.datastores|length != 2 until: setup_datastore_datatstore_facts is succeeded diff --git a/test/integration/targets/prepare_vmware_tests/tasks/setup_resource_pool.yml b/test/integration/targets/prepare_vmware_tests/tasks/setup_resource_pool.yml new file mode 100644 index 00000000000..4ebd19d5387 --- /dev/null +++ b/test/integration/targets/prepare_vmware_tests/tasks/setup_resource_pool.yml @@ -0,0 +1,18 @@ +--- +- name: Add resource pool to vCenter + vmware_resource_pool: + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter: '{{ dc1 }}' + cluster: '{{ cluster_name }}' + resource_pool: DC0_C0_RP1 + mem_shares: normal + mem_limit: -1 + mem_reservation: 0 + mem_expandable_reservations: yes + cpu_shares: normal + cpu_limit: -1 + cpu_reservation: 0 + cpu_expandable_reservations: yes + state: present diff --git a/test/integration/targets/prepare_vmware_tests/tasks/setup_switch.yml b/test/integration/targets/prepare_vmware_tests/tasks/setup_switch.yml index 8a86aaff258..a7b640ef2a3 100644 --- a/test/integration/targets/prepare_vmware_tests/tasks/setup_switch.yml +++ b/test/integration/targets/prepare_vmware_tests/tasks/setup_switch.yml @@ -2,9 +2,10 @@ - name: Add a VMware vSwitchs vmware_vswitch: validate_certs: no - hostname: '{{ hostvars[item].ansible_host }}' - username: '{{ hostvars[item].ansible_user }}' - password: '{{ hostvars[item].ansible_password }}' + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + esxi_hostname: '{{ item }}' switch_name: "{{ switch1 }}" state: present - with_items: "{{ groups['esxi-lab'] }}" + with_items: "{{ esxi_hosts }}" diff --git a/test/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml b/test/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml index 763701aa4d9..dd76e428184 100644 --- a/test/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml +++ b/test/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml @@ -1,15 +1,4 @@ --- -- name: Create a VM folder on given Datacenter - vcenter_folder: - hostname: '{{ vcenter_hostname }}' - username: '{{ vcenter_username }}' - password: '{{ vcenter_password }}' - datacenter: '{{ dc1 }}' - folder_name: '{{ f0 }}' - folder_type: vm - state: present - validate_certs: no - - name: Create VMs vmware_guest: hostname: "{{ vcenter_hostname }}" @@ -17,9 +6,8 @@ password: "{{ vcenter_password }}" datacenter: "{{ dc1 }}" validate_certs: no - folder: '{{ f0 }}' - cluster: '{{ ccr1 }}' - name: '{{ item }}' + folder: '{{ item.folder }}' + name: '{{ item.name }}' state: poweredon guest_id: debian8_64Guest disk: @@ -35,4 +23,32 @@ iso_path: "[{{ ds1 }}] Fedora-Workstation-Live-x86_64-29-1.2.iso" networks: - name: VM Network - with_items: '{{ infra.vm_list }}' + with_items: '{{ virtual_machines }}' + + +- name: Create VMs in cluster + vmware_guest: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ dc1 }}" + validate_certs: no + folder: '{{ item.folder }}' + cluster: '{{ item.cluster }}' + name: '{{ item.name }}' + state: poweredon + guest_id: debian8_64Guest + disk: + - size_gb: 1 + type: thin + datastore: '{{ ds2 }}' + hardware: + memory_mb: 128 + num_cpus: 1 + scsi: paravirtual + cdrom: + type: iso + iso_path: "[{{ ds1 }}] Fedora-Workstation-Live-x86_64-29-1.2.iso" + networks: + - name: VM Network + with_items: '{{ virtual_machines_in_cluster }}' diff --git a/test/integration/targets/prepare_vmware_tests/tasks/teardown.yml b/test/integration/targets/prepare_vmware_tests/tasks/teardown.yml index 2419a019012..0188d8f9eeb 100644 --- a/test/integration/targets/prepare_vmware_tests/tasks/teardown.yml +++ b/test/integration/targets/prepare_vmware_tests/tasks/teardown.yml @@ -1,15 +1,15 @@ --- -- name: Remove "{{ vm_name }}" +- name: Remove VM vmware_guest: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no cluster: "{{ ccr1 }}" - name: "{{ item }}" + name: "{{ item.name }}" force: yes state: absent - with_items: '{{ infra.vm_list }}' + with_items: '{{ virtual_machines + virtual_machines_in_cluster }}' ignore_errors: yes - name: Remove the DVSwitch @@ -27,11 +27,12 @@ vmware_vswitch: validate_certs: no hostname: '{{ item }}' - username: '{{ hostvars[item].ansible_user }}' - password: '{{ hostvars[item].ansible_password }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' switch_name: "{{ switch1 }}" state: absent - with_items: "{{ groups['esxi-lab'] }}" + with_items: "{{ esxi_hosts }}" + ignore_errors: yes - name: Remove ESXi Hosts to vCenter vmware_host: @@ -41,69 +42,34 @@ datacenter_name: '{{ dc1 }}' cluster_name: ccr1 esxi_hostname: '{{ item }}' - esxi_username: '{{ hostvars[item].ansible_user }}' - esxi_password: '{{ hostvars[item].ansible_password }}' + esxi_username: '{{ esxi_user }}' + esxi_password: '{{ esxi_password }}' state: absent validate_certs: no - with_items: "{{ groups['esxi-lab'] }}" + with_items: "{{ esxi_hosts }}" ignore_errors: yes -- name: Manually umount the datastores - # Work around to avoid an error from vmware_host_datastore saying - # the FS is still in use - shell: > - esxcli storage nfs remove -v nfs_ro; - esxcli storage nfs remove -v nfs_rw - with_items: "{{ groups['esxi-lab'] }}" - delegate_to: '{{ item }}' - ignore_errors: true - - name: Umount NFS datastores to ESXi (1/2) vmware_host_datastore: hostname: '{{ item }}' - username: '{{ hostvars[item].ansible_user }}' - password: '{{ hostvars[item].ansible_password }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' + esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516 datastore_name: '{{ ds1 }}' - esxi_hostname: '{{ item }}' state: absent validate_certs: no - with_items: "{{ groups['esxi-lab'] }}" - register: teardown_umount_nfs - until: teardown_umount_nfs is succeeded - retries: 15 - delay: 1 - ignore_errors: true + with_items: "{{ esxi_hosts }}" - name: Umount NFS datastores to ESXi (2/2) vmware_host_datastore: hostname: '{{ item }}' - username: '{{ hostvars[item].ansible_user }}' - password: '{{ hostvars[item].ansible_password }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' + esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516 datastore_name: '{{ ds2 }}' - esxi_hostname: '{{ item }}' state: absent validate_certs: no - with_items: "{{ groups['esxi-lab'] }}" - register: teardown_umount_nfs - until: teardown_umount_nfs is succeeded - retries: 15 - delay: 1 - ignore_errors: true - -# - name: get a final list of the datastore -# vmware_datastore_facts: -# validate_certs: False -# hostname: '{{ item }}' -# username: '{{ hostvars[item].ansible_user }}' -# password: '{{ hostvars[item].ansible_password }}' -# register: datastore_facts -# with_items: "{{ groups['esxi-lab'] }}" - -# - name: Ensure nothing is mounted -# fail: -# msg: "Some datastore are still mounted!" -# when: "item.datastores|length > 0" -# with_items: "{{ datastore_facts.results }}" + with_items: "{{ esxi_hosts }}" - name: Remove the datacenter vmware_datacenter: diff --git a/test/integration/targets/prepare_vmware_tests/vars/real_lab.yml b/test/integration/targets/prepare_vmware_tests/vars/real_lab.yml new file mode 100644 index 00000000000..2acef3050e2 --- /dev/null +++ b/test/integration/targets/prepare_vmware_tests/vars/real_lab.yml @@ -0,0 +1,40 @@ +--- +dc1: DC0 +ccr1: DC0_C0 +ds1: LocalDS_0 +ds2: LocalDS_1 +f0: F0 +switch1: switch1 +dvswitch1: DVS0 +# The ESXi entries in the inventory +esxi_hosts: + - esxi-67-1.lab + - esxi-67-2.lab +esxi_user: root +esxi_password: "!234AaAa56" +esxi1: "{{ esxi_hosts[0] }}" +esxi2: "{{ esxi_hosts[1] }}" +infra: + datastores: + LocalDS_0: + type: nfs + server: 192.168.123.1 + path: /srv/esx_lab/isos + ro: true + LocalDS_1: + type: nfs + server: 192.168.123.1 + path: /srv/esx_lab/vms + ro: false +virtual_machines: + - name: DC0_H0_VM0 + folder: '{{ f0 }}' + - name: DC0_H0_VM1 + folder: '{{ f0 }}' +virtual_machines_in_cluster: + - name: DC0_C0_RP0_VM0 + folder: '{{ f0 }}' + cluster: '{{ ccr1 }}' + - name: DC0_C0_RP0_VM1 + folder: '{{ f0 }}' + cluster: '{{ ccr1 }}' diff --git a/test/integration/targets/prepare_vmware_tests/vars/vcsim.yml b/test/integration/targets/prepare_vmware_tests/vars/vcsim.yml new file mode 100644 index 00000000000..a3cd23e365c --- /dev/null +++ b/test/integration/targets/prepare_vmware_tests/vars/vcsim.yml @@ -0,0 +1,25 @@ +--- +dc1: DC0 +ccr1: DC0_C0 +ds1: LocalDS_0 +ds2: LocalDS_1 +f0: F0 +esxi_hosts: + - DC0_C0_H0 + - DC0_C0_H1 + - DC0_C0_H2 +esxi1: '{{ esxi_hosts[0] }}' +esxi2: '{{ esxi_hosts[1] }}' +esxi3: '{{ esxi_hosts[2] }}' +switch1: switch1 +dvswitch1: DVS0 +virtual_machines: + - name: DC0_H0_VM0 + folder: /F0/DC0/vm/F0 + - name: DC0_H0_VM1 + folder: /F0/DC0/vm/F0 +virtual_machines_in_cluster: + - name: DC0_C0_RP0_VM0 + cluster: '{{ ccr1 }}' + - name: DC0_C0_RP0_VM1 + cluster: '{{ ccr1 }}' diff --git a/test/integration/targets/vmware_datastore_facts/tasks/main.yml b/test/integration/targets/vmware_datastore_facts/tasks/main.yml index 76282102749..eacaa1a25d0 100644 --- a/test/integration/targets/vmware_datastore_facts/tasks/main.yml +++ b/test/integration/targets/vmware_datastore_facts/tasks/main.yml @@ -3,20 +3,6 @@ # Copyright (c) 2018, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# Testcase 0001: Get a full list of datastores in a datacenter -# - name: get list of facts about datastores -# vmware_datastore_facts: -# validate_certs: False -# hostname: "{{ vcenter_hostname }}" -# username: "{{ vcenter_username }}" -# password: "{{ vcenter_password }}" -# datacenter: "{{ dc1 }}" -# register: datastore_facts_0001 - -# - assert: -# that: -# - "datastore_facts_0001.datastores|length == 0" - - import_role: name: prepare_vmware_tests @@ -29,11 +15,11 @@ - name: get list of facts about datastores from the ESXi vmware_datastore_facts: validate_certs: False - hostname: '{{ hostvars[item].ansible_host }}' - username: '{{ hostvars[item].ansible_user }}' - password: '{{ hostvars[item].ansible_password }}' + hostname: '{{ item }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' register: facts_from_esxi - with_items: "{{ groups['esxi-lab'] }}" + with_items: "{{ esxi_hosts }}" - assert: that: - "facts_from_esxi.results[0].datastores|length == 2" @@ -48,7 +34,6 @@ gather_nfs_mount_info: true register: facts_from_vcenter_with_dc_filter -# Depends-On: https://github.com/ansible/ansible/pull/54879 - when: vcsim is not defined block: - name: get list of facts about datastores diff --git a/test/integration/targets/vmware_drs_group/tasks/main.yml b/test/integration/targets/vmware_drs_group/tasks/main.yml index 7dec87f23be..071f9c0719d 100644 --- a/test/integration/targets/vmware_drs_group/tasks/main.yml +++ b/test/integration/targets/vmware_drs_group/tasks/main.yml @@ -19,9 +19,7 @@ cluster_name: '{{ ccr1 }}' datacenter_name: '{{ dc1 }}' group_name: TEST_VM_01 - vms: - - DC0_C0_RP0_VM0 - - DC0_C0_RP0_VM1 + vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}" state: present register: drs_vm_group_01_results @@ -32,7 +30,7 @@ that: - "drs_vm_group_01_results.changed" -- when: vcsim is defined or groups['esxi-lab'] | length >= 3 +- when: vcsim is defined or esxi_hosts | length >= 3 block: - name: Create DRS Host group vmware_drs_group: @@ -43,7 +41,7 @@ cluster_name: '{{ ccr1 }}' datacenter_name: '{{ dc1 }}' group_name: TEST_HOST_01 - hosts: "{{ groups['esxi-lab'][0:3] }}" + hosts: "{{ esxi_hosts[0:3] }}" state: present register: drs_host_group_01_results diff --git a/test/integration/targets/vmware_drs_group_facts/tasks/main.yml b/test/integration/targets/vmware_drs_group_facts/tasks/main.yml index 50dcebb7abf..d941a2a5be1 100644 --- a/test/integration/targets/vmware_drs_group_facts/tasks/main.yml +++ b/test/integration/targets/vmware_drs_group_facts/tasks/main.yml @@ -5,7 +5,7 @@ - import_role: name: prepare_vmware_tests -- when: vcsim is defined or groups['esxi-lab'] | length >= 3 +- when: vcsim is defined or esxi_hosts | length >= 3 block: - name: Gather DRS group facts from given cluster vmware_drs_group_facts: diff --git a/test/integration/targets/vmware_drs_rule_facts/tasks/main.yml b/test/integration/targets/vmware_drs_rule_facts/tasks/main.yml index e431d2f35a6..825fc6ea4d5 100644 --- a/test/integration/targets/vmware_drs_rule_facts/tasks/main.yml +++ b/test/integration/targets/vmware_drs_rule_facts/tasks/main.yml @@ -2,7 +2,10 @@ # Copyright: (c) 2018, Abhijeet Kasurde # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -- when: vcsim is defined or groups['esxi-lab'] | length >= 3 +- import_role: + name: prepare_vmware_tests + +- when: vcsim is defined or esxi_hosts | length >= 3 block: - import_role: name: prepare_vmware_tests diff --git a/test/integration/targets/vmware_dvs_portgroup_facts/tasks/main.yml b/test/integration/targets/vmware_dvs_portgroup_facts/tasks/main.yml index 9a450712bd7..4144bd7801a 100644 --- a/test/integration/targets/vmware_dvs_portgroup_facts/tasks/main.yml +++ b/test/integration/targets/vmware_dvs_portgroup_facts/tasks/main.yml @@ -2,6 +2,9 @@ # Copyright: (c) 2018, Abhijeet Kasurde # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +- import_role: + name: prepare_vmware_tests + - when: vcsim is not defined block: - &dvs_facts diff --git a/test/integration/targets/vmware_dvswitch/tasks/main.yml b/test/integration/targets/vmware_dvswitch/tasks/main.yml index c9fec84a647..9669922be30 100644 --- a/test/integration/targets/vmware_dvswitch/tasks/main.yml +++ b/test/integration/targets/vmware_dvswitch/tasks/main.yml @@ -4,6 +4,8 @@ - import_role: name: prepare_vmware_tests + vars: + setup_datacenter: true - &dvs_data name: Add distributed vSwitch @@ -26,13 +28,26 @@ that: - dvs_result_0001.changed +- name: Create a VM folder on given Datacenter + vcenter_folder: + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter: '{{ dc1 }}' + folder_name: network_folder + folder_type: network + state: present + validate_certs: no + register: + network_folder_result + - name: Add distributed vSwitch using folder vmware_dvswitch: validate_certs: False hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - folder: "/F0/{{ dc1 }}/network/F0" + folder: "{{ network_folder_result.result.path }}" state: present switch_name: dvswitch_0002 mtu: 9000 diff --git a/test/integration/targets/vmware_dvswitch_pvlans/tasks/main.yml b/test/integration/targets/vmware_dvswitch_pvlans/tasks/main.yml index 2628c2e136c..093598e4517 100644 --- a/test/integration/targets/vmware_dvswitch_pvlans/tasks/main.yml +++ b/test/integration/targets/vmware_dvswitch_pvlans/tasks/main.yml @@ -60,15 +60,15 @@ that: - pvlans_result is changed -- <<: *pv_data - name: Configure PVLANs in check mode - register: pvlans_result_check_mode - check_mode: yes - -- debug: - var: pvlans_result_check_mode - -- name: ensure pvlans were configured - assert: - that: - - pvlans_result_check_mode is changed +- when: vcsim is not defined + block: + - <<: *pv_data + name: Configure PVLANs in check mode + register: pvlans_result_check_mode + check_mode: yes + - debug: + var: pvlans_result_check_mode + - name: ensure pvlans were not changed + assert: + that: + - not (pvlans_result_check_mode is changed) diff --git a/test/integration/targets/vmware_dvswitch_uplink_pg/tasks/main.yml b/test/integration/targets/vmware_dvswitch_uplink_pg/tasks/main.yml index 1258c8bacc5..4ca85fdd119 100644 --- a/test/integration/targets/vmware_dvswitch_uplink_pg/tasks/main.yml +++ b/test/integration/targets/vmware_dvswitch_uplink_pg/tasks/main.yml @@ -63,6 +63,7 @@ - <<: *uplink_data name: Configure Uplink portgroup + register: uplink_pg_result check_mode: no - debug: diff --git a/test/integration/targets/vmware_guest/tasks/boot_firmware_d1_c1_f0.yml b/test/integration/targets/vmware_guest/tasks/boot_firmware_d1_c1_f0.yml index e35e3174907..3c182c80572 100644 --- a/test/integration/targets/vmware_guest/tasks/boot_firmware_d1_c1_f0.yml +++ b/test/integration/targets/vmware_guest/tasks/boot_firmware_d1_c1_f0.yml @@ -8,9 +8,9 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ 'newvm_' + item|basename }}" + name: "{{ 'newvm_' + item.name }}" guest_id: centos64Guest - datacenter: "{{ (item|basename).split('_')[0] }}" + datacenter: "{{ dc1 }}" hardware: num_cpus: 4 boot_firmware: "bios" @@ -20,8 +20,8 @@ type: thin autoselect_datastore: True state: poweredoff - folder: "{{ item|dirname }}" - with_items: "{{ vmlist['json'] }}" + folder: "{{ item.folder }}" + with_items: "{{ virtual_machines }}" register: clone_d1_c1_f0 - debug: var=clone_d1_c1_f0 @@ -32,34 +32,34 @@ - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" # VCSIM does not recognizes existing VMs boot firmware -#- name: create new VMs again with boot_firmware as 'bios' -# vmware_guest: -# validate_certs: False -# hostname: "{{ vcenter_hostname }}" -# username: "{{ vcenter_username }}" -# password: "{{ vcenter_password }}" -# name: "{{ 'newvm_' + item|basename }}" -# guest_id: centos64Guest -# datacenter: "{{ (item|basename).split('_')[0] }}" -# hardware: -# num_cpus: 4 -# boot_firmware: "bios" -# memory_mb: 512 -# disk: -# - size: 1gb -# type: thin -# autoselect_datastore: True -# state: poweredoff -# folder: "{{ item|dirname }}" -# with_items: "{{ vmlist['json'] }}" -# register: clone_d1_c1_f0 - -#- debug: var=clone_d1_c1_f0 - -#- name: assert that changes were not made -# assert: -# that: -# - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]" +- when: vcsim is not defined + block: + - name: create new VMs again with boot_firmware as 'bios' + vmware_guest: + validate_certs: False + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ 'newvm_' + item.name }}" + guest_id: centos64Guest + datacenter: "{{ dc1 }}" + hardware: + num_cpus: 4 + boot_firmware: "bios" + memory_mb: 512 + disk: + - size: 1gb + type: thin + autoselect_datastore: True + state: poweredoff + folder: "{{ item.folder }}" + with_items: "{{ virtual_machines }}" + register: clone_d1_c1_f0 + - debug: var=clone_d1_c1_f0 + - name: assert that changes were not made + assert: + that: + - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]" - name: create new VMs with boot_firmware as 'efi' vmware_guest: @@ -67,9 +67,9 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ 'newvm_efi_' + item|basename }}" + name: "{{ 'newvm_efi_' + item.name }}" guest_id: centos64Guest - datacenter: "{{ (item|basename).split('_')[0] }}" + datacenter: "{{ dc1 }}" hardware: num_cpus: 4 boot_firmware: "efi" @@ -79,8 +79,8 @@ type: thin autoselect_datastore: True state: poweredoff - folder: "{{ item|dirname }}" - with_items: "{{ vmlist['json'] }}" + folder: "{{ item.folder }}" + with_items: "{{ virtual_machines }}" register: clone_d1_c1_f0 - debug: var=clone_d1_c1_f0 @@ -91,31 +91,31 @@ - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" # VCSIM does not recognizes existing VMs boot firmware -#- name: create new VMs again with boot_firmware as 'efi' -# vmware_guest: -# validate_certs: False -# hostname: "{{ vcenter_hostname }}" -# username: "{{ vcenter_username }}" -# password: "{{ vcenter_password }}" -# name: "{{ 'newvm_efi_' + item|basename }}" -# guest_id: centos64Guest -# datacenter: "{{ (item|basename).split('_')[0] }}" -# hardware: -# num_cpus: 4 -# boot_firmware: "efi" -# memory_mb: 512 -# disk: -# - size: 1gb -# type: thin -# autoselect_datastore: True -# state: poweredoff -# folder: "{{ item|dirname }}" -# with_items: "{{ vmlist['json'] }}" -# register: clone_d1_c1_f0 - -#- debug: var=clone_d1_c1_f0 - -#- name: assert that changes were not made -# assert: -# that: -# - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]" +- when: vcsim is not defined + block: + - name: create new VMs again with boot_firmware as 'efi' + vmware_guest: + validate_certs: False + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ 'newvm_efi_' + item.name }}" + guest_id: centos64Guest + datacenter: "{{ dc1 }}" + hardware: + num_cpus: 4 + boot_firmware: "efi" + memory_mb: 512 + disk: + - size: 1gb + type: thin + autoselect_datastore: True + state: poweredoff + folder: "{{ item.folder }}" + with_items: "{{ virtual_machines }}" + register: clone_d1_c1_f0 + - debug: var=clone_d1_c1_f0 + - name: assert that changes were not made + assert: + that: + - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]" diff --git a/test/integration/targets/vmware_guest/tasks/check_mode.yml b/test/integration/targets/vmware_guest/tasks/check_mode.yml index 95e7a297da1..d3f6f226349 100644 --- a/test/integration/targets/vmware_guest/tasks/check_mode.yml +++ b/test/integration/targets/vmware_guest/tasks/check_mode.yml @@ -8,7 +8,7 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" datacenter: "{{ dc1 }}" state: "{{ item }}" with_items: @@ -30,7 +30,7 @@ assert: that: - "check_mode_state.results|map(attribute='changed')|unique|list == [true]" - - "check_mode_state.results|map(attribute='vm_name')|unique|list == [ infra.vm_list[0] ]" + - "check_mode_state.results|map(attribute='vm_name')|unique|list == [ virtual_machines[0].name ]" - name: Perform all operation on non-existent VM in check mode vmware_guest: diff --git a/test/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml b/test/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml index 3fcc1a767de..2da1f5770ff 100644 --- a/test/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml +++ b/test/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml @@ -2,51 +2,19 @@ # Copyright: (c) 2019, Pavan Bidkar # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -- name: Wait for Flask controller to come up online - wait_for: - host: "{{ vcsim }}" - port: 5000 - state: started - -- name: kill vcsim - uri: - url: http://{{ vcsim }}:5000/killall - -- name: start vcsim with no folders - uri: - url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0 - register: vcsim_instance - -- name: Wait for Flask controller to come up online - wait_for: - host: "{{ vcsim }}" - port: 443 - state: started - -- name: get a list of VMS from vcsim - uri: - url: http://{{ vcsim }}:5000/govc_find?filter=VM - register: vmlist - -- debug: - var: vcsim_instance - -- debug: - var: vmlist - - name: clone vm from template and customize GOS vmware_guest: validate_certs: False - hostname: "{{ vcsim }}" - username: "{{ vcsim_instance['json']['username'] }}" - password: "{{ vcsim_instance['json']['password'] }}" - name: "{{ 'net_customize_' + item|basename }}" - template: "{{ item|basename }}" - datacenter: "{{ (item|basename).split('_')[0] }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ 'net_customize_' + item.name }}" + template: "{{ item.name }}" + datacenter: "{{ dc1 }}" state: poweredoff - folder: "{{ item|dirname }}" + folder: "{{ item.folder }}" convert: thin - with_items: "{{ vmlist['json'] }}" + with_items: "{{ virtual_machines }}" register: clone_customize - debug: @@ -60,16 +28,16 @@ - name: clone vm from template and customize GOS again vmware_guest: validate_certs: False - hostname: "{{ vcsim }}" - username: "{{ vcsim_instance['json']['username'] }}" - password: "{{ vcsim_instance['json']['password'] }}" - name: "{{ 'net_customize_' + item|basename }}" - template: "{{ item|basename }}" - datacenter: "{{ (item|basename).split('_')[0] }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ 'net_customize_' + item.name }}" + template: "{{ item.name }}" + datacenter: "{{ dc1 }}" state: poweredoff - folder: "{{ item|dirname }}" + folder: "{{ item.folder }}" convert: thin - with_items: "{{ vmlist['json'] }}" + with_items: "{{ virtual_machines }}" register: clone_customize_again - debug: diff --git a/test/integration/targets/vmware_guest/tasks/clone_with_convert.yml b/test/integration/targets/vmware_guest/tasks/clone_with_convert.yml index 4cce2c72e93..a8e4e8a3271 100644 --- a/test/integration/targets/vmware_guest/tasks/clone_with_convert.yml +++ b/test/integration/targets/vmware_guest/tasks/clone_with_convert.yml @@ -8,13 +8,13 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ 'thin_' + item|basename }}" - template: "{{ item|basename }}" - datacenter: "{{ (item|basename).split('_')[0] }}" + name: "{{ 'thin_' + item.name }}" + template: "{{ item.name }}" + datacenter: "{{ dc1 }}" state: poweredoff - folder: "{{ item|dirname }}" + folder: "{{ item.folder }}" convert: thin - with_items: "{{ vmlist['json'] }}" + with_items: "{{ virtual_machines }}" register: clone_thin - debug: var=clone_thin @@ -30,13 +30,13 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ 'thick_' + item|basename }}" - template: "{{ item|basename }}" - datacenter: "{{ (item|basename).split('_')[0] }}" + name: "{{ 'thick_' + item.name }}" + template: "{{ item.name }}" + datacenter: "{{ dc1 }}" state: poweredoff - folder: "{{ item|dirname }}" + folder: "{{ item.folder }}" convert: thick - with_items: "{{ vmlist['json'] }}" + with_items: "{{ virtual_machines }}" register: clone_thick - debug: var=clone_thick @@ -52,13 +52,13 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ 'eagerzeroedthick_' + item|basename }}" - template: "{{ item|basename }}" - datacenter: "{{ (item|basename).split('_')[0] }}" + name: "{{ 'eagerzeroedthick_' + item.name }}" + template: "{{ item.name }}" + datacenter: "{{ dc1 }}" state: poweredoff - folder: "{{ item|dirname }}" + folder: "{{ item.folder }}" convert: eagerzeroedthick - with_items: "{{ vmlist['json'] }}" + with_items: "{{ virtual_machines }}" register: clone_eagerzeroedthick - debug: var=clone_eagerzeroedthick diff --git a/test/integration/targets/vmware_guest/tasks/disk_mode_d1_c1_f0.yml b/test/integration/targets/vmware_guest/tasks/disk_mode_d1_c1_f0.yml index 244e9cabe79..0f4aea21d11 100644 --- a/test/integration/targets/vmware_guest/tasks/disk_mode_d1_c1_f0.yml +++ b/test/integration/targets/vmware_guest/tasks/disk_mode_d1_c1_f0.yml @@ -70,7 +70,7 @@ password: "{{ vcenter_password }}" name: disk_mode_d1_c1_f0 guest_id: centos64Guest - datacenter: "{{ (item|basename).split('_')[0] }}" + datacenter: "{{ dc1 }}" hardware: num_cpus: 1 memory_mb: 512 diff --git a/test/integration/targets/vmware_guest/tasks/linked_clone_d1_c1_f0.yml b/test/integration/targets/vmware_guest/tasks/linked_clone_d1_c1_f0.yml index 8985f76a8ae..702ca59da7e 100644 --- a/test/integration/targets/vmware_guest/tasks/linked_clone_d1_c1_f0.yml +++ b/test/integration/targets/vmware_guest/tasks/linked_clone_d1_c1_f0.yml @@ -2,47 +2,19 @@ # Copyright: (c) 2018, Abhijeet Kasurde # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -- name: Wait for Flask controller to come up online - wait_for: - host: "{{ vcsim }}" - port: 5000 - state: started - -- name: kill vcsim - uri: - url: http://{{ vcsim }}:5000/killall -- name: start vcsim with no folders - uri: - url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0 - register: vcsim_instance - -- name: Wait for Flask controller to come up online - wait_for: - host: "{{ vcsim }}" - port: 443 - state: started - -- name: get a list of VMS from vcsim - uri: - url: http://{{ vcsim }}:5000/govc_find?filter=VM - register: vmlist - -- debug: var=vcsim_instance -- debug: var=vmlist - - name: create new linked clone without specifying snapshot_src vmware_guest: validate_certs: False - hostname: "{{ vcsim }}" - username: "{{ vcsim_instance['json']['username'] }}" - password: "{{ vcsim_instance['json']['password'] }}" - name: "{{ 'new_vm_' + item|basename }}" - template: "{{ item|basename }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ 'new_vm_' + item.name }}" + template: "{{ item.name }}" guest_id: centos64Guest - datacenter: "{{ (item|basename).split('_')[0] }}" - folder: "{{ item|dirname }}" + datacenter: "{{ dc1 }}" + folder: "{{ f0 }}" linked_clone: True - with_items: "{{ vmlist['json'] }}" + with_items: "{{ virtual_machines }}" register: linked_clone_d1_c1_f0 ignore_errors: True @@ -56,16 +28,15 @@ - name: create new linked clone without specifying linked_clone vmware_guest: validate_certs: False - hostname: "{{ vcsim }}" - username: "{{ vcsim_instance['json']['username'] }}" - password: "{{ vcsim_instance['json']['password'] }}" - name: "{{ 'new_vm_' + item|basename }}" - template: "{{ item|basename }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ 'new_vm_' + item.name }}" guest_id: centos64Guest - datacenter: "{{ (item|basename).split('_')[0] }}" - folder: "{{ item|dirname }}" + datacenter: "{{ dc1 }}" + folder: "{{ f0 }}" snapshot_src: "snap_shot1" - with_items: "{{ vmlist['json'] }}" + with_items: "{{ virtual_machines }}" register: linked_clone_d1_c1_f0 ignore_errors: True @@ -126,4 +97,4 @@ #- name: assert that changes were not made # assert: # that: -# - "linked_clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]" \ No newline at end of file +# - "linked_clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]" diff --git a/test/integration/targets/vmware_guest/tasks/main.yml b/test/integration/targets/vmware_guest/tasks/main.yml index 23da98de591..71cc3326921 100644 --- a/test/integration/targets/vmware_guest/tasks/main.yml +++ b/test/integration/targets/vmware_guest/tasks/main.yml @@ -5,24 +5,44 @@ - import_role: name: prepare_vmware_tests vars: + setup_datacenter: true setup_attach_host: true setup_datastore: true setup_virtualmachines: true + setup_resource_pool: true - -- include: poweroff_d1_c1_f0.yml -- include: poweroff_d1_c1_f1.yml -- include: check_mode.yml -- include: clone_d1_c1_f0.yml -- include: create_d1_c1_f0.yml -- include: cdrom_d1_c1_f0.yml -- include: create_rp_d1_c1_f0.yml -- include: create_guest_invalid_d1_c1_f0.yml -- include: mac_address_d1_c1_f0.yml -- include: disk_type_d1_c1_f0.yml -- include: create_nw_d1_c1_f0.yml -- include: delete_vm.yml -- include: non_existent_vm_ops.yml +- block: + - include: poweroff_d1_c1_f0.yml + - include: poweroff_d1_c1_f1.yml + - include: check_mode.yml + - include: clone_d1_c1_f0.yml + - include: create_d1_c1_f0.yml + - include: cdrom_d1_c1_f0.yml + - include: create_rp_d1_c1_f0.yml + - include: create_guest_invalid_d1_c1_f0.yml + - include: mac_address_d1_c1_f0.yml + - include: disk_type_d1_c1_f0.yml + - include: create_nw_d1_c1_f0.yml + - include: delete_vm.yml + - include: non_existent_vm_ops.yml + always: + - name: Remove VM + vmware_guest: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: no + cluster: "{{ ccr1 }}" + name: '{{ item }}' + force: yes + state: absent + with_items: + - CDROM-Test + - CDROM-Test-38679 + - newvm_2 + - newvm_3 + - newvmnw_4 + - DC0_H0_VM12 - import_role: name: prepare_vmware_tests @@ -31,17 +51,66 @@ setup_datastore: true setup_virtualmachines: true -- include: network_negative_test.yml -# VCSIM does not return list of portgroups for dvswitch so commenting following TC -#- include: network_with_portgroup.yml -# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test -# - include: network_with_dvpg.yml -#- include: template_d1_c1_f0.yml -- include: vapp_d1_c1_f0.yml -- include: disk_size_d1_c1_f0.yml -- include: network_with_device.yml -- include: disk_mode_d1_c1_f0.yml -- include: linked_clone_d1_c1_f0.yml -- include: boot_firmware_d1_c1_f0.yml -- include: clone_with_convert.yml -- include: clone_customize_guest_test.yml +- block: + - include: network_negative_test.yml + # VCSIM does not return list of portgroups for dvswitch so commenting following TC + #- include: network_with_portgroup.yml + # Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test + # - include: network_with_dvpg.yml + #- include: template_d1_c1_f0.yml + - include: vapp_d1_c1_f0.yml + - include: disk_size_d1_c1_f0.yml + - include: network_with_device.yml + - include: disk_mode_d1_c1_f0.yml + - include: linked_clone_d1_c1_f0.yml + always: + - name: Remove VM + vmware_guest: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: no + cluster: "{{ ccr1 }}" + name: '{{ item }}' + force: yes + state: absent + with_items: + - disk_mode_d1_c1_f0 + - network_with_device + - new_vm_no_nw_type + - vApp-Test + +- import_role: + name: prepare_vmware_tests + vars: + setup_attach_host: true + setup_datastore: true + setup_virtualmachines: true +- block: + - include: boot_firmware_d1_c1_f0.yml + - include: clone_with_convert.yml + - include: clone_customize_guest_test.yml + always: + - name: Remove VM + vmware_guest: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: no + cluster: "{{ ccr1 }}" + name: '{{ item }}' + force: yes + state: absent + with_items: + - newvm_DC0_H0_VM0 + - newvm_DC0_H0_VM1 + - newvm_efi_DC0_H0_VM0 + - newvm_efi_DC0_H0_VM1 + - thin_DC0_H0_VM0 + - thin_DC0_H0_VM1 + - thick_DC0_H0_VM0 + - thick_DC0_H0_VM1 + - eagerzeroedthick_DC0_H0_VM0 + - eagerzeroedthick_DC0_H0_VM1 + - net_customize_DC0_H0_VM0 + - net_customize_DC0_H0_VM1 diff --git a/test/integration/targets/vmware_guest/tasks/poweroff_d1_c1_f0.yml b/test/integration/targets/vmware_guest/tasks/poweroff_d1_c1_f0.yml index 2a503ad2098..14e724ab444 100644 --- a/test/integration/targets/vmware_guest/tasks/poweroff_d1_c1_f0.yml +++ b/test/integration/targets/vmware_guest/tasks/poweroff_d1_c1_f0.yml @@ -8,9 +8,9 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ item }}" + name: "{{ item.name }}" state: poweredoff - with_items: "{{ infra.vm_list }}" + with_items: "{{ virtual_machines }}" register: poweroff_d1_c1_f0 - debug: diff --git a/test/integration/targets/vmware_guest/tasks/poweroff_d1_c1_f1.yml b/test/integration/targets/vmware_guest/tasks/poweroff_d1_c1_f1.yml index 835824c3e83..e43d6388469 100644 --- a/test/integration/targets/vmware_guest/tasks/poweroff_d1_c1_f1.yml +++ b/test/integration/targets/vmware_guest/tasks/poweroff_d1_c1_f1.yml @@ -14,10 +14,10 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ item }}" + name: "{{ item.name }}" state: poweredoff - folder: "DC1/C1/F1" - with_items: "{{ infra.vm_list }}" + folder: "{{ item.folder }}" + with_items: "{{ virtual_machines }}" register: poweroff_d1_c1_f1 - debug: var=poweroff_d1_c1_f1 diff --git a/test/integration/targets/vmware_guest_boot_facts/tasks/main.yml b/test/integration/targets/vmware_guest_boot_facts/tasks/main.yml index e4fc817a15e..a5d5cfc6456 100644 --- a/test/integration/targets/vmware_guest_boot_facts/tasks/main.yml +++ b/test/integration/targets/vmware_guest_boot_facts/tasks/main.yml @@ -17,7 +17,7 @@ hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" register: vm1_facts - debug: var=vm1_facts - name: assert that values are set @@ -36,7 +36,7 @@ hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" check_mode: yes register: vm1_facts - debug: var=vm1_facts diff --git a/test/integration/targets/vmware_guest_custom_attributes/tasks/main.yml b/test/integration/targets/vmware_guest_custom_attributes/tasks/main.yml index 8311de4b84e..de77fe718f4 100644 --- a/test/integration/targets/vmware_guest_custom_attributes/tasks/main.yml +++ b/test/integration/targets/vmware_guest_custom_attributes/tasks/main.yml @@ -17,8 +17,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - folder: "{{ f0 }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present attributes: - name: 'sample_1' @@ -42,8 +42,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - folder: "{{ f0 }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present attributes: - name: 'sample_1' @@ -67,8 +67,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - folder: "{{ f0 }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: absent attributes: - name: 'sample_1' @@ -94,8 +94,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - folder: "{{ f0 }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: absent attributes: - name: 'sample_1' diff --git a/test/integration/targets/vmware_guest_disk_facts/tasks/main.yml b/test/integration/targets/vmware_guest_disk_facts/tasks/main.yml index d1e07909372..58c65416092 100644 --- a/test/integration/targets/vmware_guest_disk_facts/tasks/main.yml +++ b/test/integration/targets/vmware_guest_disk_facts/tasks/main.yml @@ -16,7 +16,7 @@ hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" datacenter: '{{ dc1 }}' register: disk_facts diff --git a/test/integration/targets/vmware_guest_facts/tasks/main.yml b/test/integration/targets/vmware_guest_facts/tasks/main.yml index 8ae1a9291a9..13dc8ba50ab 100644 --- a/test/integration/targets/vmware_guest_facts/tasks/main.yml +++ b/test/integration/targets/vmware_guest_facts/tasks/main.yml @@ -18,8 +18,8 @@ username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - folder: "{{ f0 }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" register: guest_facts_0001 - debug: @@ -27,7 +27,7 @@ - assert: that: - - "guest_facts_0001['instance']['hw_name'] == infra.vm_list[0]" + - "guest_facts_0001['instance']['hw_name'] == virtual_machines[0].name" - "guest_facts_0001['instance']['hw_product_uuid'] is defined" - "guest_facts_0001['instance']['hw_cores_per_socket'] is defined" - "guest_facts_0001['instance']['hw_datastores'] is defined" @@ -86,7 +86,7 @@ - assert: that: - - "guest_facts_0002['instance']['hw_name'] == infra.vm_list[0]" + - "guest_facts_0002['instance']['hw_name'] == virtual_machines[0].name" - "guest_facts_0002['instance']['hw_product_uuid'] is defined" - "guest_facts_0002['instance']['hw_product_uuid'] == vm1_uuid" - "guest_facts_0002['instance']['hw_cores_per_socket'] is defined" @@ -124,8 +124,8 @@ username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - folder: "{{ f0 }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present snapshot_name: snap1 @@ -172,7 +172,7 @@ - assert: that: - - "guest_facts_0005['instance']['hw_name'] == infra.vm_list[0]" + - "guest_facts_0005['instance']['hw_name'] == virtual_machines[0].name" - "guest_facts_0005['instance']['hw_product_uuid'] is defined" - "guest_facts_0005['instance']['hw_product_uuid'] == vm1_uuid" - "guest_facts_0005['instance']['hw_cores_per_socket'] is defined" @@ -187,4 +187,4 @@ - "guest_facts_0005['instance']['instance_uuid'] is defined" - "guest_facts_0005['instance']['instance_uuid'] == vm1_instance_uuid" - "guest_facts_0001['instance']['moid'] is defined" - - "guest_facts_0001['instance']['vimref'] is defined" \ No newline at end of file + - "guest_facts_0001['instance']['vimref'] is defined" diff --git a/test/integration/targets/vmware_guest_find/tasks/main.yml b/test/integration/targets/vmware_guest_find/tasks/main.yml index e187ce20bf2..d1e635a86a5 100644 --- a/test/integration/targets/vmware_guest_find/tasks/main.yml +++ b/test/integration/targets/vmware_guest_find/tasks/main.yml @@ -14,9 +14,9 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ item }}" + name: "{{ item.name }}" datacenter: "{{ dc1 }}" - with_items: "{{ infra.vm_list }}" + with_items: "{{ virtual_machines }}" register: folders - debug: var=item @@ -38,8 +38,8 @@ username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - folder: "{{ f0 }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" register: guest_facts_0001 - debug: var=guest_facts_0001 diff --git a/test/integration/targets/vmware_guest_move/tasks/main.yml b/test/integration/targets/vmware_guest_move/tasks/main.yml index 33b94f5c2ca..424fbfab01f 100644 --- a/test/integration/targets/vmware_guest_move/tasks/main.yml +++ b/test/integration/targets/vmware_guest_move/tasks/main.yml @@ -18,6 +18,7 @@ folder_type: vm state: present validate_certs: no + register: dest_folder # Testcase 0001: Move vm and get changed status - name: Move VM (Changed) @@ -27,8 +28,9 @@ username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - dest_folder: '/F0/DC0/vm/f1' + name: "{{ virtual_machines[0].name }}" + # Depends-On: https://github.com/ansible/ansible/pull/55237 + dest_folder: "{{ dest_folder.result.path }}" register: vm_facts_0001 @@ -40,8 +42,8 @@ username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: "{{ dc1 }}" - name: "{{ infra.vm_list[0] }}" - dest_folder: 'F0/DC0/vm/f1' + name: "{{ virtual_machines[0].name }}" + dest_folder: "{{ dest_folder.result.path }}" register: vm_facts_0002 - debug: diff --git a/test/integration/targets/vmware_guest_powerstate/tasks/main.yml b/test/integration/targets/vmware_guest_powerstate/tasks/main.yml index 2ff66544087..06b865cee63 100644 --- a/test/integration/targets/vmware_guest_powerstate/tasks/main.yml +++ b/test/integration/targets/vmware_guest_powerstate/tasks/main.yml @@ -14,9 +14,9 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: powered-off - folder: '/dc1/vm/f0' register: poweroff_d1_c1_f0 - debug: var=poweroff_d1_c1_f0 diff --git a/test/integration/targets/vmware_guest_powerstate/tasks/poweroff_d1_c1_f0.yml b/test/integration/targets/vmware_guest_powerstate/tasks/poweroff_d1_c1_f0.yml index 922233090de..8a65d8b0bbf 100644 --- a/test/integration/targets/vmware_guest_powerstate/tasks/poweroff_d1_c1_f0.yml +++ b/test/integration/targets/vmware_guest_powerstate/tasks/poweroff_d1_c1_f0.yml @@ -40,7 +40,7 @@ name: "{{ item|basename }}" state: powered-off folder: "{{ item|dirname }}" - with_items: "{{ vmlist['json'] }}" + with_items: "{{ virtual_machines }}" register: poweroff_d1_c1_f0 - debug: var=poweroff_d1_c1_f0 diff --git a/test/integration/targets/vmware_guest_snapshot/tasks/main.yml b/test/integration/targets/vmware_guest_snapshot/tasks/main.yml index 83b3bd23cf6..758a91da04e 100644 --- a/test/integration/targets/vmware_guest_snapshot/tasks/main.yml +++ b/test/integration/targets/vmware_guest_snapshot/tasks/main.yml @@ -13,8 +13,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: absent snapshot_name: snap_a @@ -26,8 +26,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present snapshot_name: "snap_{{item}}" description: "snap named {{item}}" @@ -45,8 +45,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present snapshot_name: snap_a new_snapshot_name: snap_c @@ -59,8 +59,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present snapshot_name: snap_a description: "snap named a" @@ -73,8 +73,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present snapshot_name: snap_c new_description: "renamed to snap_c from snap_a" @@ -89,8 +89,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: absent snapshot_name: snap_b remove_children: True @@ -103,8 +103,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: remove_all # Test0008: Create snap_a again and revert to it @@ -115,8 +115,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present snapshot_name: snap_a description: "snap named a" @@ -130,8 +130,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: revert snapshot_name: snap_a @@ -143,8 +143,8 @@ username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" state: present snapshot_name: snap_a description: "snap named a" diff --git a/test/integration/targets/vmware_guest_snapshot_facts/tasks/main.yml b/test/integration/targets/vmware_guest_snapshot_facts/tasks/main.yml index a876d18efee..f8908675cfc 100644 --- a/test/integration/targets/vmware_guest_snapshot_facts/tasks/main.yml +++ b/test/integration/targets/vmware_guest_snapshot_facts/tasks/main.yml @@ -17,8 +17,8 @@ username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: "{{ dc1 }}" - folder: "{{ f0 }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" register: vm_snapshot_facts - debug: var=vm_snapshot_facts diff --git a/test/integration/targets/vmware_guest_tools_wait/tasks/main.yml b/test/integration/targets/vmware_guest_tools_wait/tasks/main.yml index 063f171af8c..406521305d1 100644 --- a/test/integration/targets/vmware_guest_tools_wait/tasks/main.yml +++ b/test/integration/targets/vmware_guest_tools_wait/tasks/main.yml @@ -15,10 +15,10 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "{{ infra.vm_list[0] }}" + name: "{{ virtual_machines[0].name }}" + folder: "{{ virtual_machines[0].folder }}" datacenter: "{{ dc1 }}" state: poweredon - folder: "{{ f0 }}" # FixMe: govcsim does not support VMware tools status reporting ## Testcase 0001: Wait for VMware tools to become available by name diff --git a/test/integration/targets/vmware_host/tasks/main.yml b/test/integration/targets/vmware_host/tasks/main.yml index 093edd447ec..254c27bceef 100644 --- a/test/integration/targets/vmware_host/tasks/main.yml +++ b/test/integration/targets/vmware_host/tasks/main.yml @@ -4,6 +4,10 @@ # Testcase: Add Host - when: vcsim is not defined block: + - import_role: + name: prepare_vmware_tests + vars: + setup_attach_host: true - name: Add first ESXi Host to vCenter vmware_host: @@ -13,8 +17,8 @@ datacenter_name: '{{ dc1 }}' cluster_name: '{{ ccr1 }}' esxi_hostname: '{{ esxi1 }}' - esxi_username: '{{ hostvars[esxi1].ansible_user }}' - esxi_password: '{{ hostvars[esxi1].ansible_password }}' + esxi_username: '{{ esxi_user }}' + esxi_password: '{{ esxi_password }}' state: present validate_certs: no register: readd_host_result @@ -27,8 +31,8 @@ datacenter_name: '{{ dc1 }}' cluster_name: '{{ ccr1 }}' esxi_hostname: '{{ esxi1 }}' - esxi_username: '{{ hostvars[esxi1].ansible_user }}' - esxi_password: '{{ hostvars[esxi1].ansible_password }}' + esxi_username: '{{ esxi_user }}' + esxi_password: '{{ esxi_password }}' state: present validate_certs: no register: readd_host_result @@ -45,11 +49,10 @@ password: "{{ vcenter_password }}" validate_certs: no esxi_hostname: '{{ esxi2 }}' - esxi_username: '{{ hostvars[esxi2].ansible_user }}' - esxi_password: '{{ hostvars[esxi2].ansible_password }}' + esxi_username: '{{ esxi_user }}' + esxi_password: '{{ esxi_password }}' datacenter_name: "{{ dc1 }}" cluster_name: "{{ ccr1 }}" - fetch_ssl_thumbprint: False state: add_or_reconnect register: add_or_reconnect_host_result - name: ensure host system is present @@ -119,8 +122,8 @@ password: "{{ vcenter_password }}" validate_certs: no esxi_hostname: '{{ esxi2 }}' - esxi_username: '{{ hostvars[esxi2].ansible_user }}' - esxi_password: '{{ hostvars[esxi2].ansible_password }}' + esxi_username: '{{ esxi_user }}' + esxi_password: '{{ esxi_password }}' datacenter_name: "{{ dc1 }}" folder_name: "/{{ dc1 }}/host/Staging" state: present @@ -139,8 +142,8 @@ password: "{{ vcenter_password }}" validate_certs: no esxi_hostname: '{{ esxi2 }}' - esxi_username: '{{ hostvars[esxi2].ansible_user }}' - esxi_password: '{{ hostvars[esxi2].ansible_password }}' + esxi_username: '{{ esxi_user }}' + esxi_password: '{{ esxi_password }}' datacenter_name: "{{ dc1 }}" folder_name: "/{{ dc1 }}/host/Staging" state: present @@ -158,8 +161,8 @@ password: "{{ vcenter_password }}" validate_certs: no esxi_hostname: '{{ esxi2 }}' - esxi_username: '{{ hostvars[esxi2].ansible_user }}' - esxi_password: '{{ hostvars[esxi2].ansible_password }}' + esxi_username: '{{ esxi_user }}' + esxi_password: '{{ esxi_password }}' datacenter_name: "{{ dc1 }}" cluster_name: "{{ ccr1 }}" state: reconnect diff --git a/test/integration/targets/vmware_host_facts/tasks/main.yml b/test/integration/targets/vmware_host_facts/tasks/main.yml index f120433ea1d..215d7518f8e 100644 --- a/test/integration/targets/vmware_host_facts/tasks/main.yml +++ b/test/integration/targets/vmware_host_facts/tasks/main.yml @@ -23,8 +23,8 @@ vmware_host_facts: validate_certs: False hostname: '{{ esxi1 }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' register: facts - debug: var=facts - name: verify some data,like ansible_processor diff --git a/test/integration/targets/vmware_host_firewall_facts/tasks/main.yml b/test/integration/targets/vmware_host_firewall_facts/tasks/main.yml index b88ecc9e6db..e58e8f1fc95 100644 --- a/test/integration/targets/vmware_host_firewall_facts/tasks/main.yml +++ b/test/integration/targets/vmware_host_firewall_facts/tasks/main.yml @@ -4,7 +4,7 @@ - import_role: name: prepare_vmware_tests vars: - setup_esxi_instance: true + setup_attach_host: true - name: Gather firewall facts for a given ESXi vmware_host_firewall_facts: diff --git a/test/integration/targets/vmware_host_powermgmt_policy/tasks/main.yml b/test/integration/targets/vmware_host_powermgmt_policy/tasks/main.yml index 472f05ab6e2..0c2b408010a 100644 --- a/test/integration/targets/vmware_host_powermgmt_policy/tasks/main.yml +++ b/test/integration/targets/vmware_host_powermgmt_policy/tasks/main.yml @@ -73,5 +73,5 @@ assert: that: - not (all_hosts_result is changed) - - "all_hosts_result.result['{{ esxi1 }}']current_state == 'balanced'" - - "all_hosts_result.result['{{ esxi2 }}']current_state == 'balanced'" + - "all_hosts_result.result['{{ esxi1 }}'].current_state == 'balanced'" + - "all_hosts_result.result['{{ esxi2 }}'].current_state == 'balanced'" diff --git a/test/integration/targets/vmware_host_snmp/tasks/main.yml b/test/integration/targets/vmware_host_snmp/tasks/main.yml index 7d8eee073f9..45f73e48b86 100644 --- a/test/integration/targets/vmware_host_snmp/tasks/main.yml +++ b/test/integration/targets/vmware_host_snmp/tasks/main.yml @@ -12,9 +12,9 @@ # SNMP works only with standalone ESXi server - name: Enable and configure SNMP community in check mode vmware_host_snmp: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' community: [ test ] state: enabled validate_certs: no @@ -28,9 +28,9 @@ - name: Enable and configure SNMP community vmware_host_snmp: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' community: [ test ] state: enabled validate_certs: no @@ -43,9 +43,9 @@ - name: Disable SNMP vmware_host_snmp: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' state: disabled validate_certs: no register: snmp_disabled diff --git a/test/integration/targets/vmware_local_user_facts/tasks/main.yml b/test/integration/targets/vmware_local_user_facts/tasks/main.yml index 2fc0c004a0b..f0f1b560181 100644 --- a/test/integration/targets/vmware_local_user_facts/tasks/main.yml +++ b/test/integration/targets/vmware_local_user_facts/tasks/main.yml @@ -15,9 +15,9 @@ - &user_fact_data name: Gather facts about users vmware_local_user_facts: - hostname: "{{ hostvars[esxi1].ansible_host }}" - username: "{{ hostvars[esxi1].ansible_user }}" - password: "{{ hostvars[esxi1].ansible_password }}" + hostname: "{{ esxi1 }}" + username: "{{ esxi_user }}" + password: "{{ esxi_password }}" validate_certs: False register: all_user_facts diff --git a/test/integration/targets/vmware_portgroup/tasks/main.yml b/test/integration/targets/vmware_portgroup/tasks/main.yml index 341dadce5fe..24f88dccfd6 100644 --- a/test/integration/targets/vmware_portgroup/tasks/main.yml +++ b/test/integration/targets/vmware_portgroup/tasks/main.yml @@ -4,9 +4,13 @@ - when: vcsim is not defined block: - - debug: var=ccr1 - - debug: var=host1 + - import_role: + name: prepare_vmware_tests + vars: + setup_datacenter: true + setup_attach_host: true + setup_cluster: true - name: Create portgroup without Portgroup and vSwitch vmware_portgroup: diff --git a/test/integration/targets/vmware_vm_facts/tasks/main.yml b/test/integration/targets/vmware_vm_facts/tasks/main.yml index 276448d2d56..42784e50859 100644 --- a/test/integration/targets/vmware_vm_facts/tasks/main.yml +++ b/test/integration/targets/vmware_vm_facts/tasks/main.yml @@ -3,14 +3,20 @@ # Copyright, (c) 2018, Fedor Vompe # 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_datastore: true + setup_virtualmachines: true + - when: vcsim is not defined block: - name: Get facts from a given ESXi vmware_vm_facts: validate_certs: false hostname: '{{ esxi1 }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' - import_role: name: prepare_vmware_tests @@ -59,7 +65,7 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "DC0_H0_VM0" + name: "{{ virtual_machines[0].name }}" register: folder_path_info - set_fact: @@ -75,6 +81,7 @@ folder: "{{ folder_path }}" register: vm_facts when: folder_path_info.folders is defined +- debug: var=vm_facts - name: Check if facts are returned for VM with folder specified assert: diff --git a/test/integration/targets/vmware_vm_host_drs_rule/tasks/main.yml b/test/integration/targets/vmware_vm_host_drs_rule/tasks/main.yml index e4ea13d5302..41ac2560a0e 100644 --- a/test/integration/targets/vmware_vm_host_drs_rule/tasks/main.yml +++ b/test/integration/targets/vmware_vm_host_drs_rule/tasks/main.yml @@ -10,6 +10,7 @@ setup_attach_host: true setup_datastore: true setup_virtualmachines: true + - name: Create DRS VM group vmware_drs_group: hostname: "{{ vcenter_hostname }}" @@ -20,7 +21,7 @@ cluster_name: '{{ ccr1 }}' datacenter_name: '{{ dc1 }}' group_name: DC0_C0_VM_GR1 - vms: '{{ infra.vm_list }}' + vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}" state: present register: drs_vm_group_01_results - debug: var=drs_vm_group_01_results @@ -35,9 +36,7 @@ cluster_name: '{{ ccr1 }}' datacenter_name: '{{ dc1 }}' group_name: DC0_C0_HOST_GR1 - hosts: - - '{{ hostvars[esxi1].ansible_host }}' - - '{{ hostvars[esxi2].ansible_host }}' + hosts: '{{ esxi_hosts }}' state: present register: drs_host_group_01_results - debug: var=drs_host_group_01_results diff --git a/test/integration/targets/vmware_vm_vm_drs_rule/tasks/main.yml b/test/integration/targets/vmware_vm_vm_drs_rule/tasks/main.yml index 3e6e440027b..71723bead1c 100644 --- a/test/integration/targets/vmware_vm_vm_drs_rule/tasks/main.yml +++ b/test/integration/targets/vmware_vm_vm_drs_rule/tasks/main.yml @@ -19,7 +19,7 @@ password: "{{ vcenter_password }}" drs_rule_name: drs_rule_0001 cluster_name: "{{ ccr1 }}" - vms: "{{ infra.vm_list }}" + vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}" enabled: True affinity_rule: True mandatory: True diff --git a/test/integration/targets/vmware_vswitch/tasks/main.yml b/test/integration/targets/vmware_vswitch/tasks/main.yml index 8f1305d09b4..01bc4c0f74f 100644 --- a/test/integration/targets/vmware_vswitch/tasks/main.yml +++ b/test/integration/targets/vmware_vswitch/tasks/main.yml @@ -14,9 +14,9 @@ - name: Add a nic to a switch vmware_vswitch: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' validate_certs: no switch: vmswitch_0001 nics: vnic_1 @@ -28,9 +28,9 @@ - name: Add a nic to a switch again vmware_vswitch: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' validate_certs: no switch: vmswitch_0001 nics: vnic_1 @@ -42,9 +42,9 @@ - name: Remove a switch (check-mode) vmware_vswitch: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' validate_certs: no switch: vmswitch_0001 state: absent @@ -58,9 +58,9 @@ # FIXME: Removing a switch fails - name: Remove a switch vmware_vswitch: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' validate_certs: no switch: vmswitch_0001 state: absent @@ -71,9 +71,9 @@ - name: Remove a switch again (check-mode) vmware_vswitch: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' validate_certs: no switch: vmswitch_0001 state: absent @@ -87,9 +87,9 @@ # FIXME: Removing a switch fails - name: Remove a switch again vmware_vswitch: - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' validate_certs: no switch: vmswitch_0001 state: absent @@ -101,9 +101,9 @@ - name: Add vswitch to a specific host system vmware_vswitch: validate_certs: False - hostname: '{{ hostvars[esxi1].ansible_host }}' - username: '{{ hostvars[esxi1].ansible_user }}' - password: '{{ hostvars[esxi1].ansible_password }}' + hostname: '{{ esxi1 }}' + username: '{{ esxi_user }}' + password: '{{ esxi_password }}' switch: vmswitch_0002 nics: vnic_1 esxi_hostname: guest1