diff --git a/docs/resources/vm_qemu.md b/docs/resources/vm_qemu.md index eff7fa57..0ed8c524 100644 --- a/docs/resources/vm_qemu.md +++ b/docs/resources/vm_qemu.md @@ -100,6 +100,7 @@ The following arguments are supported in the top level resource block. | `startup` | `string` | `""` | The [startup and shutdown behaviour](https://pve.proxmox.com/pve-docs/pve-admin-guide.html#pct_startup_and_shutdown) | | `vm_state` | `string` | `"running"` | The desired state of the VM, options are `running`, `stopped` and `started`. Do note that `started` will only start the vm on creation and won't fully manage the power state unlike `running` and `stopped` do. | | `oncreate` | `bool` | `true` | Whether to have the VM startup after the VM is created (deprecated, use `vm_state` instead) | +| `protection` | `bool` | `false` | Enable/disable the VM protection from being removed. The default value of `false` indicates the VM is removable. | | `tablet` | `bool` | `true` | Enable/disable the USB tablet device. This device is usually needed to allow absolute mouse positioning with VNC. | | `boot` | `str` | | The boot order for the VM. For example: `order=scsi0;ide2;net0`. The deprecated `legacy=` syntax is no longer supported. See the `boot` option in the [Proxmox manual](https://pve.proxmox.com/wiki/Manual:_qm.conf#_options) for more information. | | `bootdisk` | `str` | | Enable booting from specified disk. You shouldn't need to change it under most circumstances. | diff --git a/examples/pxe_example.tf b/examples/pxe_example.tf index f5ba26cd..fbcaee0d 100644 --- a/examples/pxe_example.tf +++ b/examples/pxe_example.tf @@ -45,6 +45,7 @@ resource "proxmox_vm_qemu" "pxe-example" { qemu_os = "l26" scsihw = "virtio-scsi-pci" sockets = 1 + protection = false tablet = true target_node = "test" vcpus = 0 diff --git a/proxmox/resource_vm_qemu.go b/proxmox/resource_vm_qemu.go index c6a5b446..904d693f 100755 --- a/proxmox/resource_vm_qemu.go +++ b/proxmox/resource_vm_qemu.go @@ -147,6 +147,12 @@ func resourceVmQemu() *schema.Resource { // Default: "", Description: "Startup order of the VM", }, + "protection": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Protect VM from being removed", + }, "tablet": { Type: schema.TypeBool, Optional: true, @@ -838,6 +844,7 @@ func resourceVmQemuCreate(ctx context.Context, d *schema.ResourceData, meta inte Bios: d.Get("bios").(string), Onboot: BoolPointer(d.Get("onboot").(bool)), Startup: d.Get("startup").(string), + Protection: BoolPointer(d.Get("protection").(bool)), Tablet: BoolPointer(d.Get("tablet").(bool)), Boot: d.Get("boot").(string), BootDisk: d.Get("bootdisk").(string), @@ -1114,6 +1121,7 @@ func resourceVmQemuUpdate(ctx context.Context, d *schema.ResourceData, meta inte Bios: d.Get("bios").(string), Onboot: BoolPointer(d.Get("onboot").(bool)), Startup: d.Get("startup").(string), + Protection: BoolPointer(d.Get("protection").(bool)), Tablet: BoolPointer(d.Get("tablet").(bool)), Boot: d.Get("boot").(string), BootDisk: d.Get("bootdisk").(string), @@ -1427,6 +1435,7 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("bios", config.Bios) d.Set("onboot", config.Onboot) d.Set("startup", config.Startup) + d.Set("protection", config.Protection) d.Set("tablet", config.Tablet) d.Set("boot", config.Boot) d.Set("bootdisk", config.BootDisk)