mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-22 19:38:35 +00:00
feat(vm): remove support for initialization.upgrade
attribute (#1295)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
bcc4baf474
commit
2b7dd08020
@ -26,6 +26,8 @@ resource "proxmox_virtual_environment_vm" "ubuntu_vm" {
|
||||
# read 'Qemu guest agent' section, change to true only when ready
|
||||
enabled = false
|
||||
}
|
||||
# if agent is not enabled, the VM may not be able to shutdown properly, and may need to be forced off
|
||||
stop_on_destroy = true
|
||||
|
||||
startup {
|
||||
order = "3"
|
||||
@ -372,7 +374,6 @@ output "ubuntu_vm_public_key" {
|
||||
all vendor data passed to the VM via cloud-init.
|
||||
- `meta_data_file_id` - (Optional) The identifier for a file containing
|
||||
all meta data passed to the VM via cloud-init.
|
||||
- `upgrade` - (Optional) Whether to do an automatic package upgrade after the first boot (defaults to `true`).
|
||||
- `keyboard_layout` - (Optional) The keyboard layout (defaults to `en-us`).
|
||||
- `da` - Danish.
|
||||
- `de` - German.
|
||||
@ -563,7 +564,10 @@ Qemu-guest-agent is an application which can be installed inside guest VM, see
|
||||
Documentation](https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_qemu_agent)
|
||||
|
||||
For VM with `agent.enabled = false`, Proxmox uses ACPI for `Shutdown` and
|
||||
`Reboot`, and `qemu-guest-agent` is not needed inside the VM.
|
||||
`Reboot`, and `qemu-guest-agent` is not needed inside the VM. For some VMs,
|
||||
the shutdown process may not work, causing the VM to be stuck on destroying.
|
||||
Add `stop_on_destroy = true` to the VM configuration to stop the VM instead of
|
||||
shutting it down.
|
||||
|
||||
Setting `agent.enabled = true` informs Proxmox that the guest agent is expected
|
||||
to be *running* inside the VM. Proxmox then uses `qemu-guest-agent` instead of
|
||||
|
@ -261,52 +261,6 @@ func TestAccResourceVMInitialization(t *testing.T) {
|
||||
}),
|
||||
),
|
||||
}}},
|
||||
{"cloud-init: clone", []resource.TestStep{{
|
||||
Config: te.renderConfig(`
|
||||
resource "proxmox_virtual_environment_vm" "test_vm_cloudinit_template" {
|
||||
node_name = "{{.NodeName}}"
|
||||
name = "test-vm-cloudinit-template"
|
||||
started = false
|
||||
template = "true"
|
||||
initialization {
|
||||
upgrade = false
|
||||
}
|
||||
}
|
||||
resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
content_type = "snippets"
|
||||
datastore_id = "local"
|
||||
node_name = "{{.NodeName}}"
|
||||
source_raw {
|
||||
data = <<-EOF
|
||||
#cloud-config
|
||||
runcmd:
|
||||
- apt update
|
||||
- apt install -y qemu-guest-agent
|
||||
- systemctl enable qemu-guest-agent
|
||||
- systemctl start qemu-guest-agent
|
||||
EOF
|
||||
file_name = "cloud-config.yaml"
|
||||
}
|
||||
}
|
||||
resource "proxmox_virtual_environment_vm" "test_vm_cloudinit" {
|
||||
node_name = "{{.NodeName}}"
|
||||
name = "test-vm-cloudinit"
|
||||
started = false
|
||||
description = "Example to cause ciupgrade issue"
|
||||
clone {
|
||||
vm_id = proxmox_virtual_environment_vm.test_vm_cloudinit_template.id
|
||||
}
|
||||
|
||||
initialization {
|
||||
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
|
||||
}
|
||||
}`),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testResourceAttributes("proxmox_virtual_environment_vm.test_vm_cloudinit", map[string]string{
|
||||
"initialization.0.upgrade": "false",
|
||||
}),
|
||||
),
|
||||
}}},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
@ -50,7 +50,8 @@ type CustomCloudInitConfig struct {
|
||||
SearchDomain *string `json:"searchdomain,omitempty" url:"searchdomain,omitempty"`
|
||||
SSHKeys *CustomCloudInitSSHKeys `json:"sshkeys,omitempty" url:"sshkeys,omitempty"`
|
||||
Type *string `json:"citype,omitempty" url:"citype,omitempty"`
|
||||
Upgrade *types.CustomBool `json:"ciupgrade,omitempty" url:"ciupgrade,omitempty,int"`
|
||||
// Can't be reliably set, it is TRUE by default in PVE
|
||||
// Upgrade *types.CustomBool `json:"ciupgrade,omitempty" url:"ciupgrade,omitempty,int"`
|
||||
Username *string `json:"ciuser,omitempty" url:"ciuser,omitempty"`
|
||||
}
|
||||
|
||||
@ -825,14 +826,6 @@ func (r CustomCloudInitConfig) EncodeValues(_ string, v *url.Values) error {
|
||||
v.Add("citype", *r.Type)
|
||||
}
|
||||
|
||||
if r.Upgrade != nil {
|
||||
if *r.Upgrade {
|
||||
v.Add("ciupgrade", "1")
|
||||
} else {
|
||||
v.Add("ciupgrade", "0")
|
||||
}
|
||||
}
|
||||
|
||||
if r.Username != nil {
|
||||
v.Add("ciuser", *r.Username)
|
||||
}
|
||||
|
@ -904,6 +904,7 @@ func VM() *schema.Resource {
|
||||
Description: "Whether to do an automatic package upgrade after the first boot",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Deprecated: "The `upgrade` attribute is deprecated and will be removed in a future release.",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -2973,11 +2974,6 @@ func vmGetCloudInitConfig(d *schema.ResourceData) *vms.CustomCloudInitConfig {
|
||||
initializationConfig.Type = &initializationType
|
||||
}
|
||||
|
||||
if initializationBlock[mkInitializationUpgrade] != nil && initializationConfig.Files == nil {
|
||||
v := types.CustomBool(initializationBlock[mkInitializationUpgrade].(bool))
|
||||
initializationConfig.Upgrade = &v
|
||||
}
|
||||
|
||||
return initializationConfig
|
||||
}
|
||||
|
||||
@ -4135,12 +4131,6 @@ func vmReadCustom(
|
||||
initialization[mkInitializationType] = ""
|
||||
}
|
||||
|
||||
if vmConfig.CloudInitUpgrade != nil {
|
||||
initialization[mkInitializationUpgrade] = *vmConfig.CloudInitUpgrade
|
||||
} else if len(initialization) > 0 {
|
||||
initialization[mkInitializationUpgrade] = dvInitializationUpgrade
|
||||
}
|
||||
|
||||
currentInitialization := d.Get(mkInitialization).([]interface{})
|
||||
|
||||
//nolint:gocritic
|
||||
|
Loading…
Reference in New Issue
Block a user