resource "proxmox_virtual_environment_vm" "debian_vm" { count = 2 name = "test-debian${count.index+1}" node_name = "pve" initialization { ip_config { ipv4 { address = "dhcp" # ou encore address = "192.168.1.100/24" } } user_account { # do not use this in production, configure your own ssh key instead! username = "debian" keys = ["ssh-rsa AAAAB.....UKNwqgOCcE= paul@host"] #password = "password" } } memory { dedicated = 1024 } network_device { bridge = "vmbr0" model = "virtio" } lifecycle { ignore_changes = [ network_device, # on conserve l'adresse MAC pour éviter de régénérer la VM ] } operating_system { type = "l26" } disk { datastore_id = "local-lvm" file_id = proxmox_virtual_environment_file.debian_cloud_image.id interface = "virtio0" iothread = true discard = "on" size = 6 } } resource "proxmox_virtual_environment_file" "debian_cloud_image" { content_type = "iso" datastore_id = "local" node_name = "pve" source_file { # you may download this image locally on your workstation and then use the local path instead of the remote URL path = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2" # path = "/var/www/html/debian-12-genericcloud-amd64.qcow2" # chemin local file_name = "debian-12-genericcloud-amd64.img" } } resource "random_password" "debian_vm_password" { length = 16 override_special = "_%@" special = true } resource "tls_private_key" "debian_vm_key" { algorithm = "RSA" rsa_bits = 2048 } output "debian_vm_public_key" { value = tls_private_key.debian_vm_key.public_key_openssh } }