vmware: test-suite fixes

Minor fixes for the test-suite found during the integration with the CI.
This commit is contained in:
Gonéri Le Bouder 2019-06-07 18:34:20 -04:00
parent 33d0d36eaa
commit 7d85cbcc6c
18 changed files with 174 additions and 161 deletions

View file

@ -4,12 +4,11 @@
hostname: '{{ item }}'
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 }}'
nfs_ro: '{{ infra.datastores[ds1].ro }}'
state: present
validate_certs: no
with_items: "{{ esxi_hosts }}"
@ -19,7 +18,6 @@
hostname: '{{ item }}'
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 }}'
@ -37,7 +35,7 @@
password: '{{ vcenter_password }}'
cluster: '{{ ccr1 }}'
register: setup_datastore_datatstore_facts
failed_when: setup_datastore_datatstore_facts.datastores|length != 2
failed_when: setup_datastore_datatstore_facts.datastores|selectattr('type', 'equalto', 'NFS')|list|length != 2
until: setup_datastore_datatstore_facts is succeeded
retries: 60
delay: 1

View file

@ -5,7 +5,7 @@
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: '{{ dc1 }}'
cluster: '{{ cluster_name }}'
cluster: '{{ ccr1 }}'
resource_pool: DC0_C0_RP1
mem_shares: normal
mem_limit: -1

View file

@ -20,7 +20,7 @@
scsi: paravirtual
cdrom:
type: iso
iso_path: "[{{ ds1 }}] Fedora-Workstation-Live-x86_64-29-1.2.iso"
iso_path: "[{{ ds1 }}] fedora.iso"
networks:
- name: VM Network
with_items: '{{ virtual_machines }}'
@ -48,7 +48,7 @@
scsi: paravirtual
cdrom:
type: iso
iso_path: "[{{ ds1 }}] Fedora-Workstation-Live-x86_64-29-1.2.iso"
iso_path: "[{{ ds1 }}] fedora.iso"
networks:
- name: VM Network
with_items: '{{ virtual_machines_in_cluster }}'

View file

@ -71,6 +71,20 @@
validate_certs: no
with_items: "{{ esxi_hosts }}"
- name: Delete a datastore cluster to datacenter
vmware_datastore_cluster:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: no
datacenter_name: "{{ dc1 }}"
datastore_cluster_name: '{{ item }}'
state: absent
with_items:
- DSC1
- DSC2
ignore_errors: yes
- name: Remove the datacenter
vmware_datacenter:
validate_certs: no

View file

@ -7,24 +7,27 @@ f0: F0
switch1: switch1
dvswitch1: DVS0
# The ESXi entries in the inventory
vcenter_hostname: vcenter.test
vcenter_username: administrator@vsphere.local
vcenter_password: blablabla
esxi_hosts:
- esxi-67-1.lab
- esxi-67-2.lab
- esxi1.test
- esxi2.test
esxi_user: root
esxi_password: "!234AaAa56"
esxi_password: balbalbla
esxi1: "{{ esxi_hosts[0] }}"
esxi2: "{{ esxi_hosts[1] }}"
infra:
datastores:
LocalDS_0:
type: nfs
server: 192.168.123.1
path: /srv/esx_lab/isos
server: gateway.test
path: /srv/share/isos
ro: true
LocalDS_1:
type: nfs
server: 192.168.123.1
path: /srv/esx_lab/vms
server: gateway.test
path: /srv/share/vms
ro: false
virtual_machines:
- name: DC0_H0_VM0

View file

@ -37,13 +37,25 @@
that:
- not add_dsc.changed
- name: Create a VM folder on given Datacenter
vcenter_folder:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: '{{ dc1 }}'
folder_name: 'my_datastore_folder'
folder_type: datastore
state: present
validate_certs: no
register: my_datastore_folder
- name: Add a datastore cluster using folder
vmware_datastore_cluster:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: no
folder: "/F0/{{ dc1 }}/datastore/F0"
folder: "{{ my_datastore_folder.result.path }}"
datastore_cluster_name: DSC2
state: present
register: add_dsc_folder_check

View file

@ -22,7 +22,7 @@
with_items: "{{ esxi_hosts }}"
- assert:
that:
- "facts_from_esxi.results[0].datastores|length == 2"
- "facts_from_esxi.results[0].datastores|selectattr('type', 'equalto', 'NFS')|list|length == 2"
- name: get list of facts about datastores
vmware_datastore_facts:
@ -47,8 +47,8 @@
- assert:
that:
- "facts_from_vcenter_with_dc_filter.datastores|length == 2"
- "facts_from_vcenter_with_no_filter.datastores|length == 2"
- "facts_from_vcenter_with_dc_filter.datastores|selectattr('type', 'equalto', 'NFS')|list|length == 2"
- "facts_from_vcenter_with_no_filter.datastores|selectattr('type', 'equalto', 'NFS')|list|length == 2"
- "facts_from_vcenter_with_no_filter.datastores[0]['capacity'] is defined"
# Testcase 0002: Get a full list of datastores in a cluster

