如何使用 Terraform 处理 proxmox 中现有 VM 的资源?
How to handle resources of existing VM inside proxmox using Terraform?
我有一个关于如何使用 terraform 更改 RAM、节点 node-1 上现有 VM 的核心数等资源的问题。我参考了这个示例 https://github.com/Telmate/terraform-provider-proxmox/blob/master/examples/cloudinit_example.tf,但这会创建 VM,我需要更改 and/or 处理现有的 VM 资源。谁能解释如何做到这一点?提前致谢。
请在直接提问之前检查文档。如果你没有找到它,请用源代码交叉检查它。这非常简单。提供现有名称和 vmid。进一步添加资源、网络并添加您真正需要的所有内容。
示例代码在这里。
provider "proxmox" {
pm_tls_insecure = true
pm_api_url = "https://proxmox-server01.example.com:8006/api2/json"
pm_password = "secret"
pm_user = "terraform-user@pve"
pm_otp = ""
}
resource "proxmox_vm_qemu" "cloudinit-test" {
vmid = <Existing VMID>
name = "<Existing Name of VM>"
# Node name has to be the same name as within the cluster
# this might not include the FQDN
target_node = "proxmox-server02"
cores = 2
sockets = 1
vcpus = 0
cpu = "host"
memory = 2048
scsihw = "lsi"
# Setup the disk
disk {
size = 32
type = "virtio"
storage = "ceph-storage-pool"
storage_type = "rbd"
iothread = 1
ssd = 1
discard = "on"
}
# Setup the network interface and assign a vlan tag: 256
network {
model = "virtio"
bridge = "vmbr0"
}
}
我有一个关于如何使用 terraform 更改 RAM、节点 node-1 上现有 VM 的核心数等资源的问题。我参考了这个示例 https://github.com/Telmate/terraform-provider-proxmox/blob/master/examples/cloudinit_example.tf,但这会创建 VM,我需要更改 and/or 处理现有的 VM 资源。谁能解释如何做到这一点?提前致谢。
请在直接提问之前检查文档。如果你没有找到它,请用源代码交叉检查它。这非常简单。提供现有名称和 vmid。进一步添加资源、网络并添加您真正需要的所有内容。
示例代码在这里。
provider "proxmox" {
pm_tls_insecure = true
pm_api_url = "https://proxmox-server01.example.com:8006/api2/json"
pm_password = "secret"
pm_user = "terraform-user@pve"
pm_otp = ""
}
resource "proxmox_vm_qemu" "cloudinit-test" {
vmid = <Existing VMID>
name = "<Existing Name of VM>"
# Node name has to be the same name as within the cluster
# this might not include the FQDN
target_node = "proxmox-server02"
cores = 2
sockets = 1
vcpus = 0
cpu = "host"
memory = 2048
scsihw = "lsi"
# Setup the disk
disk {
size = 32
type = "virtio"
storage = "ceph-storage-pool"
storage_type = "rbd"
iothread = 1
ssd = 1
discard = "on"
}
# Setup the network interface and assign a vlan tag: 256
network {
model = "virtio"
bridge = "vmbr0"
}
}