gpt4 book ai didi

ubuntu - 使用 terraform 将 ubuntu iso 部署到 proxmox

转载 作者:行者123 更新时间:2023-12-04 18:55:46 25 4
gpt4 key购买 nike

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












这个问题似乎与 help center 中定义的范围内的编程无关。 .


7 个月前关闭。







Improve this question




我可以使用 cloud init(ubuntu 镜像模板)在 Proxmox 中创建 VM。但是,现在我想在我有 iso 的地方创建 VM,但我无法创建 VM。我有一个文件夹,其中包含 foo.iso, main.tf, vars.tf .我需要使用这个 foo.iso 在 proxmox 中创建 VM。有人可以帮我吗?任何线索将不胜感激。
这是 main.tf

terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "2.9.1"
}
}
}

provider "proxmox" {

pm_api_url = "https://foo:8006/api2/json"


pm_api_token_id = ""

pm_api_token_secret = "pass"


pm_tls_insecure = true
}


resource "proxmox_vm_qemu" "test_server" {
count = 1 # just want 1 for now, set to 0 and apply to destroy VM
name = "test-vm-${count.index + 1}" #count.index starts at 0, so + 1 means this VM will be named test-vm-1 in proxmox


target_node = var.proxmox_host

# another variable with contents "ubuntu-2004-cloudinit-template"

iso = "home/Terraform/foo.iso"

#clone is working fine but I need to the above one to work.
clone = var.template_name

# basic VM settings here. agent refers to guest agent
agent = 1
#os_type = "cloud-init"
cores = 2
sockets = 1
cpu = "host"
memory = 2048
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"

disk {
slot = 0
size = "10G"
type = "scsi"
storage = "local-zfs"
iothread = 1
}

network {
model = "virtio"
bridge = "vmbr0"
}

lifecycle {
ignore_changes = [
network,
]
}


# multiple VMs and have an IP assigned to each (.91, .92, .93, etc.)

ipconfig0 = "ip=10.98.1.9${count.index + 1}/24,gw=10.98.1.1"

# sshkeys set using variables. the variable contains the text of the key.
sshkeys = <<EOF
${var.ssh_key}
EOF
}

应用以下计划时出错。
Error: Cloud-init parameters only supported on clones or updates

on main.tf line 20, in resource "proxmox_vm_qemu" "test_server":
20: resource "proxmox_vm_qemu" "test_server" {

最佳答案

答案是去掉 ip 和 ssh 来创建 vm。
试试这个,它应该工作

terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "2.9.1"
}
}
}

provider "proxmox" {

pm_api_url = "https://foo:8006/api2/json"


pm_api_token_id = ""

pm_api_token_secret = "pass"


pm_tls_insecure = true
}


resource "proxmox_vm_qemu" "test_server" {
count = 1 # just want 1 for now, set to 0 and apply to destroy VM
name = "test-vm-${count.index + 1}" #count.index starts at 0, so + 1 means this VM will be named test-vm-1 in proxmox


target_node = var.proxmox_host

# another variable with contents "ubuntu-2004-cloudinit-template"

iso = "home/Terraform/foo.iso"

#clone is working fine but I need to the above one to work.
clone = var.template_name

# basic VM settings here. agent refers to guest agent
agent = 1
#os_type = "cloud-init"
cores = 2
sockets = 1
cpu = "host"
memory = 2048
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"

disk {
slot = 0
size = "10G"
type = "scsi"
storage = "local-zfs"
iothread = 1
}

network {
model = "virtio"
bridge = "vmbr0"
}

lifecycle {
ignore_changes = [
network,
]
}


}

关于ubuntu - 使用 terraform 将 ubuntu iso 部署到 proxmox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70102851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com