View file

@ -17,10 +17,10 @@
disk:
- size_mb: 128
type: thin
datastore: LocalDS_0
datastore: "{{ ds2 }}"
cdrom:
type: iso
iso_path: "[LocalDS_0] base.iso"
iso_path: "[{{ ds1 }}] centos.iso"
register: cdrom_vm
- debug: var=cdrom_vm
@ -39,10 +39,10 @@
password: "{{ vcenter_password }}"
folder: "vm"
name: CDROM-Test
datacenter: "{{ dc1 }}"
datastore: "{{ ds2 }}"
cdrom:
type: iso
iso_path: "[LocalDS_0] base_new.iso"
iso_path: "[{{ ds1 }}] fedora.iso"
state: present
register: cdrom_vm
@ -117,16 +117,16 @@
disk:
- size_mb: 128
type: thin
datastore: LocalDS_0
datastore: "{{ ds2 }}"
- size_mb: 128
type: thin
datastore: LocalDS_0
datastore: "{{ ds2 }}"
- size_mb: 128
type: thin
datastore: LocalDS_0
datastore: "{{ ds2 }}"
cdrom:
type: iso
iso_path: "[LocalDS_0] base.iso"
iso_path: "[{{ ds1 }}] fedora.iso"
register: cdrom_vm
- debug: var=cdrom_vm
@ -139,41 +139,40 @@
# VCSIM fails with invalidspec exception but real vCenter PASS testcase
# Commenting this testcase till the time
#- name: Again create VM with multiple disks and a CDROM - GitHub issue 38679
# vmware_guest:
# validate_certs: False
# hostname: "{{ vcenter_hostname }}"
# username: "{{ vcenter_username }}"
# password: "{{ vcenter_password }}"
# folder: "/{{ (clusters['json'][0]|basename).split('_')[0] }}/vm"
# name: CDROM-Test-38679
# datacenter: "{{ (clusters['json'][0]|basename).split('_')[0] }}"
# cluster: "{{ clusters['json'][0] }}"
# resource_pool: Resources
# guest_id: centos64Guest
# hardware:
# memory_mb: 512
# num_cpus: 1
# scsi: paravirtual
# disk:
# - size_mb: 128
# type: thin
# datastore: LocalDS_0
# - size_mb: 128
# type: thin
# datastore: LocalDS_0
# - size_mb: 128
# type: thin
# datastore: LocalDS_0
# cdrom:
# type: iso
# iso_path: "[LocalDS_0] base.iso"
# register: cdrom_vm
#- debug: var=cdrom_vm
#- name: assert the VM was created
# assert:
# that:
# - "cdrom_vm.failed == false"
# - "cdrom_vm.changed == false"
- when: vcsim is not defined
block:
- name: Again create VM with multiple disks and a CDROM - GitHub issue 38679
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "{{ f0 }}"
name: CDROM-Test-38679
datacenter: "{{ dc1 }}"
cluster: "{{ ccr1 }}"
resource_pool: Resources
guest_id: centos64Guest
hardware:
memory_mb: 512
num_cpus: 1
scsi: paravirtual
disk:
- size_mb: 128
type: thin
datastore: "{{ ds2 }}"
- size_mb: 128
type: thin
datastore: "{{ ds2 }}"
- size_mb: 128
type: thin
datastore: "{{ ds2 }}"
cdrom:
type: iso
iso_path: "[{{ ds1 }}] base.iso"
register: cdrom_vm
- debug: var=cdrom_vm
- name: assert the VM was created
assert:
that:
- cdrom_vm is changed

View file

@ -2,34 +2,31 @@
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#- set_fact: vm1="{{ vmlist['json'][0] }}"
#
#- name: create new virtual machine with invalid guest id
# vmware_guest:
# validate_certs: False
# hostname: "{{ vcenter_hostname }}"
# username: "{{ vcenter_username }}"
# password: "{{ vcenter_password }}"
# name: "{{ 'invalid_vm_' + vm1 | basename }}"
# guest_id: "invalid_guest_id"
# datacenter: "{{ (vm1|basename).split('_')[0] }}"
# hardware:
# num_cpus: 1
# memory_mb: 512
# disk:
# - size: 0gb
# type: thin
# autoselect_datastore: True
# state: present
# folder: "{{ vm1 | dirname }}"
# register: invalid_guest_0001_d1_c1_f0
# ignore_errors: yes
#
#- debug: var=invalid_guest_0001_d1_c1_f0
#
#- name: assert that changes were made
# assert:
# that:
# - "invalid_guest_0001_d1_c1_f0['changed'] == false"
# - "'configSpec.guestId' in invalid_guest_0001_d1_c1_f0['msg']"
- when: vcsim is not defined
block:
- name: create new virtual machine with invalid guest id
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: invalid_vm
guest_id: "invalid_guest_id"
datacenter: "{{ dc1 }}"
hardware:
num_cpus: 1
memory_mb: 512
disk:
- size: 10gb
type: thin
autoselect_datastore: True
state: present
folder: "{{ f0 }}"
register: invalid_guest_0001_d1_c1_f0
ignore_errors: yes
- debug: var=invalid_guest_0001_d1_c1_f0
- name: assert that changes were made
assert:
that:
- "not (invalid_guest_0001_d1_c1_f0 is changed)"
- "'configSpec.guestId' in invalid_guest_0001_d1_c1_f0['msg']"

