mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 18:42:58 +00:00
feat(vm): add optional reboot_after_update
configuration flag (#1777)
* feat(vm): add optional reboot after update configuration - Add `reboot_after_update` parameter to VM resource - Update documentation to reflect new configuration option - Implement logic to control VM reboot after configuration changes - Provide warning if reboot is required but disabled by configuration --------- Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
6a75b0cd2a
commit
5e726c48d4
@ -483,7 +483,8 @@ output "ubuntu_vm_public_key" {
|
|||||||
- `wxp` - Windows XP.
|
- `wxp` - Windows XP.
|
||||||
- `pool_id` - (Optional) The identifier for a pool to assign the virtual machine to.
|
- `pool_id` - (Optional) The identifier for a pool to assign the virtual machine to.
|
||||||
- `protection` - (Optional) Sets the protection flag of the VM. This will disable the remove VM and remove disk operations (defaults to `false`).
|
- `protection` - (Optional) Sets the protection flag of the VM. This will disable the remove VM and remove disk operations (defaults to `false`).
|
||||||
- `reboot` - (Optional) Reboot the VM after initial creation. (defaults to `false`)
|
- `reboot` - (Optional) Reboot the VM after initial creation (defaults to `false`).
|
||||||
|
- `reboot_after_update` - (Optional) Reboot the VM after update if needed (defaults to `true`).
|
||||||
- `rng` - (Optional) The random number generator configuration. Can only be set by `root@pam.`
|
- `rng` - (Optional) The random number generator configuration. Can only be set by `root@pam.`
|
||||||
- `source` - The file on the host to gather entropy from. In most cases, `/dev/urandom` should be preferred over `/dev/random` to avoid entropy-starvation issues on the host.
|
- `source` - The file on the host to gather entropy from. In most cases, `/dev/urandom` should be preferred over `/dev/random` to avoid entropy-starvation issues on the host.
|
||||||
- `max_bytes` - (Optional) Maximum bytes of entropy allowed to get injected into the guest every `period` milliseconds (defaults to `1024`). Prefer a lower value when using `/dev/random` as source.
|
- `max_bytes` - (Optional) Maximum bytes of entropy allowed to get injected into the guest every `period` milliseconds (defaults to `1024`). Prefer a lower value when using `/dev/random` as source.
|
||||||
|
@ -42,6 +42,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
dvRebootAfterCreation = false
|
dvRebootAfterCreation = false
|
||||||
|
dvRebootAfterUpdate = true
|
||||||
dvOnBoot = true
|
dvOnBoot = true
|
||||||
dvACPI = true
|
dvACPI = true
|
||||||
dvAgentEnabled = false
|
dvAgentEnabled = false
|
||||||
@ -144,6 +145,7 @@ const (
|
|||||||
maxResourceVirtualEnvironmentVMNUMADevices = 8
|
maxResourceVirtualEnvironmentVMNUMADevices = 8
|
||||||
|
|
||||||
mkRebootAfterCreation = "reboot"
|
mkRebootAfterCreation = "reboot"
|
||||||
|
mkRebootAfterUpdate = "reboot_after_update"
|
||||||
mkOnBoot = "on_boot"
|
mkOnBoot = "on_boot"
|
||||||
mkBootOrder = "boot_order"
|
mkBootOrder = "boot_order"
|
||||||
mkACPI = "acpi"
|
mkACPI = "acpi"
|
||||||
@ -299,10 +301,16 @@ func VM() *schema.Resource {
|
|||||||
s := map[string]*schema.Schema{
|
s := map[string]*schema.Schema{
|
||||||
mkRebootAfterCreation: {
|
mkRebootAfterCreation: {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Description: "Whether to reboot vm after creation",
|
Description: "Whether to reboot VM after creation",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: dvRebootAfterCreation,
|
Default: dvRebootAfterCreation,
|
||||||
},
|
},
|
||||||
|
mkRebootAfterUpdate: {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Description: "Whether to reboot VM after update if needed",
|
||||||
|
Optional: true,
|
||||||
|
Default: dvRebootAfterUpdate,
|
||||||
|
},
|
||||||
mkOnBoot: {
|
mkOnBoot: {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Description: "Start VM on Node boot",
|
Description: "Start VM on Node boot",
|
||||||
@ -5643,6 +5651,15 @@ func vmUpdateDiskLocationAndSize(
|
|||||||
|
|
||||||
// Perform a regular reboot in case it's necessary and haven't already been done.
|
// Perform a regular reboot in case it's necessary and haven't already been done.
|
||||||
if reboot {
|
if reboot {
|
||||||
|
canReboot := d.Get(mkRebootAfterUpdate).(bool)
|
||||||
|
if !canReboot {
|
||||||
|
return []diag.Diagnostic{{
|
||||||
|
Severity: diag.Warning,
|
||||||
|
Summary: "a reboot is required to apply configuration changes, but automatic " +
|
||||||
|
"reboots are disabled by 'reboot_after_update = false'. Please reboot the VM manually.",
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
vmStatus, err := vmAPI.GetVMStatus(ctx)
|
vmStatus, err := vmAPI.GetVMStatus(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user