diff --git a/tests/e2e/molecule/provision_vm/destroy.yml b/tests/e2e/molecule/provision_vm/destroy.yml new file mode 100644 index 00000000..6a9d64cd --- /dev/null +++ b/tests/e2e/molecule/provision_vm/destroy.yml @@ -0,0 +1,24 @@ +--- +- name: Deprovision VM + hosts: localhost + gather_facts: false + tasks: + - name: Include vSphere datacenter creds + ansible.builtin.include_vars: + file: ../vault_files/vsphere_creds.yml + + - name: Include deprovision VM vars + ansible.builtin.include_vars: + file: vars/deprovision_vm_vars.yml + + - name: Deprovision a VM + ansible.builtin.import_role: + name: provision_vm + vars: + provision_vm_hostname: "{{ vCenter_hostname }}" + provision_vm_username: "{{ vCenter_username }}" + provision_vm_password: "{{ vCenter_password }}" + + - name: Verify that VM is absent + ansible.builtin.include_tasks: + file: post_validations/verify_vm_deprovisioning.yml diff --git a/tests/e2e/molecule/provision_vm/molecule.yml b/tests/e2e/molecule/provision_vm/molecule.yml index 96178f70..b67500f7 100644 --- a/tests/e2e/molecule/provision_vm/molecule.yml +++ b/tests/e2e/molecule/provision_vm/molecule.yml @@ -2,8 +2,8 @@ dependency: name: galaxy -# driver: -# name: docker +driver: + name: podman platforms: - name: instance @@ -26,10 +26,11 @@ provisioner: ANSIBLE_ROLES_PATH: "../../../../roles" config_options: defaults: - vault_password_file: ${HOME}/vsphere_crds_vault_pass.txt + vault_password_file: ${HOME}/vault.pass callback_whitelist: junit playbooks: converge: ../converge.yml + destroy: destroy.yml verifier: name: ansible diff --git a/tests/e2e/molecule/provision_vm/post_validations/verify_vm_deprovisioning.yml b/tests/e2e/molecule/provision_vm/post_validations/verify_vm_deprovisioning.yml new file mode 100644 index 00000000..66054c85 --- /dev/null +++ b/tests/e2e/molecule/provision_vm/post_validations/verify_vm_deprovisioning.yml @@ -0,0 +1,19 @@ +--- +- name: Verify Deprovisioned VM + ansible.builtin.include_vars: + file: ../vars/deprovision_vm_vars.yml + +- name: Check that VM does not exist + community.vmware.vmware_vm_info: + hostname: "{{ vCenter_hostname }}" + username: "{{ vCenter_username }}" + password: "{{ vCenter_password }}" + validate_certs: "{{ provision_vm_validate_certs }}" + vm_name: "{{ provision_vm_name }}" + register: vm_info + ignore_errors: true + +- name: Fail the task if the VM exists + ansible.builtin.fail: + msg: "Provisioned VM still exists" + when: not vm_info.failed diff --git a/tests/e2e/molecule/provision_vm/post_validations/verify_vm_post_provisioning.yml b/tests/e2e/molecule/provision_vm/post_validations/verify_vm_post_provisioning.yml index 16191236..908567ab 100644 --- a/tests/e2e/molecule/provision_vm/post_validations/verify_vm_post_provisioning.yml +++ b/tests/e2e/molecule/provision_vm/post_validations/verify_vm_post_provisioning.yml @@ -5,9 +5,9 @@ - name: Check VM existence community.vmware.vmware_vm_info: - hostname: "{{ provision_vm_hostname }}" - username: "{{ provision_vm_username }}" - password: "{{ provision_vm_password }}" + hostname: "{{ vCenter_hostname }}" + username: "{{ vCenter_username }}" + password: "{{ vCenter_password }}" validate_certs: "{{ provision_vm_validate_certs }}" vm_name: "{{ provision_vm_name }}" register: vm_info diff --git a/tests/e2e/molecule/provision_vm/scenarios/basic_provision_vm.yml b/tests/e2e/molecule/provision_vm/scenarios/basic_provision_vm.yml index 6a5d7d9d..cdb21a1b 100644 --- a/tests/e2e/molecule/provision_vm/scenarios/basic_provision_vm.yml +++ b/tests/e2e/molecule/provision_vm/scenarios/basic_provision_vm.yml @@ -7,6 +7,10 @@ - name: Provision a VM ansible.builtin.import_role: name: provision_vm + vars: + provision_vm_hostname: "{{ vCenter_hostname }}" + provision_vm_username: "{{ vCenter_username }}" + provision_vm_password: "{{ vCenter_password }}" - name: Verify Provisioned VM ansible.builtin.include_tasks: diff --git a/tests/e2e/molecule/provision_vm/vars/deprovision_vm_vars.yml b/tests/e2e/molecule/provision_vm/vars/deprovision_vm_vars.yml new file mode 100644 index 00000000..87382d72 --- /dev/null +++ b/tests/e2e/molecule/provision_vm/vars/deprovision_vm_vars.yml @@ -0,0 +1,8 @@ +# vars.yaml +provision_vm_validate_certs: false +provision_vm_cluster: "nestedcluster" +provision_vm_folder: "/nesteddatacenter/vm" +provision_vm_datacenter: "nesteddatacenter" +provision_vm_name: "qe-provision-vm" +provision_vm_state: "absent" +provision_vm_force: true diff --git a/tests/e2e/molecule/provision_vm/vars/vars.yml b/tests/e2e/molecule/provision_vm/vars/vars.yml index c8384d67..d469a7fa 100644 --- a/tests/e2e/molecule/provision_vm/vars/vars.yml +++ b/tests/e2e/molecule/provision_vm/vars/vars.yml @@ -3,7 +3,7 @@ provision_vm_validate_certs: false provision_vm_cluster: "nestedcluster" provision_vm_folder: "/nesteddatacenter/vm" provision_vm_datacenter: "nesteddatacenter" -provision_vm_name: "smiron-provision-vm-2" +provision_vm_name: "qe-provision-vm" provision_vm_state: "poweredon" provision_vm_cdrom: - controller_number: 0 @@ -35,6 +35,6 @@ provision_vm_hardware: num_cpus: 4 boot_firmware: efi secure_boot: true -# provision_vm_guest_id: "rhel9_64Guest" +provision_vm_guest_id: "rhel9_64Guest" provision_vm_datastore: "Datastore-host1" -provision_vm_template: "provision-vm-template" +# provision_vm_template: "provision-vm-template" diff --git a/tests/e2e/molecule/vault_files/vsphere_creds.yml b/tests/e2e/molecule/vault_files/vsphere_creds.yml index 87629e61..c3c63f37 100644 --- a/tests/e2e/molecule/vault_files/vsphere_creds.yml +++ b/tests/e2e/molecule/vault_files/vsphere_creds.yml @@ -1,14 +1,14 @@ $ANSIBLE_VAULT;1.1;AES256 -62353361643765386533316139656438306166613765336366376563313666666538663838306336 -3335623861613631303431623730366564663635643863640a396435306332373639326232643531 -63356366366232623830383762653230626139343731366466623262626132623736663732366562 -3237326363346263360a623535353534343365663431616537663634353563383639313334343463 -35353637373237386133633234383939356537316632376139613366376132323436306464313439 -34373939333930353931356432356361376437383338313732663866373663623865613166626632 -36306564336464346164656431363865633465613864373231303538333935356434353966383164 -65663566613333396435363866623066623530306662646162353665613034663434336261313865 -36353738396334633263343766623736343362393765333030386563343563393138363035373135 -31613839636538373339346266333863336139363534393339383361376232303939313036633263 -66396438613030613433376334663637616566326566643162363430326239316334623534316437 -31613962633362383132653166656561366535323236656363333736313536623663386434313234 -30646130353664346530383264323433313666393162373261373465336266623032 \ No newline at end of file +39656266323032616132376530316632633133316234363564313635353064363365343431313631 +6530383432643133663361623536353634386230326338610a653731663737653334616638353462 +39313462313966653832376162353139306463323635383065653632653164313533623866666230 +3762616333306463360a653333663966613565633231343034386634636366333530346563653166 +32623366626334363361323661346230333135333062613964613766336337313739633333386235 +38313235366463343531623362666635396439613035636563333366333336376335373263326534 +36383866383766623937636461313130616166663536313361393736343230656239333230313338 +31366535313239666535326432326431366435393335393239326535616161336437313563376462 +36623061343537306231373366333564306165363931633434353563663931333331306538656362 +63323038343139316638386137366562346439643466363933353435396632656432353636636463 +65373135663337643262633630313261613065366237613638333430303864333733643964656338 +39363835303966323561313237383034326330373463663738623530313666303763393731393432 +3233 diff --git a/tests/integration/requirements.yml b/tests/integration/requirements.yml index a7276e35..38e398af 100644 --- a/tests/integration/requirements.yml +++ b/tests/integration/requirements.yml @@ -1,4 +1,6 @@ collections: - name: community.vmware + version: "4.2.0" - name: vmware.vmware_rest + version: "2.3.1" - name: containers.podman