This commit is contained in:
Arthur Dodin
2026-05-05 11:50:46 +02:00
parent ffde04bdec
commit a35261ea30
4 changed files with 891 additions and 52 deletions
+27 -8
View File
@@ -1,7 +1,27 @@
resource "proxmox_virtual_environment_vm" "vm_ubuntu" { data "proxmox_files" "ubuntu_image" {
content_type = "import"
node_name = var.target_node node_name = var.target_node
name = "vm-ubuntu" datastore_id = "local"
vm_id = 1100 file_name_regex = "jammy"
}
resource "proxmox_virtual_environment_vm" "vm_ubuntu_iscsi" {
count = 3
vm_id = 100 + count.index + 2
name = "ubuntu-cloud-vm-${count.index + 1}"
node_name = var.target_node
initialization {
ip_config {
ipv4 {
address = "dhcp"
}
}
user_account {
username = "root"
password = "rootroot"
}
}
cpu { cpu {
cores = 2 cores = 2
@@ -12,14 +32,13 @@ resource "proxmox_virtual_environment_vm" "vm_ubuntu" {
} }
network_device { network_device {
bridge = "vmbr0" bridge = "vmbr1"
} }
disk { disk {
import_from = "local:iso/jammy-server-cloudimg-amd64.img" interface = "scsi0"
datastore_id = "truenas_lvm"
import_from = data.proxmox_files.ubuntu_image.files[0].id
} }
initialization {
}
} }
+1 -1
View File
@@ -1,4 +1,4 @@
output "vm_status" { output "vm_status" {
value = proxmox_virtual_environment_vm.vm_ubuntu.ipv4_addresses value = proxmox_virtual_environment_vm.vm_ubuntu_iscsi[*].all
description = "Les adresses IP de la VM créée" description = "Les adresses IP de la VM créée"
} }
+538 -23
View File
@@ -1,28 +1,81 @@
{ {
"version": 4, "version": 4,
"terraform_version": "1.15.1", "terraform_version": "1.15.1",
"serial": 7, "serial": 33,
"lineage": "932f91fd-26ce-0c13-df63-09cd25a0eb0f", "lineage": "932f91fd-26ce-0c13-df63-09cd25a0eb0f",
"outputs": { "outputs": {
"vm_status": { "vm_status": {
"value": [], "value": [
[],
[],
[]
],
"type": [ "type": [
"tuple",
[
[
"list",
[
"list",
"string"
]
],
[
"list",
[
"list",
"string"
]
],
[
"list", "list",
[ [
"list", "list",
"string" "string"
] ]
] ]
]
]
} }
}, },
"resources": [ "resources": [
{ {
"mode": "managed", "mode": "data",
"type": "proxmox_virtual_environment_vm", "type": "proxmox_files",
"name": "vm_ubuntu", "name": "ubuntu_image",
"provider": "provider[\"registry.terraform.io/bpg/proxmox\"]", "provider": "provider[\"registry.terraform.io/bpg/proxmox\"]",
"instances": [ "instances": [
{ {
"schema_version": 0,
"attributes": {
"content_type": "import",
"datastore_id": "local",
"file_name_regex": "jammy",
"files": [
{
"content_type": "import",
"file_format": "qcow2",
"file_name": "jammy-server-cloudimg-amd64.qcow2",
"file_size": 692407808,
"id": "local:import/jammy-server-cloudimg-amd64.qcow2",
"vmid": null
}
],
"node_name": "pve1"
},
"sensitive_attributes": [],
"identity_schema_version": 0
}
]
},
{
"mode": "managed",
"type": "proxmox_virtual_environment_vm",
"name": "vm_ubuntu_iscsi",
"provider": "provider[\"registry.terraform.io/bpg/proxmox\"]",
"instances": [
{
"index_key": 0,
"schema_version": 0, "schema_version": 0,
"attributes": { "attributes": {
"acpi": true, "acpi": true,
@@ -31,16 +84,10 @@
"audio_device": [], "audio_device": [],
"bios": "seabios", "bios": "seabios",
"boot_order": [ "boot_order": [
"ide3", "scsi0",
"net0" "net0"
], ],
"cdrom": [ "cdrom": [],
{
"enabled": false,
"file_id": "local:iso/jammy-server-cloudimg-amd64.img",
"interface": "ide3"
}
],
"clone": [], "clone": [],
"cpu": [ "cpu": [
{ {
@@ -58,19 +105,69 @@
], ],
"delete_unreferenced_disks_on_destroy": true, "delete_unreferenced_disks_on_destroy": true,
"description": "", "description": "",
"disk": [], "disk": [
{
"aio": "io_uring",
"backup": true,
"cache": "none",
"datastore_id": "truenas_lvm",
"discard": "ignore",
"file_format": "raw",
"file_id": "",
"import_from": "local:import/jammy-server-cloudimg-amd64.qcow2",
"interface": "scsi0",
"iothread": false,
"path_in_datastore": "vm-102-disk-0",
"replicate": true,
"serial": "",
"size": 8,
"speed": [],
"ssd": false
}
],
"efi_disk": [], "efi_disk": [],
"hook_script_file_id": null, "hook_script_file_id": null,
"hostpci": [], "hostpci": [],
"hotplug": null, "hotplug": null,
"id": "1100", "id": "102",
"initialization": [], "initialization": [
{
"datastore_id": "local-lvm",
"dns": [],
"file_format": "",
"interface": "ide2",
"ip_config": [
{
"ipv4": [
{
"address": "dhcp",
"gateway": ""
}
],
"ipv6": []
}
],
"meta_data_file_id": "",
"network_data_file_id": "",
"type": "",
"upgrade": true,
"user_account": [
{
"keys": null,
"password": "**********",
"username": "root"
}
],
"user_data_file_id": "",
"vendor_data_file_id": ""
}
],
"ipv4_addresses": [], "ipv4_addresses": [],
"ipv6_addresses": [], "ipv6_addresses": [],
"keyboard_layout": "en-us", "keyboard_layout": "en-us",
"kvm_arguments": "", "kvm_arguments": "",
"mac_addresses": [ "mac_addresses": [
"BC:24:11:AE:FB:4F" "BC:24:11:F0:0B:68"
], ],
"machine": "", "machine": "",
"memory": [ "memory": [
@@ -83,14 +180,14 @@
} }
], ],
"migrate": false, "migrate": false,
"name": "vm-ubuntu", "name": "ubuntu-cloud-vm-1",
"network_device": [ "network_device": [
{ {
"bridge": "vmbr0", "bridge": "vmbr1",
"disconnected": false, "disconnected": false,
"enabled": true, "enabled": true,
"firewall": false, "firewall": false,
"mac_address": "BC:24:11:AE:FB:4F", "mac_address": "BC:24:11:F0:0B:68",
"model": "virtio", "model": "virtio",
"mtu": 0, "mtu": 0,
"queues": 0, "queues": 0,
@@ -131,12 +228,430 @@
"usb": [], "usb": [],
"vga": [], "vga": [],
"virtiofs": [], "virtiofs": [],
"vm_id": 1100, "vm_id": 102,
"watchdog": [] "watchdog": []
}, },
"sensitive_attributes": [], "sensitive_attributes": [
[
{
"type": "get_attr",
"value": "initialization"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "user_account"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "password"
}
]
],
"identity_schema_version": 0, "identity_schema_version": 0,
"private": "bnVsbA==" "private": "bnVsbA==",
"dependencies": [
"data.proxmox_files.ubuntu_image"
]
},
{
"index_key": 1,
"schema_version": 0,
"attributes": {
"acpi": true,
"agent": [],
"amd_sev": [],
"audio_device": [],
"bios": "seabios",
"boot_order": [
"scsi0",
"net0"
],
"cdrom": [],
"clone": [],
"cpu": [
{
"affinity": "",
"architecture": "",
"cores": 2,
"flags": null,
"hotplugged": 0,
"limit": 0,
"numa": false,
"sockets": 1,
"type": "qemu64",
"units": 0
}
],
"delete_unreferenced_disks_on_destroy": true,
"description": "",
"disk": [
{
"aio": "io_uring",
"backup": true,
"cache": "none",
"datastore_id": "truenas_lvm",
"discard": "ignore",
"file_format": "raw",
"file_id": "",
"import_from": "local:import/jammy-server-cloudimg-amd64.qcow2",
"interface": "scsi0",
"iothread": false,
"path_in_datastore": "vm-103-disk-0",
"replicate": true,
"serial": "",
"size": 8,
"speed": [],
"ssd": false
}
],
"efi_disk": [],
"hook_script_file_id": null,
"hostpci": [],
"hotplug": null,
"id": "103",
"initialization": [
{
"datastore_id": "local-lvm",
"dns": [],
"file_format": "",
"interface": "ide2",
"ip_config": [
{
"ipv4": [
{
"address": "dhcp",
"gateway": ""
}
],
"ipv6": []
}
],
"meta_data_file_id": "",
"network_data_file_id": "",
"type": "",
"upgrade": true,
"user_account": [
{
"keys": null,
"password": "**********",
"username": "root"
}
],
"user_data_file_id": "",
"vendor_data_file_id": ""
}
],
"ipv4_addresses": [],
"ipv6_addresses": [],
"keyboard_layout": "en-us",
"kvm_arguments": "",
"mac_addresses": [
"BC:24:11:BC:8C:9C"
],
"machine": "",
"memory": [
{
"dedicated": 2048,
"floating": 0,
"hugepages": "",
"keep_hugepages": false,
"shared": 0
}
],
"migrate": false,
"name": "ubuntu-cloud-vm-2",
"network_device": [
{
"bridge": "vmbr1",
"disconnected": false,
"enabled": true,
"firewall": false,
"mac_address": "BC:24:11:BC:8C:9C",
"model": "virtio",
"mtu": 0,
"queues": 0,
"rate_limit": 0,
"trunks": "",
"vlan_id": 0
}
],
"network_interface_names": [],
"node_name": "pve1",
"numa": [],
"on_boot": true,
"operating_system": [],
"pool_id": "",
"protection": false,
"purge_on_destroy": true,
"reboot": false,
"reboot_after_update": true,
"rng": [],
"scsi_hardware": "virtio-scsi-pci",
"serial_device": [],
"smbios": [],
"started": true,
"startup": [],
"stop_on_destroy": false,
"tablet_device": true,
"tags": null,
"template": false,
"timeout_clone": 1800,
"timeout_create": 1800,
"timeout_migrate": 1800,
"timeout_move_disk": 1800,
"timeout_reboot": 1800,
"timeout_shutdown_vm": 1800,
"timeout_start_vm": 1800,
"timeout_stop_vm": 300,
"tpm_state": [],
"usb": [],
"vga": [],
"virtiofs": [],
"vm_id": 103,
"watchdog": []
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "initialization"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "user_account"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "password"
}
]
],
"identity_schema_version": 0,
"private": "bnVsbA==",
"dependencies": [
"data.proxmox_files.ubuntu_image"
]
},
{
"index_key": 2,
"schema_version": 0,
"attributes": {
"acpi": true,
"agent": [],
"amd_sev": [],
"audio_device": [],
"bios": "seabios",
"boot_order": [
"scsi0",
"net0"
],
"cdrom": [],
"clone": [],
"cpu": [
{
"affinity": "",
"architecture": "",
"cores": 2,
"flags": null,
"hotplugged": 0,
"limit": 0,
"numa": false,
"sockets": 1,
"type": "qemu64",
"units": 0
}
],
"delete_unreferenced_disks_on_destroy": true,
"description": "",
"disk": [
{
"aio": "io_uring",
"backup": true,
"cache": "none",
"datastore_id": "truenas_lvm",
"discard": "ignore",
"file_format": "raw",
"file_id": "",
"import_from": "local:import/jammy-server-cloudimg-amd64.qcow2",
"interface": "scsi0",
"iothread": false,
"path_in_datastore": "vm-104-disk-0",
"replicate": true,
"serial": "",
"size": 8,
"speed": [],
"ssd": false
}
],
"efi_disk": [],
"hook_script_file_id": null,
"hostpci": [],
"hotplug": null,
"id": "104",
"initialization": [
{
"datastore_id": "local-lvm",
"dns": [],
"file_format": "",
"interface": "ide2",
"ip_config": [
{
"ipv4": [
{
"address": "dhcp",
"gateway": ""
}
],
"ipv6": []
}
],
"meta_data_file_id": "",
"network_data_file_id": "",
"type": "",
"upgrade": true,
"user_account": [
{
"keys": null,
"password": "**********",
"username": "root"
}
],
"user_data_file_id": "",
"vendor_data_file_id": ""
}
],
"ipv4_addresses": [],
"ipv6_addresses": [],
"keyboard_layout": "en-us",
"kvm_arguments": "",
"mac_addresses": [
"BC:24:11:7C:BB:37"
],
"machine": "",
"memory": [
{
"dedicated": 2048,
"floating": 0,
"hugepages": "",
"keep_hugepages": false,
"shared": 0
}
],
"migrate": false,
"name": "ubuntu-cloud-vm-3",
"network_device": [
{
"bridge": "vmbr1",
"disconnected": false,
"enabled": true,
"firewall": false,
"mac_address": "BC:24:11:7C:BB:37",
"model": "virtio",
"mtu": 0,
"queues": 0,
"rate_limit": 0,
"trunks": "",
"vlan_id": 0
}
],
"network_interface_names": [],
"node_name": "pve1",
"numa": [],
"on_boot": true,
"operating_system": [],
"pool_id": "",
"protection": false,
"purge_on_destroy": true,
"reboot": false,
"reboot_after_update": true,
"rng": [],
"scsi_hardware": "virtio-scsi-pci",
"serial_device": [],
"smbios": [],
"started": true,
"startup": [],
"stop_on_destroy": false,
"tablet_device": true,
"tags": null,
"template": false,
"timeout_clone": 1800,
"timeout_create": 1800,
"timeout_migrate": 1800,
"timeout_move_disk": 1800,
"timeout_reboot": 1800,
"timeout_shutdown_vm": 1800,
"timeout_start_vm": 1800,
"timeout_stop_vm": 300,
"tpm_state": [],
"usb": [],
"vga": [],
"virtiofs": [],
"vm_id": 104,
"watchdog": []
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "initialization"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "user_account"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "password"
}
]
],
"identity_schema_version": 0,
"private": "bnVsbA==",
"dependencies": [
"data.proxmox_files.ubuntu_image"
]
} }
] ]
} }
+322 -17
View File
@@ -1,7 +1,7 @@
{ {
"version": 4, "version": 4,
"terraform_version": "1.15.1", "terraform_version": "1.15.1",
"serial": 4, "serial": 27,
"lineage": "932f91fd-26ce-0c13-df63-09cd25a0eb0f", "lineage": "932f91fd-26ce-0c13-df63-09cd25a0eb0f",
"outputs": { "outputs": {
"vm_status": { "vm_status": {
@@ -16,10 +16,39 @@
} }
}, },
"resources": [ "resources": [
{
"mode": "data",
"type": "proxmox_files",
"name": "ubuntu_image",
"provider": "provider[\"registry.terraform.io/bpg/proxmox\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"content_type": "import",
"datastore_id": "local",
"file_name_regex": "jammy",
"files": [
{
"content_type": "import",
"file_format": "qcow2",
"file_name": "jammy-server-cloudimg-amd64.qcow2",
"file_size": 692407808,
"id": "local:import/jammy-server-cloudimg-amd64.qcow2",
"vmid": null
}
],
"node_name": "pve1"
},
"sensitive_attributes": [],
"identity_schema_version": 0
}
]
},
{ {
"mode": "managed", "mode": "managed",
"type": "proxmox_virtual_environment_vm", "type": "proxmox_virtual_environment_vm",
"name": "ma_super_vm", "name": "vm_ubuntu_iscsi",
"provider": "provider[\"registry.terraform.io/bpg/proxmox\"]", "provider": "provider[\"registry.terraform.io/bpg/proxmox\"]",
"instances": [ "instances": [
{ {
@@ -31,16 +60,210 @@
"audio_device": [], "audio_device": [],
"bios": "seabios", "bios": "seabios",
"boot_order": [ "boot_order": [
"ide3", "scsi0",
"net0" "net0"
], ],
"cdrom": [ "cdrom": [],
"clone": [],
"cpu": [
{ {
"enabled": false, "affinity": "",
"file_id": "local:iso/alpine-standard-3.23.4-x86_64.iso", "architecture": "",
"interface": "ide3" "cores": 2,
"flags": null,
"hotplugged": 0,
"limit": 0,
"numa": false,
"sockets": 1,
"type": "qemu64",
"units": 0
} }
], ],
"delete_unreferenced_disks_on_destroy": true,
"description": "",
"disk": [
{
"aio": "io_uring",
"backup": true,
"cache": "none",
"datastore_id": "truenas_lvm",
"discard": "ignore",
"file_format": "raw",
"file_id": "",
"import_from": "local:import/jammy-server-cloudimg-amd64.qcow2",
"interface": "scsi0",
"iothread": false,
"path_in_datastore": "vm-101-disk-0",
"replicate": true,
"serial": "",
"size": 8,
"speed": [],
"ssd": false
}
],
"efi_disk": [],
"hook_script_file_id": null,
"hostpci": [],
"hotplug": null,
"id": "101",
"initialization": [
{
"datastore_id": "local-lvm",
"dns": [],
"file_format": "",
"interface": "ide2",
"ip_config": [
{
"ipv4": [
{
"address": "dhcp",
"gateway": ""
}
],
"ipv6": []
}
],
"meta_data_file_id": "",
"network_data_file_id": "",
"type": "",
"upgrade": true,
"user_account": [
{
"keys": null,
"password": "**********",
"username": "root"
}
],
"user_data_file_id": "",
"vendor_data_file_id": ""
}
],
"ipv4_addresses": [],
"ipv6_addresses": [],
"keyboard_layout": "en-us",
"kvm_arguments": "",
"mac_addresses": [
"BC:24:11:FB:1B:D9"
],
"machine": "",
"memory": [
{
"dedicated": 2048,
"floating": 0,
"hugepages": "",
"keep_hugepages": false,
"shared": 0
}
],
"migrate": false,
"name": "ubuntu-cloud-vm-iscsi",
"network_device": [
{
"bridge": "vmbr1",
"disconnected": false,
"enabled": true,
"firewall": false,
"mac_address": "BC:24:11:FB:1B:D9",
"model": "virtio",
"mtu": 0,
"queues": 0,
"rate_limit": 0,
"trunks": "",
"vlan_id": 0
}
],
"network_interface_names": [],
"node_name": "pve1",
"numa": [],
"on_boot": true,
"operating_system": [],
"pool_id": "",
"protection": false,
"purge_on_destroy": true,
"reboot": false,
"reboot_after_update": true,
"rng": [],
"scsi_hardware": "virtio-scsi-pci",
"serial_device": [],
"smbios": [],
"started": true,
"startup": [],
"stop_on_destroy": false,
"tablet_device": true,
"tags": null,
"template": false,
"timeout_clone": 1800,
"timeout_create": 1800,
"timeout_migrate": 1800,
"timeout_move_disk": 1800,
"timeout_reboot": 1800,
"timeout_shutdown_vm": 1800,
"timeout_start_vm": 1800,
"timeout_stop_vm": 300,
"tpm_state": [],
"usb": [],
"vga": [],
"virtiofs": [],
"vm_id": 101,
"watchdog": []
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "initialization"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "user_account"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "password"
}
]
],
"identity_schema_version": 0,
"private": "bnVsbA==",
"dependencies": [
"data.proxmox_files.ubuntu_image"
]
}
]
},
{
"mode": "managed",
"type": "proxmox_virtual_environment_vm",
"name": "vm_ubuntu_local",
"provider": "provider[\"registry.terraform.io/bpg/proxmox\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"acpi": true,
"agent": [],
"amd_sev": [],
"audio_device": [],
"bios": "seabios",
"boot_order": [
"scsi0",
"net0"
],
"cdrom": [],
"clone": [], "clone": [],
"cpu": [ "cpu": [
{ {
@@ -58,19 +281,69 @@
], ],
"delete_unreferenced_disks_on_destroy": true, "delete_unreferenced_disks_on_destroy": true,
"description": "", "description": "",
"disk": [], "disk": [
{
"aio": "io_uring",
"backup": true,
"cache": "none",
"datastore_id": "local-lvm",
"discard": "ignore",
"file_format": "raw",
"file_id": "",
"import_from": "local:import/jammy-server-cloudimg-amd64.qcow2",
"interface": "scsi0",
"iothread": false,
"path_in_datastore": "vm-102-disk-0",
"replicate": true,
"serial": "",
"size": 8,
"speed": [],
"ssd": false
}
],
"efi_disk": [], "efi_disk": [],
"hook_script_file_id": null, "hook_script_file_id": null,
"hostpci": [], "hostpci": [],
"hotplug": null, "hotplug": null,
"id": "1000", "id": "102",
"initialization": [], "initialization": [
{
"datastore_id": "local-lvm",
"dns": [],
"file_format": "",
"interface": "ide2",
"ip_config": [
{
"ipv4": [
{
"address": "dhcp",
"gateway": ""
}
],
"ipv6": []
}
],
"meta_data_file_id": "",
"network_data_file_id": "",
"type": "",
"upgrade": true,
"user_account": [
{
"keys": [],
"password": "**********",
"username": "root"
}
],
"user_data_file_id": "",
"vendor_data_file_id": ""
}
],
"ipv4_addresses": [], "ipv4_addresses": [],
"ipv6_addresses": [], "ipv6_addresses": [],
"keyboard_layout": "en-us", "keyboard_layout": "en-us",
"kvm_arguments": "", "kvm_arguments": "",
"mac_addresses": [ "mac_addresses": [
"BC:24:11:C1:5F:18" "BC:24:11:52:A8:CA"
], ],
"machine": "", "machine": "",
"memory": [ "memory": [
@@ -83,14 +356,14 @@
} }
], ],
"migrate": false, "migrate": false,
"name": "vm-terraform-demo", "name": "ubuntu-cloud-vm-local",
"network_device": [ "network_device": [
{ {
"bridge": "vmbr0", "bridge": "vmbr1",
"disconnected": false, "disconnected": false,
"enabled": true, "enabled": true,
"firewall": false, "firewall": false,
"mac_address": "BC:24:11:C1:5F:18", "mac_address": "BC:24:11:52:A8:CA",
"model": "virtio", "model": "virtio",
"mtu": 0, "mtu": 0,
"queues": 0, "queues": 0,
@@ -131,12 +404,44 @@
"usb": [], "usb": [],
"vga": [], "vga": [],
"virtiofs": [], "virtiofs": [],
"vm_id": 1000, "vm_id": 102,
"watchdog": [] "watchdog": []
}, },
"sensitive_attributes": [], "sensitive_attributes": [
[
{
"type": "get_attr",
"value": "initialization"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "user_account"
},
{
"type": "index",
"value": {
"value": 0,
"type": "number"
}
},
{
"type": "get_attr",
"value": "password"
}
]
],
"identity_schema_version": 0, "identity_schema_version": 0,
"private": "bnVsbA==" "private": "bnVsbA==",
"dependencies": [
"data.proxmox_files.ubuntu_image"
]
} }
] ]
} }