如何使用Terraform处理proxyox内现有VM的资源



我有一个问题,关于如何使用terraform更改资源,如RAM,节点node-1上现有VM的内核数量。我提到了这个例子https://github.com/Telmate/terraform-provider-proxmox/blob/master/examples/cloudinit_example.tf,但这将创建VM,我需要更改和/或处理现有的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​" 
​    } 
​}

最新更新