Comments (9)
Hi @mmacedo2000! 👋🏼
The migration support was added in #501, so in theory this should work, however, I have not tested it for a while.
How did you try migrating the VM? By updating the node_name
and migrate = true
in the VM resource? Is your VM is a clone of another VM?
from terraform-provider-proxmox.
Hi @mmacedo2000! 👋🏼
The migration support was added in #501, so in theory this should work, however, I have not tested it for a while.
How did you try migrating the VM? By updating the
node_name
andmigrate = true
in the VM resource? Is your VM is a clone of another VM?
Hello,
Yes, I am trying to migrate the VM by updating the node_name and migrate = true
The VM is created with proxmox_virtual_environment_vm and I am also using a cloud init.
This is the VM creation configuration:
resource "proxmox_virtual_environment_vm" "vm" {
name = var.name
description = var.description
tags = ["terraform"]
#local.proxmox_tags
node_name = var.host_name
migrate = true
cpu {
cores = var.vm_cores
numa = true
type = "host"
}
memory {
dedicated = var.vm_memory
}
agent {
enabled = true
}
network_device {
bridge = "vmbr0"
}
disk {
datastore_id = var.disk_datasource_name
file_id = proxmox_virtual_environment_file.ubuntu_cloud_image.id
interface = "scsi0"
size = var.disk_size
}
serial_device {}
operating_system {
type = "l26"
}
initialization {
datastore_id = var.disk_datasource_name
user_data_file_id = proxmox_virtual_environment_file.cloud_init.id
ip_config {
ipv4 {
address = "dhcp"
}
}
}
}
from terraform-provider-proxmox.
Hey @mmaced, could you post your TF output and ideally a debug log, so I can try to debug it?
from terraform-provider-proxmox.
Hello,
Did you have a chance to look at this problem? @bpg
Thanks.
from terraform-provider-proxmox.
Hi @mmaced, I can't reproduce this issue in my lab.
My template:
resource "proxmox_virtual_environment_vm" "ubuntu_vm" {
name = "test"
node_name = "pve2"
vm_id = 1000
agent {
enabled = true
}
cpu {
cores = 4
}
memory {
dedicated = 4096
# hugepages = "any"
}
boot_order = ["virtio0", "scsi0"]
disk {
datastore_id = "local-lvm"
file_id = proxmox_virtual_environment_download_file.ubuntu_cloud_image.id
interface = "virtio0"
}
initialization {
datastore_id = "local-lvm"
ip_config {
ipv4 {
address = "dhcp"
}
}
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
}
network_device {
bridge = "vmbr0"
}
}
resource "proxmox_virtual_environment_download_file" "ubuntu_cloud_image" {
content_type = "iso"
datastore_id = "local"
node_name = "pve2"
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
overwrite_unmanaged = true
}
After initial deployment, I changed
node_name = "pve1"
migrate = true
in the TF template for the ubuntu_vm
resource, and then ran apply
again, which performed the migration:
data.local_file.ssh_public_key: Reading...
data.local_file.ssh_public_key: Read complete after 0s [id=84cdc3a1d1eaa8e821cd6dd4287f04ae996b8309]
proxmox_virtual_environment_download_file.ubuntu_cloud_image: Refreshing state... [id=local:iso/jammy-server-cloudimg-amd64.img]
proxmox_virtual_environment_file.cloud_config: Refreshing state... [id=local:snippets/cloud-config.yaml]
proxmox_virtual_environment_vm.ubuntu_vm: Refreshing state... [id=1000]
OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
OpenTofu will perform the following actions:
# proxmox_virtual_environment_vm.ubuntu_vm will be updated in-place
~ resource "proxmox_virtual_environment_vm" "ubuntu_vm" {
id = "1000"
~ migrate = false -> true
name = "test"
~ node_name = "pve2" -> "pve1"
tags = []
# (25 unchanged attributes hidden)
# (6 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
proxmox_virtual_environment_vm.ubuntu_vm: Modifying... [id=1000]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 10s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 20s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 30s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 40s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 50s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 1m0s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 1m10s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 1m20s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Still modifying... [id=1000, 1m30s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Modifications complete after 1m31s [id=1000]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
![Screenshot 2024-05-12 at 4 03 34 PM](https://private-user-images.githubusercontent.com/627562/329877335-d3b8928e-a517-4d3a-ae7b-5873312970fe.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE5NDUxNDAsIm5iZiI6MTcyMTk0NDg0MCwicGF0aCI6Ii82Mjc1NjIvMzI5ODc3MzM1LWQzYjg5MjhlLWE1MTctNGQzYS1hZTdiLTU4NzMzMTI5NzBmZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcyNVQyMjAwNDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wOWZmZjBlZTkyNzBiODYzZmY0ZWJhM2E3ZWM0NWFhYzExMzBhN2I3ZTllMTljYTY3ZDY1ODQ3ZjBkZmU1YmJlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.i0fFCTMKdI7Xy_OBVlZ-EihRW2vS6d-ivTatVjwOWEE)
![Screenshot 2024-05-12 at 4 04 39 PM](https://private-user-images.githubusercontent.com/627562/329877339-cc003ad9-649f-4c71-8fd9-f5c9e7f796f7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE5NDUxNDAsIm5iZiI6MTcyMTk0NDg0MCwicGF0aCI6Ii82Mjc1NjIvMzI5ODc3MzM5LWNjMDAzYWQ5LTY0OWYtNGM3MS04ZmQ5LWY1YzllN2Y3OTZmNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcyNVQyMjAwNDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00OTNjOTU5ZmNkNGNiYzgzYWQ3ODk5NzMxYjgxYmE2ODY2YTI5MWQ2ZjQ2ZGJmM2ZjN2JjM2Q2MTY2NTM5ZjEzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.LGivMO6Gv0hpFmJUZJ44sZX4COqsM4M_OcGK4xKXKs0)
Could you post your terraform / tofu output from the plan
or apply
command when you're trying to migrate?
from terraform-provider-proxmox.
Hello @bpg , sorry for the late response.
So, this is my vm configuration (initially already with migrate=true, idk if that could be the problem).
##############################################
# Resource names and tags
##############################################
locals {
proxmox_tags = {
Service = "proxmox",
Availability = "${var.availability}",
App = "${var.app}",
CreatedBy = "${var.username}",
Type = "${var.created_proccess}",
Pipeline = "${var.pipeline_caller}",
PipelineID = "${var.pipeline_id}",
CostCenter = "${var.cost_center}",
ModifiedAt = timestamp()
}
}
##############################################
# Proxmox VM
##############################################
resource "proxmox_virtual_environment_vm" "vm" {
name = var.name
description = var.description
tags = ["terraform"]
#local.proxmox_tags
node_name = var.host_name
migrate = true
protection = true
cpu {
cores = var.vm_cores
numa = true
type = "host"
}
memory {
dedicated = var.vm_memory
}
agent {
enabled = true
}
network_device {
bridge = "vmbr0"
}
disk {
datastore_id = var.disk_datasource_name
file_id = "NAS:iso/jammy-server-cloudimg-amd64.img"
interface = "scsi0"
size = var.disk_size
}
serial_device {}
operating_system {
type = "l26"
}
initialization {
datastore_id = var.disk_datasource_name
user_data_file_id = proxmox_virtual_environment_file.cloud_init.id
ip_config {
ipv4 {
address = "dhcp"
}
}
}
}
Now I will change variable var.host_name to another host name and run tf.
and as you can see he will destroy and recreate instead of migrate:
from terraform-provider-proxmox.
Ah, that's migration of a promox_virual_environment_file
resource, not a VM.
You'd probably need to put your cloud_init file to a shared datastore (ceph, nfs, cifs, etc) to support this scenario.
Moving file resources between local datastores on different cluster nodes is not supported by the provider.
from terraform-provider-proxmox.
But this promox_virtual_environment_file is already set to be shared as a nfs (NAS2),
I am also migrating the promox_virtual_environment_vm from node_name to another and it also tries to destroy and create instead of migrate.
resource "proxmox_virtual_environment_vm" "vm" {
name = var.name
description = var.description
tags = ["terraform"]
#local.proxmox_tags
node_name = var.host_name
migrate = true
protection = true
from terraform-provider-proxmox.
But this promox_virtual_environment_file is already set to be shared as a nfs (NAS2),
Great, then it doesn't need to be moved from node to node, as the file should be available under the same datastore name on all nodes.
I am also migrating the promox_virtual_environment_vm from node_name to another and it also tries to destroy and create instead of migrate.
Could you share a terraform output of this try?
from terraform-provider-proxmox.
Related Issues (20)
- Cannot create volume mount point in LXC HOT 7
- Add support for `proxmox_virtual_environment_file` data source HOT 4
- Terraform VM Creation crashes plugin when adding ipv4 configuration to VM HOT 3
- Context Deadline Exceeded only on certain resources HOT 11
- Using Cloud Init package_upgrade: false HOT 1
- Error: resizing disk: error waiting for VM disk resize: All attempts fail: HOT 5
- After import command or block, unprivileged forces replacement HOT 2
- Live Migration error: retrieving VM 100: the requested resource does not exist HOT 3
- Recommended way to get Packer built VM ID into Terraform control HOT 9
- proxmox_virtual_environment_vm.virtual_machine already exists error HOT 2
- Please add new arguments and attributes to the `proxmox_virtual_environment_vms` data source HOT 2
- Unknown timezone "Europe/Amsterdam" with proxmox_virtual_environment_time HOT 2
- Changing disk size of 'proxmox_virtual_environment_container' forces replacement HOT 4
- proxmox_virtual_environment_download_file can't read metadata HOT 2
- CloudImage size changes forces replacement of VM HOT 2
- proxmox_virtual_environment_vm forces replacement by unchanged initialization.user_account.keys HOT 2
- A question about documentation related to the proxmox_virtual_environment_container resource
- Error listing files from datastore using API Token as credentials HOT 2
- Unable to download iso (OpenTofu) HOT 2
- proxmox_virtual_environment_network_linux_bridge additional config
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-provider-proxmox.