From 27665554de4a35ec678f5c63b529ccaa7d99bc74 Mon Sep 17 00:00:00 2001 From: michalg91 <63045346+michalg91@users.noreply.github.com> Date: Sat, 10 Dec 2022 04:32:43 +0100 Subject: [PATCH] fix: Remove cloned ide2 before creating new one (#174) (#175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Remove cloned ide2 before creating new one (#174) * add test case to `/examples` Co-authored-by: Michał Gawryś Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- example/resource_virtual_environment_vm.tf | 7 +++++++ proxmoxtf/resource_virtual_environment_vm.go | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/example/resource_virtual_environment_vm.tf b/example/resource_virtual_environment_vm.tf index d1ed7b3e..e06284b3 100644 --- a/example/resource_virtual_environment_vm.tf +++ b/example/resource_virtual_environment_vm.tf @@ -83,6 +83,13 @@ resource "proxmox_virtual_environment_vm" "example" { "echo Welcome to $(hostname)!", ] } + + initialization { + dns { + server = "8.8.8.8" + } + } + } output "resource_proxmox_virtual_environment_vm_example_id" { diff --git a/proxmoxtf/resource_virtual_environment_vm.go b/proxmoxtf/resource_virtual_environment_vm.go index 48ac31eb..dd196ee0 100644 --- a/proxmoxtf/resource_virtual_environment_vm.go +++ b/proxmoxtf/resource_virtual_environment_vm.go @@ -1323,7 +1323,12 @@ func resourceVirtualEnvironmentVMCreateClone(ctx context.Context, d *schema.Reso Media: &cdromCloudInitMedia, }, } - + ciUpdateBody := &proxmox.VirtualEnvironmentVMUpdateRequestBody{} + ciUpdateBody.Delete = append(ciUpdateBody.Delete, "ide2") + err = veClient.UpdateVM(ctx, nodeName, vmID, ciUpdateBody) + if err != nil { + return diag.FromErr(err) + } initializationConfig, err := resourceVirtualEnvironmentVMGetCloudInitConfig(d) if err != nil { return diag.FromErr(err)