diff --git a/Makefile b/Makefile index 59036e50..32a92bd5 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,9 @@ integration: install-python-packages install-ansible-collections .PHONY: eco-vcenter-ci eco-vcenter-ci: install-python-packages install-ansible-collections install-pyvmomy-latest - ansible-test integration --no-temp-workdir info_test + @for dir in $(shell ansible-test integration --list-target --no-temp-workdir | grep 'vmware_ops_'); do \ + ansible-test integration --no-temp-workdir $$dir; \ + done .PHONY: ee-clean ee-clean: diff --git a/tests/integration/targets/.DS_Store b/tests/integration/targets/.DS_Store new file mode 100644 index 00000000..1260aaf1 Binary files /dev/null and b/tests/integration/targets/.DS_Store differ diff --git a/tests/integration/targets/init.sh b/tests/integration/targets/init.sh index 2cefa174..492fce9b 100644 --- a/tests/integration/targets/init.sh +++ b/tests/integration/targets/init.sh @@ -1,8 +1,13 @@ #!/usr/bin/env bash # shellcheck disable=SC2155,SC2086 -# Export the collections path -export ANSIBLE_COLLECTIONS_PATH="$ANSIBLE_COLLECTIONS_PATH/ansible_collections" +export DEFAULT_COLLECTIONS_PATH="$ANSIBLE_COLLECTIONS_PATH/ansible_collections" + +# Check if the variable is already set (e.g., in CI) +if [ -z "$ANSIBLE_COLLECTIONS_PATH" ]; then + # If not, use base collections path + ANSIBLE_COLLECTIONS_PATH="$DEFAULT_COLLECTIONS_PATH" +fi echo "ANSIBLE_COLLECTIONS_PATH: $ANSIBLE_COLLECTIONS_PATH" BASE_DIR=$(dirname "$(realpath "${BASH_SOURCE[0]}")") diff --git a/tests/integration/targets/provision_vm_test/run.yml b/tests/integration/targets/provision_vm_test/run.yml deleted file mode 100644 index 69481b4a..00000000 --- a/tests/integration/targets/provision_vm_test/run.yml +++ /dev/null @@ -1,13 +0,0 @@ -- hosts: localhost - gather_facts: no - collections: - - community.general - - tasks: - - name: Vcsim - ansible.builtin.import_role: - name: prepare_soap - - - name: Import provision VM role - ansible.builtin.import_role: - name: provision_vm_test diff --git a/tests/integration/targets/provision_vm_test/runme.sh b/tests/integration/targets/provision_vm_test/runme.sh deleted file mode 100755 index a4c36631..00000000 --- a/tests/integration/targets/provision_vm_test/runme.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -source ../init.sh -exec ansible-playbook run.yml diff --git a/tests/integration/targets/provision_vm_test/tasks/main.yml b/tests/integration/targets/provision_vm_test/tasks/main.yml deleted file mode 100644 index 47be9ce2..00000000 --- a/tests/integration/targets/provision_vm_test/tasks/main.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- name: Provision VM - ansible.builtin.import_role: - name: cloud.vmware_ops.provision_vm - vars: - provision_vm_hostname: "127.0.0.1" - provision_vm_username: "test" - provision_vm_password: "test" - provision_vm_validate_certs: false - provision_vm_cluster: "DC0_C0" - provision_vm_folder: "/DC0/vm" - provision_vm_datacenter: "DC0" - provision_vm_name: "vm-test" - provision_vm_port: "8989" - provision_vm_disk: - - size_gb: 10 - type: thin - datastore: "LocalDS_0" - provision_vm_hardware: - memory_mb: 512 - num_cpus: 4 - provision_vm_guest_id: "centos64Guest" diff --git a/tests/integration/targets/info_test/mock.json b/tests/integration/targets/vmware_ops_info_test/mock.json similarity index 100% rename from tests/integration/targets/info_test/mock.json rename to tests/integration/targets/vmware_ops_info_test/mock.json diff --git a/tests/integration/targets/info_test/run.yml b/tests/integration/targets/vmware_ops_info_test/run.yml similarity index 95% rename from tests/integration/targets/info_test/run.yml rename to tests/integration/targets/vmware_ops_info_test/run.yml index a3e81541..52fbbeef 100644 --- a/tests/integration/targets/info_test/run.yml +++ b/tests/integration/targets/vmware_ops_info_test/run.yml @@ -28,7 +28,7 @@ - name: Import info role ansible.builtin.import_role: - name: info_test + name: vmware_ops_info_test tags: - eco-vcenter-ci - integration-ci diff --git a/tests/integration/targets/info_test/runme.sh b/tests/integration/targets/vmware_ops_info_test/runme.sh similarity index 100% rename from tests/integration/targets/info_test/runme.sh rename to tests/integration/targets/vmware_ops_info_test/runme.sh diff --git a/tests/integration/targets/info_test/tasks/main.yml b/tests/integration/targets/vmware_ops_info_test/tasks/main.yml similarity index 100% rename from tests/integration/targets/info_test/tasks/main.yml rename to tests/integration/targets/vmware_ops_info_test/tasks/main.yml diff --git a/tests/integration/targets/info_test/vars.yml b/tests/integration/targets/vmware_ops_info_test/vars.yml similarity index 100% rename from tests/integration/targets/info_test/vars.yml rename to tests/integration/targets/vmware_ops_info_test/vars.yml diff --git a/tests/integration/targets/info_test/vars/main.yml b/tests/integration/targets/vmware_ops_info_test/vars/main.yml similarity index 100% rename from tests/integration/targets/info_test/vars/main.yml rename to tests/integration/targets/vmware_ops_info_test/vars/main.yml diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/run.yml b/tests/integration/targets/vmware_ops_provision_vm_test/run.yml new file mode 100644 index 00000000..5b1953bd --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/run.yml @@ -0,0 +1,27 @@ +- hosts: localhost + gather_facts: no + collections: + - community.general + + tasks: + - name: Import eco-vcenter credentials + ansible.builtin.include_vars: + file: ../../integration_config.yml + tags: eco-vcenter-ci + + - name: Import simulator vars + ansible.builtin.include_vars: + file: vars.yml + tags: integration-ci + + - name: Vcsim + ansible.builtin.import_role: + name: prepare_soap + tags: integration-ci + + - name: Import provision VM role + ansible.builtin.import_role: + name: vmware_ops_provision_vm_test + tags: + - eco-vcenter-ci + - integration-ci diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/runme.sh b/tests/integration/targets/vmware_ops_provision_vm_test/runme.sh new file mode 100755 index 00000000..a3298746 --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/runme.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +source ../init.sh + +# Extract the ansible_tags from integration_config.yml +ANSIBLE_TAGS=$(awk '/ansible_tags/ {print $2}' ../../integration_config.yml) + +# Check if the ANSIBLE_TAGS variable is set +if [[ -n "$ANSIBLE_TAGS" ]]; then + echo "ANSIBLE_TAGS is set to: $ANSIBLE_TAGS" + exec ansible-playbook run.yml --tags "$ANSIBLE_TAGS" +else + echo "ANSIBLE_TAGS is not set for Eco vCenter. Running on simulator." + exec ansible-playbook run.yml --tags integration-ci +fi diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/tasks/cleanup_vms.yml b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/cleanup_vms.yml new file mode 100644 index 00000000..9424b9b6 --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/cleanup_vms.yml @@ -0,0 +1,23 @@ +--- +- name: Deprovision VM {{ item.provision_vm_name }} + ansible.builtin.include_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_name: "{{ item.provision_vm_name }}" + provision_vm_state: "absent" + provision_vm_force: true + +- name: "Check that the following VM does not exist: {{ item.provision_vm_name }}" + community.vmware.vmware_vm_info: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: "{{ provision_vm_validate_certs }}" + vm_name: "{{ item.provision_vm_name }}" + register: vm_info + ignore_errors: true + +- name: "Fail the task if the following VM exists: {{ item.provision_vm_name }}" + ansible.builtin.fail: + msg: "Provisioned VM {{ item.provision_vm_name }} still exists" + when: not vm_info.failed \ No newline at end of file diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/tasks/get_vm_info.yml b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/get_vm_info.yml new file mode 100644 index 00000000..ae48d6c5 --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/get_vm_info.yml @@ -0,0 +1,14 @@ +--- +- name: "Check VM existence: {{ vm_name }}" + community.vmware.vmware_vm_info: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: "{{ provision_vm_validate_certs }}" + vm_name: "{{ vm_name }}" + register: vm_info + +- name: Fail the task if the VM doesn't exist + ansible.builtin.fail: + msg: "Provisioned VM does not exist" + when: vm_info is not defined or vm_info.failed diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/tasks/main.yml b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/main.yml new file mode 100644 index 00000000..873697ac --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/main.yml @@ -0,0 +1,36 @@ +--- +- name: Provision VM for simulator + ansible.builtin.import_role: + name: cloud.vmware_ops.provision_vm + when: "'integration-ci' in ansible_run_tags" + +- name: Perform VM Lifecycle Operations in vCenter Environment + block: + - name: Provision multiple VMs + loop: "{{ provision_vms }}" + ansible.builtin.include_tasks: provision_vms_with_validation.yml + + - name: Turn one of the provisioned VMs into template + loop: "{{ provision_vms_template }}" + community.vmware.vmware_guest: + hostname: "{{ provision_vm_hostname }}" + username: "{{ provision_vm_username }}" + password: "{{ provision_vm_password }}" + validate_certs: "{{ provision_vm_validate_certs }}" + name: "{{ item.provision_vm_name }}" + is_template: true + folder: "{{ provision_vm_folder }}" + datacenter: "{{ provision_vm_datacenter }}" + + - name: Create a VM from the template + loop: "{{ provision_vms_from_template }}" + ansible.builtin.include_tasks: provision_vms_with_validation.yml + + - name: Update one the provisioned VMs + ansible.builtin.include_tasks: update_vm.yml + + always: + - name: Cleanup VMs and template from the vcenter env + loop: "{{ provision_vms + provision_vms_template + provision_vms_from_template }}" + ansible.builtin.include_tasks: cleanup_vms.yml + when: "'eco-vcenter-ci' in ansible_run_tags" diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_name_validation.yml b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_name_validation.yml new file mode 100644 index 00000000..2a5808bc --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_name_validation.yml @@ -0,0 +1,22 @@ +--- +- name: Collect information about VM with ID {{ vm_moid }} + vmware.vmware_rest.vcenter_vm_info: + vcenter_hostname: "{{ vcenter_hostname }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_validate_certs: "{{ provision_vm_validate_certs }}" + vm: '{{ vm_moid }}' + register: vm_info_updated_name + +- name: Print vm_info_updated_name for {{ vm_moid }} + ansible.builtin.debug: + var: vm_info_updated_name + +- name: Print vm_name + ansible.builtin.debug: + var: vm_name + +- name: Validate name of VM with ID {{ vm_moid }} + ansible.builtin.assert: + that: + - vm_info_updated_name.value.name == vm_name diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_settings_validation.yml b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_settings_validation.yml new file mode 100644 index 00000000..50f90ce7 --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_settings_validation.yml @@ -0,0 +1,68 @@ +--- +- name: Get info about the updated VM + ansible.builtin.include_tasks: + file: get_vm_info.yml + vars: + vm_name: "{{ vm_update_name }}" + +- name: "Get network info about '{{ vm_update_name }}' VM" + community.vmware.vmware_guest_network: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: "{{ provision_vm_validate_certs }}" + uuid: "{{ vm_uuid }}" + gather_network_info: true + register: vm_network_info + +- name: "Print vm_network_info for '{{ vm_update_name }}'" + ansible.builtin.debug: + var: vm_network_info + +- name: "Validate updated network configuration of '{{ vm_update_name }}' VM" + ansible.builtin.assert: + that: + - vm_network_info.network_info[index].name == network.name + - vm_network_info.network_info[index].device_type == network.device_type + - vm_network_info.network_info[index].mac_address == network.mac + loop: "{{ vm_updated_networks }}" + loop_control: + loop_var: network + index_var: index + +- name: Retrieve the CPU information from the VM + vmware.vmware_rest.vcenter_vm_hardware_cpu_info: + vcenter_hostname: "{{ vcenter_hostname }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_validate_certs: "{{ provision_vm_validate_certs }}" + vm: "{{ vm_moid }}" + register: cpu_info + +- name: Retrieve the memory information from the VM + vmware.vmware_rest.vcenter_vm_hardware_memory_info: + vcenter_hostname: "{{ vcenter_hostname }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_validate_certs: "{{ provision_vm_validate_certs }}" + vm: "{{ vm_moid }}" + register: memory_info + +- name: Retrieve disk information using the disk label + vmware.vmware_rest.vcenter_vm_hardware_disk_info: + vcenter_hostname: "{{ vcenter_hostname }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_validate_certs: "{{ provision_vm_validate_certs }}" + vm: "{{ vm_moid }}" + label: Hard disk 1 + register: disk_info + +- name: "Validate updated configuration of '{{ vm_update_name }}' VM" + ansible.builtin.assert: + that: + - vm_info.virtual_machines[0].guest_fullname == guest_fullnames[vm_updated_guest_id] + - cpu_info.value.count == vm_updated_hardware.num_cpus + - cpu_info.value.cores_per_socket == vm_updated_hardware.num_cpu_cores_per_socket + - memory_info.value.size_MiB == vm_updated_hardware.memory_mb + - disk_info.value.capacity == gib_to_bytes * ( vm_enlarge_disk[0].size_gb | int ) diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_state_validation.yml b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_state_validation.yml new file mode 100644 index 00000000..6bf67eb9 --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_state_validation.yml @@ -0,0 +1,11 @@ +--- +- name: Get info about the updated VM + ansible.builtin.include_tasks: + file: get_vm_info.yml + vars: + vm_name: "{{ vm_update_name }}" + +- name: "Validate that VM is in state {{ vm_state }}" + ansible.builtin.assert: + that: + - vm_info.virtual_machines[0].power_state | lower == vm_state diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/tasks/provision_vms_with_validation.yml b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/provision_vms_with_validation.yml new file mode 100644 index 00000000..0f653553 --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/provision_vms_with_validation.yml @@ -0,0 +1,46 @@ +--- +- name: Run Provision VM Role + ansible.builtin.include_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_name: "{{ item.provision_vm_name }}" + provision_vm_state: "{{ item.provision_vm_state | default(omit) }}" + provision_vm_cdrom: "{{ item.provision_vm_cdrom | default(omit) }}" + provision_vm_networks: "{{ item.provision_vm_networks | default(omit) }}" + provision_vm_esxi_hostname: "{{ item.provision_vm_esxi_hostname | default(omit) }}" + provision_vm_resource_pool: "{{ item.provision_vm_resource_pool | default(omit) }}" + provision_vm_port: "{{ item.provision_vm_port | default(omit) }}" + provision_vm_disk: "{{ item.provision_vm_disk | default(omit) }}" + provision_vm_hardware: "{{ item.provision_vm_hardware | default(omit) }}" + provision_vm_guest_id: "{{ item.provision_vm_guest_id | default(omit) }}" + provision_vm_datastore: "{{ item.provision_vm_datastore | default(omit) }}" + provision_vm_template: "{{ item.provision_vm_template | default(omit) }}" + +- name: Run post validations for VMs creation + block: + - name: Get info about the VM + ansible.builtin.include_tasks: + file: get_vm_info.yml + vars: + vm_name: "{{ item.provision_vm_name }}" + + - name: "Validate the properties of the following VM: {{ item.provision_vm_name }}" + ansible.builtin.assert: + that: + - vm_info.virtual_machines[0].guest_name == item.provision_vm_name + - vm_info.virtual_machines[0].cluster == provision_vm_cluster + - vm_info.virtual_machines[0].datacenter == provision_vm_datacenter + - vm_info.virtual_machines[0].folder == provision_vm_folder + - vm_info.virtual_machines[0].power_state | lower == item.provision_vm_state + + - name: "Validate the following VM datastore when datastore was defined in provision_vm_datastore: {{ item.provision_vm_name }}" + ansible.builtin.assert: + that: + - vm_info.virtual_machines[0].datastore_url[0].name == item.provision_vm_datastore + when: "'provision_vm_datastore' in item" + + - name: "Validate the following VM datastore when datastore was defined in provision_vm_disk: {{ item.provision_vm_name }}" + ansible.builtin.assert: + that: + - vm_info.virtual_machines[0].datastore_url[0].name == item.provision_vm_disk[0].datastore + when: "'provision_vm_datastore' not in item" diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/tasks/update_vm.yml b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/update_vm.yml new file mode 100644 index 00000000..5fbba84f --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/tasks/update_vm.yml @@ -0,0 +1,97 @@ +- name: Get info about the VM to be updated + ansible.builtin.include_tasks: + file: get_vm_info.yml + vars: + vm_name: "{{ vm_update_name }}" + +- name: Set vm_uuid variable + ansible.builtin.set_fact: + vm_uuid: "{{ vm_info.virtual_machines[0].uuid }}" + +- name: Set vm_moid variable + ansible.builtin.set_fact: + vm_moid: "{{ vm_info.virtual_machines[0].moid }}" + +- name: Update the name of an existing VM with UUID {{ vm_uuid }} + loop: "{{ vm_names_to_update }}" + ansible.builtin.include_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_uuid: "{{ vm_uuid }}" + provision_vm_name: "{{ item }}" + +- name: Verify updated VM name + loop: "{{ vm_names_to_update }}" + ansible.builtin.include_tasks: + file: post_update_name_validation.yml + vars: + vm_name: "{{ item }}" + +- name: "Update the state of an existing VM to: {{ vm_update_name }}" + loop: "{{ vm_states }}" + ansible.builtin.include_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_name: "{{ vm_update_name }}" + provision_vm_state: "{{ item }}" + provision_vm_force: true + +- name: Verify updated VM state + loop: "{{ vm_states }}" + ansible.builtin.include_tasks: + file: post_update_state_validation.yml + vars: + vm_state: "{{ item }}" + +- name: Add port group with network label {{ portgroup_name }} + community.vmware.vmware_portgroup: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: "{{ provision_vm_validate_certs }}" + cluster_name: "{{ provision_vm_cluster }}" + switch: "{{ vswitch_name }}" + portgroup: "{{ portgroup_name }}" + +- name: Update networks of existing VM {{ vm_update_name }} + ansible.builtin.import_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_name: "{{ vm_update_name }}" + provision_vm_networks: "{{ vm_updated_networks }}" + +- name: Update VM hardware properties + ansible.builtin.import_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_name: "{{ vm_update_name }}" + provision_vm_hardware: "{{ vm_updated_hardware }}" + +- name: Enlarge existing disk of existing VM {{ vm_update_name }} + ansible.builtin.import_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_name: "{{ vm_update_name }}" + provision_vm_disk: "{{ vm_enlarge_disk }}" + +- name: Update guest_id of existing VM {{ vm_update_name }} + ansible.builtin.import_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_name: "{{ vm_update_name }}" + provision_vm_guest_id: "{{ vm_updated_guest_id }}" + provision_vm_cdrom: "{{ vm_updated_cdrom }}" + +- name: Power on the updated VM {{ vm_update_name }} + loop: + - "poweredon" + ansible.builtin.include_role: + name: cloud.vmware_ops.provision_vm + vars: + provision_vm_name: "{{ vm_update_name }}" + provision_vm_state: "{{ item }}" + provision_vm_force: true + +- name: Verify updated VM settings + ansible.builtin.include_tasks: + file: post_update_settings_validation.yml \ No newline at end of file diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/vars.yml b/tests/integration/targets/vmware_ops_provision_vm_test/vars.yml new file mode 100644 index 00000000..afda0716 --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/vars.yml @@ -0,0 +1,17 @@ +provision_vm_hostname: "127.0.0.1" +provision_vm_username: "test" +provision_vm_password: "test" +provision_vm_validate_certs: false +provision_vm_cluster: "DC0_C0" +provision_vm_folder: "/DC0/vm" +provision_vm_datacenter: "DC0" +provision_vm_name: "vm-test" +provision_vm_port: "8989" +provision_vm_disk: +- size_gb: 10 + type: thin + datastore: "LocalDS_0" +provision_vm_hardware: + memory_mb: 512 + num_cpus: 4 +provision_vm_guest_id: "centos64Guest" \ No newline at end of file diff --git a/tests/integration/targets/vmware_ops_provision_vm_test/vars/main.yml b/tests/integration/targets/vmware_ops_provision_vm_test/vars/main.yml new file mode 100644 index 00000000..87df7486 --- /dev/null +++ b/tests/integration/targets/vmware_ops_provision_vm_test/vars/main.yml @@ -0,0 +1,163 @@ +# vars.yaml +provision_vm_hostname: "{{ vcenter_hostname }}" +provision_vm_username: "{{ vcenter_username }}" +provision_vm_password: "{{ vcenter_password }}" +provision_vm_validate_certs: false + +provision_vm_cluster: "Eco-Cluster" +provision_vm_folder: "/Eco-Datacenter/vm/e2e-qe" +provision_vm_datacenter: "Eco-Datacenter" + +# Create VM template +provision_vms_template: + - provision_vm_name: "qe-provision-vm-rhel-9" + provision_vm_state: "poweredoff" + provision_vm_cdrom: + - controller_number: 0 + unit_number: 0 + state: present + type: iso + iso_path: "[datastore1] ISO/rhel-9.3-x86_64-dvd.iso" + provision_vm_networks: + - name: "VM Network" + device_type: "vmxnet3" + mac: "00:50:56:bd:d2:9e" + type: "dhcp" + provision_vm_resource_pool: null + provision_vm_disk: + - size_gb: 50 + type: thin + datastore: "datastore1" + provision_vm_hardware: + memory_mb: 2000 + num_cpus: 4 + boot_firmware: efi + secure_boot: true + provision_vm_guest_id: "rhel9_64Guest" + provision_vm_datastore: "datastore1" + +# Provision VMs from template +provision_vms_from_template: + - provision_vm_name: "qe-provision-vm-from-template" + provision_vm_state: "poweredon" + provision_vm_template: "{{ provision_vms_template[0].provision_vm_name }}" + provision_vm_datastore: "datastore1" + +provision_vms: +# RHEL9 VM + - provision_vm_name: "qe-provision-vm-rhel-9" + provision_vm_state: "poweredoff" + provision_vm_cdrom: + - controller_number: 0 + unit_number: 0 + state: present + type: iso + iso_path: "[datastore1] ISO/rhel-9.3-x86_64-dvd.iso" + provision_vm_networks: + - name: "VM Network" + device_type: "vmxnet3" + mac: "00:50:56:bd:d2:9e" + type: "dhcp" + provision_vm_resource_pool: null + provision_vm_disk: + - size_gb: 50 + type: thin + datastore: "datastore1" + provision_vm_hardware: + memory_mb: 2000 + num_cpus: 4 + boot_firmware: efi + secure_boot: true + provision_vm_guest_id: "rhel9_64Guest" + provision_vm_datastore: "datastore1" +# RHEL8 VM + - provision_vm_name: "qe-provision-vm-rhel-8" + provision_vm_state: "poweredon" + provision_vm_cdrom: + - controller_number: 0 + unit_number: 0 + state: present + type: iso + iso_path: "[datastore1] ISO/rhel-8.9-x86_64-boot.iso" + provision_vm_networks: + - name: "VM Network" + device_type: "vmxnet3" + mac: "00:50:56:bd:d2:9e" + type: "dhcp" + provision_vm_resource_pool: null + provision_vm_disk: + - size_gb: 50 + type: thin + datastore: "datastore1" + provision_vm_hardware: + memory_mb: 2000 + num_cpus: 4 + boot_firmware: efi + secure_boot: true + provision_vm_guest_id: "rhel8_64Guest" + provision_vm_datastore: "datastore1" + +vm_to_update: "{{ provision_vms[0] }}" +vm_update_name: "{{ vm_to_update.provision_vm_name }}" +vm_update_datastore: "{{ vm_to_update.provision_vm_datastore }}" + +vm_names_to_update: + - vm_updated_name + - "{{ vm_update_name }}" + +vm_states: +# - "rebootguest" # error msg: "VMware tools should be installed for guest shutdown/reboot" +# - "shutdownguest" # error msg: "VMware tools should be installed for guest shutdown/reboot" +# - "restarted" # test failing because after restart the status is poweredOn again + - "poweredon" + - "suspended" + - "poweredoff" + +vm_updated_hardware: + memory_mb: 2048 + num_cpus: 6 + num_cpu_cores_per_socket: 2 + boot_firmware: efi + secure_boot: true + +vswitch_name: vSwitch0 +portgroup_name: qe-network + +vm_network_to_add: + - name: "{{ portgroup_name }}" + device_type: "vmxnet3" + mac: "00:50:a6:b5:b2:3c" + type: "dhcp" + +vm_updated_networks: "{{ vm_to_update.provision_vm_networks + vm_network_to_add }}" + +vm_enlarge_disk: + - size_gb: "{{ vm_to_update.provision_vm_disk[0].size_gb + 10 }}" + type: "{{ vm_to_update.provision_vm_disk[0].type }}" + datastore: "{{ vm_to_update.provision_vm_disk[0].datastore }}" + +vm_disk_to_add: + - size_gb: 10 + type: thin + datastore: "datastore1" + +vm_add_disk: "{{ vm_to_update.provision_vm_disk + vm_disk_to_add }}" + +guest_fullnames: + rhel8_64Guest: "Red Hat Enterprise Linux 8 (64-bit)" + rhel9_64Guest: "Red Hat Enterprise Linux 9 (64-bit)" + +vm_updated_guest_id: "rhel8_64Guest" +vm_updated_cdrom: + - controller_number: 0 + unit_number: 0 + state: present + type: iso + iso_path: "[datastore1] ISO/rhel-8.9-x86_64-boot.iso" + +vm_update_os_customization: + existing_vm: true + hostname: my.customized.vm + timezone: Europe/Paris + +gib_to_bytes: 1073741824