diff --git a/tests/integration/targets/vmware_folder_template_from_vm/defaults/main.yml b/tests/integration/targets/vmware_folder_template_from_vm/defaults/main.yml index 795bf754..f6cd182c 100644 --- a/tests/integration/targets/vmware_folder_template_from_vm/defaults/main.yml +++ b/tests/integration/targets/vmware_folder_template_from_vm/defaults/main.yml @@ -1,11 +1,18 @@ -vcenter_port: 443 -run_on_simulator: false +--- +vcenter_hostname: "127.0.0.1" +vcenter_username: "user" +vcenter_password: "pass" +vcenter_port: 8989 +vcenter_datacenter_name: DC0 +vcenter_cluster_name: DC0_C0 + +run_on_simulator: true template_folder: e2e-qe +vm_name: DC0_H0_VM0 +vm_name_match: first +template_name: "{{ vm_name }}_template" -vm: test-folder_template -vm_cluster: "Eco-Cluster" -vm_datacenter: "Eco-Datacenter" vm_guest_id: "rhel8_64Guest" vm_disk: - size_gb: 10 diff --git a/tests/integration/targets/vmware_folder_template_from_vm/run.yml b/tests/integration/targets/vmware_folder_template_from_vm/run.yml index 4510ac6f..8d5dcc36 100644 --- a/tests/integration/targets/vmware_folder_template_from_vm/run.yml +++ b/tests/integration/targets/vmware_folder_template_from_vm/run.yml @@ -2,13 +2,25 @@ gather_facts: no collections: - community.general - vars_files: - - vars.yml + tasks: + - name: Import eco-vcenter test vars + ansible.builtin.include_vars: + file: "{{ item }}" + loop: + - ../../integration_config.yml + - ../../group_vars.yml + - vars.yml + tags: eco-vcenter-ci + - name: Vcsim ansible.builtin.import_role: name: prepare_vcsim + tags: integration-ci - name: Import vmware_folder_template role ansible.builtin.import_role: name: vmware_folder_template_from_vm + tags: + - integration-ci + - eco-vcenter-ci diff --git a/tests/integration/targets/vmware_folder_template_from_vm/runme.sh b/tests/integration/targets/vmware_folder_template_from_vm/runme.sh deleted file mode 100755 index a4c36631..00000000 --- a/tests/integration/targets/vmware_folder_template_from_vm/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/vmware_folder_template_from_vm/tasks/main.yml b/tests/integration/targets/vmware_folder_template_from_vm/tasks/main.yml index 86266596..98fe5081 100644 --- a/tests/integration/targets/vmware_folder_template_from_vm/tasks/main.yml +++ b/tests/integration/targets/vmware_folder_template_from_vm/tasks/main.yml @@ -1,5 +1,7 @@ --- -- block: +- name: Test On Simulator + when: run_on_simulator + block: - name: "Test setup: Create Folder" community.vmware.vcenter_folder: validate_certs: false @@ -7,41 +9,54 @@ username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" port: "{{ vcenter_port }}" - datacenter: "{{ vm_datacenter }}" + datacenter: "{{ vcenter_datacenter_name }}" folder_name: "{{ template_folder }}" folder_type: vm state: present - when: run_on_simulator - - name: "Test setup: Create VM guest {{ vm }}" + - name: "Test setup: Power Off VM guest {{ vm_name }}" community.vmware.vmware_guest: validate_certs: false hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - cluster: "{{ vm_cluster }}" + cluster: "{{ vcenter_cluster_name }}" + datacenter: "{{ vcenter_datacenter_name }}" port: "{{ vcenter_port }}" - datacenter: "{{ vm_datacenter }}" - folder: "{{ template_folder }}" - state: present - name: "{{ vm }}" - disk: "{{ vm_disk }}" - guest_id: "{{ vm_guest_id }}" - hardware: "{{ vm_hardware }}" - when: not run_on_simulator + state: poweredoff + name: "{{ vm_name }}" - - name: "Test setup: Power Off VM guest {{ vm }}" + - name: Create template from vm in vcenter folder + vmware.vmware.folder_template_from_vm: + validate_certs: false + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ vcenter_datacenter_name }}" + port: "{{ vcenter_port }}" + template_folder: "{{ template_folder }}" + vm_name: "{{ vm_name }}" + template_name: "{{ template_name }}" + register: __res + +- name: Run On VCenter + when: not run_on_simulator + block: + - name: "Test setup: Create VM guest {{ vm }}" community.vmware.vmware_guest: validate_certs: false hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - cluster: "{{ vm_cluster }}" - datacenter: "{{ vm_datacenter }}" + cluster: "{{ vcenter_cluster_name }}" port: "{{ vcenter_port }}" - state: poweredoff - name: "{{ vm }}" - when: run_on_simulator + datacenter: "{{ vcenter_datacenter_name }}" + folder: "{{ template_folder }}" + state: present + name: "{{ vm_name }}" + disk: "{{ vm_disk }}" + guest_id: "{{ vm_guest_id }}" + hardware: "{{ vm_hardware }}" - name: Create template from vm in vcenter folder vmware.vmware.folder_template_from_vm: @@ -49,39 +64,38 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - datacenter: "{{ vm_datacenter }}" + datacenter: "{{ vcenter_datacenter_name }}" port: "{{ vcenter_port }}" template_folder: "{{ template_folder }}" - vm_name: "{{ vm }}" - template_name: "test_template" + vm_name: "{{ vm_name }}" + template_name: "{{ template_name }}" register: __res always: - - name: "Test teardown: Destroy VM guest {{ vm }}" + - name: "Test teardown: Destroy VM guest {{ vm_name }}" community.vmware.vmware_guest: validate_certs: false hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - cluster: "{{ vm_cluster }}" + cluster: "{{ vcenter_cluster_name }}" port: "{{ vcenter_port }}" - datacenter: "{{ vm_datacenter }}" + datacenter: "{{ vcenter_datacenter_name }}" folder: "{{ vm_folder }}" state: absent force: true - name: "{{ vm }}" - when: not run_on_simulator - - name: "Test teardown: Destroy VM template {{ vm }}" + name: "{{ vm_name }}" + + - name: "Test teardown: Destroy VM template {{ template_name }}" community.vmware.vmware_guest: validate_certs: false hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - cluster: "{{ vm_cluster }}" + cluster: "{{ vcenter_cluster_name }}" port: "{{ vcenter_port }}" - datacenter: "{{ vm_datacenter }}" + datacenter: "{{ vcenter_datacenter_name }}" folder: "{{ vm_folder }}" state: absent force: true - name: "{{ vm }}_template" - when: not run_on_simulator + name: "{{ template_name }}" diff --git a/tests/integration/targets/vmware_folder_template_from_vm/vars.yml b/tests/integration/targets/vmware_folder_template_from_vm/vars.yml index 493ef902..208c070b 100644 --- a/tests/integration/targets/vmware_folder_template_from_vm/vars.yml +++ b/tests/integration/targets/vmware_folder_template_from_vm/vars.yml @@ -1,9 +1,5 @@ -vcenter_hostname: "127.0.0.1" -vcenter_username: "user" -vcenter_password: "pass" -vcenter_port: 8989 -vm_cluster: DC0_C0 -vm_datacenter: DC0 -vm_folder: test -run_on_simulator: true -vm: DC0_H0_VM0 +--- +run_on_simulator: false +template_folder: e2e-qe +vm_name: folder_template_from_vm_test +vm_name_match: first