2019-05-16 19:39:51 -04:00
|
|
|
provider "proxmox" {
|
|
|
|
|
pm_tls_insecure = true
|
|
|
|
|
pm_api_url = "https://proxmox-server01.example.com:8006/api2/json"
|
|
|
|
|
pm_password = "secret"
|
2022-02-04 11:41:58 -05:00
|
|
|
pm_user = "terraform-prov@pve"
|
2019-08-02 08:01:52 -04:00
|
|
|
pm_otp = ""
|
2019-05-16 19:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "proxmox_vm_qemu" "cloudinit-test" {
|
|
|
|
|
name = "terraform-test-vm"
|
2025-10-14 09:53:34 -04:00
|
|
|
description = "A test for using terraform and cloudinit"
|
2019-05-16 19:39:51 -04:00
|
|
|
|
|
|
|
|
# Node name has to be the same name as within the cluster
|
|
|
|
|
# this might not include the FQDN
|
|
|
|
|
target_node = "proxmox-server02"
|
|
|
|
|
|
2019-07-13 19:49:34 -04:00
|
|
|
# The destination resource pool for the new VM
|
|
|
|
|
pool = "pool0"
|
|
|
|
|
|
2019-05-16 19:39:51 -04:00
|
|
|
# The template name to clone this vm from
|
|
|
|
|
clone = "linux-cloudinit-template"
|
|
|
|
|
|
|
|
|
|
# Activate QEMU agent for this VM
|
|
|
|
|
agent = 1
|
|
|
|
|
|
|
|
|
|
os_type = "cloud-init"
|
2025-05-03 14:01:04 -04:00
|
|
|
|
|
|
|
|
cpu {
|
|
|
|
|
cores = 2
|
|
|
|
|
sockets = 1
|
|
|
|
|
type = "host"
|
|
|
|
|
}
|
2021-01-18 05:08:28 -05:00
|
|
|
memory = 2048
|
2019-08-05 05:00:26 -04:00
|
|
|
scsihw = "lsi"
|
2019-05-16 19:39:51 -04:00
|
|
|
|
2021-01-18 05:08:28 -05:00
|
|
|
# Setup the disk
|
2024-02-26 12:37:46 -05:00
|
|
|
disks {
|
2024-05-18 19:06:44 -04:00
|
|
|
ide {
|
|
|
|
|
ide3 {
|
|
|
|
|
cloudinit {
|
|
|
|
|
storage = "local-lvm"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-26 12:37:46 -05:00
|
|
|
virtio {
|
|
|
|
|
virtio0 {
|
|
|
|
|
disk {
|
|
|
|
|
size = 32
|
|
|
|
|
cache = "writeback"
|
|
|
|
|
storage = "ceph-storage-pool"
|
|
|
|
|
storage_type = "rbd"
|
|
|
|
|
iothread = true
|
|
|
|
|
discard = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-16 19:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Setup the network interface and assign a vlan tag: 256
|
2019-06-05 16:24:04 -04:00
|
|
|
network {
|
2024-10-28 03:09:36 -04:00
|
|
|
id = 0
|
2019-05-16 19:39:51 -04:00
|
|
|
model = "virtio"
|
|
|
|
|
bridge = "vmbr0"
|
|
|
|
|
tag = 256
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Setup the ip address using cloud-init.
|
2024-05-18 19:06:44 -04:00
|
|
|
boot = "order=virtio0"
|
2019-05-16 19:39:51 -04:00
|
|
|
# Keep in mind to use the CIDR notation for the ip.
|
|
|
|
|
ipconfig0 = "ip=192.168.10.20/24,gw=192.168.10.1"
|
|
|
|
|
|
|
|
|
|
sshkeys = <<EOF
|
|
|
|
|
ssh-rsa 9182739187293817293817293871== user@pc
|
|
|
|
|
EOF
|
|
|
|
|
}
|