提问人:GodAtum 提问时间:1/2/2023 更新时间:1/2/2023 访问量:105
Remote-exec 未在我的 Terraform 代码上运行
Remote-exec not running on my Terraform code
问:
我在下面有这个 main.tf。它使用所有正确的东西创建虚拟机。但出于某种原因,它不运行 provisioner file 和 remote-exec 部分。我从这里复制了代码。
我正在尝试在 Proxmox 中设置一个具有 2 个磁盘的 VM,并创建一个 LVM。这最终将用于添加 ceph 集群。
terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "2.9.11"
}
}
}
provider "proxmox" {
pm_api_url = "https://xxx:8006/api2/json"
pm_api_token_id = "terraform_token"
pm_api_token_secret = "xxx"
pm_tls_insecure = true
}
resource "proxmox_vm_qemu" "node_server" {
count = 3
# just want 1 for now, set to 0 and apply to destroy VM
name = "node-${count.index + 1}"
target_node = var.proxmox_host
clone = var.template_name
agent = 1
os_type = "cloud-init"
cores = 2
sockets = 1
cpu = "host"
memory = 4096
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"
disk {
slot = 0
size = "20G"
type = "scsi"
storage = "local-lvm"
iothread = 1
}
disk {
slot = 1
size = "250G"
type = "scsi"
storage = "local-lvm"
iothread = 1
}
provisioner "file" {
source = "/home/xxx/terraform-proxmox/setup-disks.sh"
destination = "/tmp/setup-disks.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/setup-disks.sh",
"sudo /tmp/setup-disk.sh",
]
}
network {
model = "virtio"
bridge = "vmbr0"
}
lifecycle {
ignore_changes = [
network,
]
}
ipconfig0 = "ip=xxx.5${count.index + 1}/24,gw=xxx"
sshkeys = <<EOF
${var.ssh_key}
EOF
}
答: 暂无答案
评论