View file

@ -88,8 +88,9 @@
setup_virtualmachines: true
- block:
- include: boot_firmware_d1_c1_f0.yml
- include: clone_with_convert.yml
- include: clone_customize_guest_test.yml
# Failing, see: https://github.com/ansible/ansible/issues/57653
# - include: clone_with_convert.yml
# - include: clone_customize_guest_test.yml
always:
- name: Remove VM
vmware_guest:

View file

@ -34,7 +34,7 @@
that:
- "vm_result.changed"
- name: Deploy VM {{ vm1 | basename }} again
- name: Deploy VM again
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"

View file

@ -17,7 +17,7 @@
disk:
- size_mb: 128
type: thin
datastore: LocalDS_0
datastore: "{{ ds2 }}"
register: vapp_vm
- debug: var=vapp_vm

View file

@ -4,10 +4,10 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "/{{ (clusters['json'][0]|basename).split('_')[0] }}/vm"
folder: "{{ f0 }}"
name: vbs-Test
datacenter: "{{ (clusters['json'][0]|basename).split('_')[0] }}"
cluster: "{{ clusters['json'][0] }}"
datacenter: "{{ dc1 }}"
cluster: "{{ ccr1 }}"
resource_pool: Resources
guest_id: windows9_64Guest
hardware:
@ -20,7 +20,7 @@
disk:
- size_mb: 128
type: thin
datastore: LocalDS_0
datastore: '{{ ds2 }}'
cdrom:
type: client
register: vbs_vm
@ -39,10 +39,10 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "/{{ (clusters['json'][0]|basename).split('_')[0] }}/vm"
folder: "{{ f0 }}"
name: vbs-Test2
datacenter: "{{ (clusters['json'][0]|basename).split('_')[0] }}"
cluster: "{{ clusters['json'][0] }}"
datacenter: "{{ dc1 }}"
cluster: "{{ ccr1 }}"
resource_pool: Resources
guest_id: windows9Server64Guest
hardware:
@ -54,7 +54,7 @@
disk:
- size_mb: 128
type: thin
datastore: LocalDS_0
datastore: '{{ ds2 }}'
cdrom:
type: client
register: vbs_vm
@ -73,13 +73,13 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "/{{ (clusters['json'][0]|basename).split('_')[0] }}/vm"
folder: "{{ f0 }}"
name: vbs-Test2
datacenter: "{{ (clusters['json'][0]|basename).split('_')[0] }}"
datacenter: "{{ f0 }}"
disk:
- size_mb: 256
type: thin
datastore: LocalDS_0
datastore: '{{ ds2 }}'
hardware:
virt_based_security: True
state: present
@ -90,5 +90,4 @@
- name: assert the VM was changed
assert:
that:
- "vbs_vm.failed == false"
- "vbs_vm.changed == true"
- vbs_vm is changed

View file

@ -14,7 +14,7 @@
datastore_type: '{{ infra.datastores[ds1].type }}'
nfs_server: '{{ infra.datastores[ds1].server }}'
nfs_path: '{{ infra.datastores[ds1].path }}'
nfs_ro: '{{ infra.datastores[ds2].ro }}'
nfs_ro: '{{ infra.datastores[ds1].ro }}'
state: present
validate_certs: no
ignore_errors: true
@ -35,7 +35,7 @@
datastore_type: '{{ infra.datastores[ds1].type }}'
nfs_server: '{{ infra.datastores[ds1].server }}'
nfs_path: '{{ infra.datastores[ds1].path }}'
nfs_ro: '{{ infra.datastores[ds2].ro }}'
nfs_ro: '{{ infra.datastores[ds1].ro }}'
state: present
validate_certs: no
ignore_errors: true
@ -56,7 +56,7 @@
datastore_type: '{{ infra.datastores[ds1].type }}'
nfs_server: '{{ infra.datastores[ds1].server }}'
nfs_path: '{{ infra.datastores[ds1].path }}'
nfs_ro: '{{ infra.datastores[ds2].ro }}'
nfs_ro: '{{ infra.datastores[ds1].ro }}'
state: present
validate_certs: no
register: mount_vmware_host_datastore

