-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable provision virtual esxi integration target test to run on eco v…
…center
- Loading branch information
1 parent
89531a7
commit a9434d1
Showing
10 changed files
with
201 additions
and
27 deletions.
There are no files selected for viewing
Binary file not shown.
13 changes: 0 additions & 13 deletions
13
tests/integration/targets/provision_virtual_esxi_test/run.yml
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
tests/integration/targets/provision_virtual_esxi_test/runme.sh
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
tests/integration/targets/provision_virtual_esxi_test/tasks/main.yml
This file was deleted.
Oops, something went wrong.
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
tests/integration/targets/vmware_ops_provision_virtual_esxi_test/run.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
- hosts: localhost | ||
gather_facts: false | ||
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 virtual ESXi role | ||
ansible.builtin.include_role: | ||
name: vmware_ops_provision_virtual_esxi_test | ||
tags: | ||
- integration-ci | ||
- eco-vcenter-ci |
64 changes: 64 additions & 0 deletions
64
tests/integration/targets/vmware_ops_provision_virtual_esxi_test/tasks/cleanup_esxi.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
- name: Power off ESXi VM | ||
ansible.builtin.include_role: | ||
name: cloud.vmware_ops.provision_vm | ||
vars: | ||
provision_vm_hostname: "{{ provision_virtual_esxi_hostname }}" | ||
provision_vm_username: "{{ provision_virtual_esxi_username }}" | ||
provision_vm_password: "{{ provision_virtual_esxi_password }}" | ||
provision_vm_validate_certs: false | ||
provision_vm_port: "{{ provision_virtual_esxi_port }}" | ||
provision_vm_cluster: "{{ provision_virtual_esxi_cluster }}" | ||
provision_vm_datacenter: "{{ provision_virtual_esxi_datacenter }}" | ||
provision_vm_name: "{{ provision_virtual_esxi_vms[0].name }}" | ||
provision_vm_state: "poweredoff" | ||
|
||
- name: Cleanup Virtual Esxi | ||
ansible.builtin.include_role: | ||
name: cloud.vmware_ops.provision_vm | ||
vars: | ||
provision_vm_hostname: "{{ provision_virtual_esxi_hostname }}" | ||
provision_vm_username: "{{ provision_virtual_esxi_username }}" | ||
provision_vm_password: "{{ provision_virtual_esxi_password }}" | ||
provision_vm_validate_certs: false | ||
provision_vm_port: "{{ provision_virtual_esxi_port }}" | ||
provision_vm_cluster: "{{ provision_virtual_esxi_cluster }}" | ||
provision_vm_datacenter: "{{ provision_virtual_esxi_datacenter }}" | ||
provision_vm_name: "{{ provision_virtual_esxi_vms[0].name }}" | ||
provision_vm_state: "absent" | ||
provision_vm_force: true | ||
|
||
- name: Check if ESXi VM is down | ||
command: ping -c 1 -W 5 {{ esxi_host.instance.ipv4 }} | ||
register: ping_check_result | ||
ignore_errors: true | ||
|
||
- name: Set fact if ping is not available | ||
set_fact: | ||
ping_not_available: "{{ ping_check_result.rc != 0 }}" | ||
|
||
- name: Verify VM absence in vCenter | ||
community.vmware.vmware_guest_info: | ||
hostname: "{{ vcenter_hostname }}" | ||
username: "{{ vcenter_username }}" | ||
password: "{{ vcenter_password }}" | ||
datacenter: "{{ provision_virtual_esxi_datacenter }}" | ||
validate_certs: no | ||
name: "{{ provision_virtual_esxi_vms[0].name }}" | ||
register: vm_info | ||
ignore_errors: true | ||
|
||
- name: Fail if VM is still present in vCenter | ||
fail: | ||
msg: "The VM {{ provision_virtual_esxi_vms[0].name }} is still present in vCenter." | ||
when: vm_info.instance is defined | ||
|
||
- name: Cleanup Resource Pool | ||
community.vmware.vmware_resource_pool: | ||
hostname: "{{ provision_virtual_esxi_hostname }}" | ||
username: "{{ provision_virtual_esxi_username }}" | ||
password: "{{ provision_virtual_esxi_password }}" | ||
validate_certs: "{{ provision_virtual_esxi_validate_certs }}" | ||
datacenter: "{{ provision_virtual_esxi_datacenter }}" | ||
cluster: "{{ provision_virtual_esxi_cluster }}" | ||
resource_pool: "{{ resource_pool_name }}" | ||
state: absent |
83 changes: 83 additions & 0 deletions
83
tests/integration/targets/vmware_ops_provision_virtual_esxi_test/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
- name: Test Virtual Esxi Provisioning on Simulator | ||
tags: integration-ci | ||
ansible.builtin.import_role: | ||
name: cloud.vmware_ops.provision_virtual_esxi | ||
|
||
- name: Test Virtual Esxi Provisioning on vCenter Env | ||
tags: eco-vcenter-ci | ||
block: | ||
- name: Add Resource Pool | ||
community.vmware.vmware_resource_pool: | ||
hostname: "{{ provision_virtual_esxi_hostname }}" | ||
username: "{{ provision_virtual_esxi_username }}" | ||
password: "{{ provision_virtual_esxi_password }}" | ||
datacenter: "{{ provision_virtual_esxi_datacenter }}" | ||
cluster: "{{ provision_virtual_esxi_cluster }}" | ||
validate_certs: "{{ provision_virtual_esxi_validate_certs }}" | ||
resource_pool: "{{ resource_pool_name }}" | ||
state: present | ||
|
||
- name: Provision Virtual Esxi | ||
ansible.builtin.import_role: | ||
name: cloud.vmware_ops.provision_virtual_esxi | ||
vars: | ||
provision_virtual_esxi_resource_pool: "{{ resource_pool_name }}" | ||
|
||
- name: Wait until ESXi VM is powered off after OS installation | ||
community.vmware.vmware_guest_info: | ||
hostname: "{{ provision_virtual_esxi_hostname }}" | ||
username: "{{ provision_virtual_esxi_username }}" | ||
password: "{{ provision_virtual_esxi_password }}" | ||
port: "{{ provision_virtual_esxi_port }}" | ||
datacenter: "{{ provision_virtual_esxi_datacenter }}" | ||
validate_certs: "{{ provision_virtual_esxi_validate_certs }}" | ||
name: "{{ provision_virtual_esxi_vms[0].name }}" | ||
register: _esxi_power_status | ||
until: _esxi_power_status.instance.hw_power_status == 'poweredOff' | ||
retries: 30 | ||
delay: 20 | ||
|
||
- name: Power on ESXi VM if it is off | ||
ansible.builtin.import_role: | ||
name: cloud.vmware_ops.provision_vm | ||
vars: | ||
provision_vm_hostname: "{{ provision_virtual_esxi_hostname }}" | ||
provision_vm_username: "{{ provision_virtual_esxi_username }}" | ||
provision_vm_password: "{{ provision_virtual_esxi_password }}" | ||
provision_vm_validate_certs: false | ||
provision_vm_port: "{{ provision_virtual_esxi_port }}" | ||
provision_vm_cluster: "{{ provision_virtual_esxi_cluster }}" | ||
provision_vm_datacenter: "{{ provision_virtual_esxi_datacenter }}" | ||
provision_vm_name: "{{ provision_virtual_esxi_vms[0].name }}" | ||
provision_vm_state: "poweredon" | ||
|
||
- name: Wait until ESXi VM has an IP address | ||
community.vmware.vmware_guest_info: | ||
hostname: "{{ provision_virtual_esxi_hostname }}" | ||
username: "{{ provision_virtual_esxi_username }}" | ||
password: "{{ provision_virtual_esxi_password }}" | ||
port: "{{ provision_virtual_esxi_port }}" | ||
datacenter: "{{ provision_virtual_esxi_datacenter }}" | ||
validate_certs: "{{ provision_virtual_esxi_validate_certs }}" | ||
name: "{{ provision_virtual_esxi_vms[0].name }}" | ||
register: _esxi_host_check | ||
until: _esxi_host_check.instance.ipv4 is defined and _esxi_host_check.instance.ipv4 is not none | ||
retries: 30 | ||
delay: 10 | ||
|
||
- name: Set fact for esxi instance | ||
set_fact: | ||
esxi_host: "{{ _esxi_host_check }}" | ||
|
||
- name: Check if VM is up | ||
wait_for: | ||
host: "{{ esxi_host.instance.ipv4 }}" | ||
port: 22 | ||
delay: 10 | ||
timeout: 300 | ||
state: started | ||
|
||
always: | ||
- name: "Call cleanup playbook" | ||
ansible.builtin.include_tasks: cleanup_esxi.yml |
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
tests/integration/targets/vmware_ops_provision_virtual_esxi_test/vars/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
provision_virtual_esxi_hostname: "{{ vcenter_hostname }}" | ||
provision_virtual_esxi_username: "{{ vcenter_username }}" | ||
provision_virtual_esxi_password: "{{ vcenter_password }}" | ||
provision_virtual_esxi_validate_certs: false | ||
provision_virtual_esxi_port: 443 | ||
provision_virtual_esxi_cluster: "Eco-Cluster" | ||
provision_virtual_esxi_folder: "e2e-qe" | ||
provision_virtual_esxi_datacenter: "Eco-Datacenter" | ||
provision_virtual_esxi_datastore_iso_path: "[eco-nfs-datastore-iso] esxi_8.iso" | ||
resource_pool_name: ci-resource-pool-test | ||
provision_virtual_esxi_vms: | ||
- name: ci-esxi-test-1 | ||
network_name: "VM Network" | ||
provision_virtual_esxi_networks: | ||
- name: "{{ network_name }}" | ||
device_type: "vmxnet3" | ||
type: "dhcp" | ||
mac: "00:50:56:8b:95:ff" | ||
provision_virtual_esxi_disks: | ||
- size_gb: 100 | ||
type: thin | ||
datastore: datastore1 | ||
provision_virtual_esxi_memory_mb: 10000 | ||
provision_virtual_esxi_cpus: 8 | ||
provision_vm_datastore: "datastore1" |