You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
image_name = "default/image-abc12" # match the existing image ID
140
+
network_name = "team-ns/vlan-600"
141
+
142
+
# Brownfield overrides — match what the Harvester UI created
143
+
disk_name = "disk-0"
144
+
disk_auto_delete = false
145
+
network_interface_name = "default"
146
+
ssh_key_ids = ["default/shared-key"]
147
+
input_devices = [{ name = "tablet", type = "tablet", bus = "usb" }]
148
+
}
149
+
```
150
+
151
+
After declaring the module, `terraform import module.legacy_vm.harvester_virtualmachine.this <namespace>/<name>` and run `terraform plan` — the plan should show zero changes.
152
+
122
153
### Referencing images from the management phase
123
154
124
155
```hcl
@@ -152,6 +183,12 @@ locals {
152
183
|`wait_for_lease`| Wait for IP lease on primary NIC. Set false for static cloud-init IPs. |`bool`|`true`| no |
153
184
|`user_data`| Cloud-init user-data YAML. Creates a cloud-init secret when set. |`string`|`null`| no |
154
185
|`network_data`| Cloud-init network-data config (requires `user_data` to be set). |`string`|`""`| no |
186
+
|`disk_name`| Name of the root disk volume. Override to match brownfield VMs. |`string`|`"rootdisk"`| no |
187
+
|`disk_auto_delete`| Whether the root disk's PVC is deleted with the VM. |`bool`|`true`| no |
188
+
|`network_interface_name`| Name of the primary NIC. Override to match brownfield VMs. |`string`|`"nic-1"`| no |
189
+
|`restart_after_update`| Whether Terraform restarts the VM when its spec changes. |`bool`|`true`| no |
190
+
|`ssh_key_ids`| Existing Harvester SSH key IDs (`namespace/name`) to attach. |`list(string)`|`[]`| no |
191
+
|`input_devices`| Input devices (e.g. USB tablet) to attach. |`list(object)`|`[]`| no |
# These let the module wrap VMs that were created outside Terraform (e.g. via
112
+
# the Harvester UI) without forcing destructive renames on import. Defaults
113
+
# match greenfield conventions; override only when matching existing state.
114
+
115
+
variable"disk_name" {
116
+
type=string
117
+
description="Name of the root disk volume. Harvester-UI-created VMs use \"disk-0\"; module-created VMs use \"rootdisk\"."
118
+
default="rootdisk"
119
+
}
120
+
121
+
variable"disk_auto_delete" {
122
+
type=bool
123
+
description="Whether the root disk's PVC is deleted when the VM is deleted. UI-created VMs typically have this false."
124
+
default=true
125
+
}
126
+
127
+
variable"network_interface_name" {
128
+
type=string
129
+
description="Name of the primary network interface. Harvester-UI-created VMs use \"default\"; module-created VMs use \"nic-1\"."
130
+
default="nic-1"
131
+
}
132
+
133
+
variable"restart_after_update" {
134
+
type=bool
135
+
description="Whether Terraform restarts the VM to apply spec changes. Set false to defer restarts on live VMs."
136
+
default=true
137
+
}
138
+
139
+
variable"ssh_key_ids" {
140
+
type=list(string)
141
+
description="Existing Harvester SSH key IDs (namespace/name) to attach, in addition to any key created by create_ssh_key. Use this to reference pre-existing shared keys."
142
+
default=[]
143
+
}
144
+
145
+
variable"input_devices" {
146
+
type=list(object({
147
+
name =string
148
+
type =string
149
+
bus =optional(string, "usb")
150
+
}))
151
+
description="Input devices (e.g. USB tablet) to attach. Harvester-UI-created VMs include a tablet by default; module-created VMs add none."
0 commit comments