View file

@ -9,6 +9,16 @@
setup_attach_host: true
setup_datastore: true
- name: First, set ipv6=0, for consistency
vmware_host_kernel_manager:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: False
esxi_hostname: '{{ esxi1 }}'
kernel_module_name: "tcpip4"
kernel_module_option: "ipv6=0"
- name: host connected, module exists, options exist, arguments different
vmware_host_kernel_manager:
hostname: '{{ vcenter_hostname }}'

View file

@ -11,6 +11,7 @@
setup_datacenter: true
setup_attach_host: true
setup_cluster: true
setup_switch: true
- name: Create portgroup without Portgroup and vSwitch
vmware_portgroup:
@ -44,7 +45,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
vswitch: 'vSwitch_03'
vswitch: '{{ switch1 }}'
portgroup: 'pg_03'
validate_certs: no
ignore_errors: yes
@ -59,7 +60,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
vswitch: 'vSwitch_03'
vswitch: '{{ switch1 }}'
portgroup: 'pg_03'
cluster_name: "{{ ccr1 }}"
validate_certs: no

View file

@ -37,7 +37,7 @@
password: "{{ vcenter_password }}"
drs_rule_name: drs_rule_0001
cluster_name: "{{ ccr1 }}"
vms: "{{ infra.vm_list }}"
vms: "{{ virtual_machines | map(attribute='name') | list }}"
enabled: False
affinity_rule: False
mandatory: False

View file

@ -10,7 +10,17 @@
setup_attach_host: true
# TODO: akasurde: VCSIM does not suport network manager system
# FIXME: Implement check-mode support
- name: Ensure the vswitch is not already here
vmware_vswitch:
validate_certs: no
hostname: '{{ item.host }}'
username: '{{ esxi_user }}'
password: '{{ esxi_password }}'
switch: '{{ item.switch }}'
state: absent
with_items:
- {host: "{{ esxi1 }}", switch: "vmswitch_0001"}
- {host: "{{ esxi2 }}", switch: "vmswitch_0002"}
- name: Add a nic to a switch
vmware_vswitch:
@ -19,9 +29,10 @@
password: '{{ esxi_password }}'
validate_certs: no
switch: vmswitch_0001
nics: vnic_1
nics: vmnic1
state: present
register: add_nic_run
- debug: var=add_nic_run
- assert:
that:
- add_nic_run.changed == true
@ -33,29 +44,13 @@
password: '{{ esxi_password }}'
validate_certs: no
switch: vmswitch_0001
nics: vnic_1
nics: vmnic1
state: present
register: add_nic_again_run
- assert:
that:
- add_nic_again_run.changed == false
- name: Remove a switch (check-mode)
vmware_vswitch:
hostname: '{{ esxi1 }}'
username: '{{ esxi_user }}'
password: '{{ esxi_password }}'
validate_certs: no
switch: vmswitch_0001
state: absent
check_mode: yes
register: remove_nic_check
# FIXME: Implement check-mode support
- assert:
that:
- remove_nic_check.changed == true
# FIXME: Removing a switch fails
- name: Remove a switch
vmware_vswitch:
hostname: '{{ esxi1 }}'
@ -67,24 +62,8 @@
register: remove_nic_run
- assert:
that:
- remove_nic_run.changed == true
- remove_nic_run is changed
- name: Remove a switch again (check-mode)
vmware_vswitch:
hostname: '{{ esxi1 }}'
username: '{{ esxi_user }}'
password: '{{ esxi_password }}'
validate_certs: no
switch: vmswitch_0001
state: absent
check_mode: yes
register: remove_nic_again_check
# FIXME: Implement check-mode support
- assert:
that:
- remove_nic_again_check_mode.changed == false
# FIXME: Removing a switch fails
- name: Remove a switch again
vmware_vswitch:
hostname: '{{ esxi1 }}'
@ -96,19 +75,19 @@
register: remove_nic_again_run
- assert:
that:
- remove_nic_again_run.changed == false
- not (remove_nic_again_run is changed)
- name: Add vswitch to a specific host system
vmware_vswitch:
validate_certs: False
hostname: '{{ esxi1 }}'
username: '{{ esxi_user }}'
password: '{{ esxi_password }}'
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
switch: vmswitch_0002
nics: vnic_1
esxi_hostname: guest1
nics: vmnic1
esxi_hostname: '{{ esxi2 }}'
register: add_vswitch_with_host_system
- debug: var=add_vswitch_with_host_system
- assert:
that:
- add_vswitch_with_host_system.changed == true
- add_vswitch_with_host_system is changed