mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-03 12:02:57 +00:00
fix(vm): prevent cloud-init username reset to " "
during create (#1863)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
af46a9c71a
commit
c9fcb30762
@ -494,6 +494,24 @@ func TestAccResourceVMInitialization(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
}}},
|
}}},
|
||||||
|
{"native cloud-init: username should not change", []resource.TestStep{{
|
||||||
|
Config: te.RenderConfig(`
|
||||||
|
resource "proxmox_virtual_environment_vm" "test_vm_cloudinit4" {
|
||||||
|
node_name = "{{.NodeName}}"
|
||||||
|
started = false
|
||||||
|
initialization {
|
||||||
|
user_account {
|
||||||
|
keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQCHPhOV9XsJa3uq4bmKymklNy6ktgBB/+2umizgnnY"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
NoResourceAttributesSet("proxmox_virtual_environment_vm.test_vm_cloudinit4", []string{
|
||||||
|
"initialization.0.username",
|
||||||
|
"initialization.0.password",
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
@ -2937,8 +2937,10 @@ func vmGetCloudInitConfig(d *schema.ResourceData) *vms.CustomCloudInitConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
username := initializationUserAccountBlock[mkInitializationUserAccountUsername].(string)
|
username := initializationUserAccountBlock[mkInitializationUserAccountUsername].(string)
|
||||||
|
if username != "" {
|
||||||
initializationConfig.Username = &username
|
initializationConfig.Username = &username
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
initializationUserDataFileID := initializationBlock[mkInitializationUserDataFileID].(string)
|
initializationUserDataFileID := initializationBlock[mkInitializationUserDataFileID].(string)
|
||||||
if initializationUserDataFileID != "" {
|
if initializationUserDataFileID != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user