From cd7dc7419f2b39dc3bd97ef39c9e4b11269ff544 Mon Sep 17 00:00:00 2001 From: George Ghawali Date: Mon, 16 Dec 2024 14:54:27 +0200 Subject: [PATCH 1/2] Adding test case to create VM using unattend xml file --- .../tasks/create_delete_info_vm.yml | 40 +++++++++++++++++++ .../prepare_env/playbooks/prepare_env.yml | 7 ++++ 2 files changed, 47 insertions(+) diff --git a/tests/integration/targets/ntnx_vms_v2/tasks/create_delete_info_vm.yml b/tests/integration/targets/ntnx_vms_v2/tasks/create_delete_info_vm.yml index a8bd5851..f26150dd 100644 --- a/tests/integration/targets/ntnx_vms_v2/tasks/create_delete_info_vm.yml +++ b/tests/integration/targets/ntnx_vms_v2/tasks/create_delete_info_vm.yml @@ -537,6 +537,46 @@ ansible.builtin.set_fact: todelete: '{{ todelete + [result["ext_id"]] }}' ######################################################################## + +- name: Read content from file + ansible.builtin.set_fact: + xml_file_content: "{{ lookup('file', unattendxml.dest + '/unattendxml.txt') }}" + +- name: Create vm with windows unattend xml file + ntnx_vms_v2: + name: "{{ vm_name }}" + description: ansible test + cluster: + ext_id: "{{ cluster.uuid }}" + guest_customization: + config: + sysprep: + install_type: "FRESH" + sysprep_script: + unattendxml: + value: "{{ xml_file_content }}" + register: result + ignore_errors: true + +- name: Creation status + ansible.builtin.assert: + that: + - result.response is defined + - result.changed == True + - result.failed == False + - result.response.ext_id is defined + - result.response.cluster.ext_id == "{{ cluster.uuid }}" + - result.response.name == "{{ vm_name }}" + - result.response.cd_roms[0] is defined + - result.response.cd_roms[0].iso_type == "GUEST_CUSTOMIZATION" + fail_msg: " Unable to create VM with windows unattend xml file " + success_msg: " VM with windows unattend xml file created successfully " + +- name: Adding VM to todelete list + ansible.builtin.set_fact: + todelete: '{{ todelete + [result["ext_id"]] }}' + +######################################################################## - name: List all VMs ntnx_vms_info_v2: register: result diff --git a/tests/integration/targets/prepare_env/playbooks/prepare_env.yml b/tests/integration/targets/prepare_env/playbooks/prepare_env.yml index 045cc5b0..ce6f5c67 100644 --- a/tests/integration/targets/prepare_env/playbooks/prepare_env.yml +++ b/tests/integration/targets/prepare_env/playbooks/prepare_env.yml @@ -216,3 +216,10 @@ mode: "0644" url: "{{ xml_content.url }}" dest: "{{ xml_content.dest }}" + + - name: Downloading unattendxml file for windows tests + ansible.builtin.get_url: + mode: "0644" + url: "{{ unattendxml.url }}" + dest: "{{ unattendxml.dest }}" + From 78b75c11b03dd423aec4bcdfc1370eae2d315393 Mon Sep 17 00:00:00 2001 From: George Ghawali Date: Tue, 17 Dec 2024 09:51:50 +0200 Subject: [PATCH 2/2] Ansible lint fix after adding download unattendxml file task in prepare_env --- tests/integration/targets/prepare_env/playbooks/prepare_env.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/targets/prepare_env/playbooks/prepare_env.yml b/tests/integration/targets/prepare_env/playbooks/prepare_env.yml index ce6f5c67..1159d1c7 100644 --- a/tests/integration/targets/prepare_env/playbooks/prepare_env.yml +++ b/tests/integration/targets/prepare_env/playbooks/prepare_env.yml @@ -222,4 +222,3 @@ mode: "0644" url: "{{ unattendxml.url }}" dest: "{{ unattendxml.dest }}" -