summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjerome <jerome@xlinfo.fr>2025-01-27 12:57:15 +0100
committerjerome <jerome@xlinfo.fr>2025-01-27 12:57:15 +0100
commit4e0a104ef04ee5e1787c5c205a691775fb37d03a (patch)
treee81539be4664c3da51de1ecb7bbad39d82cbf375
downloadproxmox_vm-4e0a104ef04ee5e1787c5c205a691775fb37d03a.tar.gz
proxmox_vm-4e0a104ef04ee5e1787c5c205a691775fb37d03a.zip
commit initial
-rw-r--r--main.tf70
1 files changed, 70 insertions, 0 deletions
diff --git a/main.tf b/main.tf
new file mode 100644
index 0000000..364b378
--- /dev/null
+++ b/main.tf
@@ -0,0 +1,70 @@
+terraform {
+ required_providers {
+ proxmox = {
+ source = "telmate/proxmox"
+ version = "3.0.1-rc6"
+ }
+ }
+}
+
+provider "proxmox" {
+ pm_api_url = "https://pve.xlinfo.fr:8006/api2/json"
+ pm_user = "stagiaire@pve"
+ pm_password = "terraform"
+}
+
+resource "proxmox_vm_qemu" "stagiaire" {
+ vmid = 201
+ name = "ubuntu-prenom"
+ target_node = "pve"
+ clone = "ubuntu-cloud"
+
+ agent = 1
+ os_type = "cloud-init"
+
+ cores = 1
+ sockets = 1
+ cpu_type = "host"
+ memory = 1024
+ balloon = 512
+ scsihw = "virtio-scsi-pci"
+ bootdisk = "scsi0"
+ disks {
+ scsi {
+ scsi0 {
+ disk {
+ storage = "local-lvm"
+ size = "8G"
+ }
+ }
+ }
+ ide {
+ ide1 {
+ cloudinit {
+ storage = "local-lvm"
+ }
+ }
+ }
+ }
+
+ network {
+ id = 0
+ model = "virtio"
+ bridge = "vmbr0"
+ }
+ vm_state = "started"
+
+ # Cloud-Init configuration
+ ciuser = "ansible"
+ cipassword = "secret"
+ sshkeys = <<-EOT
+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCZJG/XcIIvW0JOJb6ftEpopS4szOo8dRehASGIOAswPRko6JFMT9QuAvl9YkmzgSorn0KpyQrqAxNTklADocMGPW2BJzKb/1fQyZYKY9bLXxyKaYZKbDZNaUJmW92ThDmUrIWPgjh5BhUxOTwRbDhTsRu/pvulnGw+8yOp7Tz8nUgAoJEZ/7fGkm7AaJPLmF/szQEhL/WSNqTtNdCHNYpQqgRIUZh5zqcb2jXa0pZ7GMnPmoSUMlz1OfAxMOIuziaP3i1J/KHVhXdxj4nrOtUjrUULfqk9vyfKkf7BLYKO3fO3BLR9H5HgeTlaB2aXNuDgRAQposNZ0FEK/VkWj+DQuqjuj9nYo57GbfMfhWr/dTKxTVj3xsbFdThDWtlp7sVI2jguqntwwlmhhexJp1fAYZn92KYkaxGHWLbR0bxLEWVjHXciVW2D12IUZfGWXh5wInoQN1gs1i6NUqgf1uDZhAax5H9G07YySR2fnM9TB5c5apyf7PFCg1kZAnqVHrE= jerome@parrot
+ EOT
+ ipconfig0 = "ip=dhcp,ip6=auto"
+}
+
+output "vm_ip_address_default" {
+ description = "Current IP Default"
+ value = proxmox_vm_qemu.stagiaire.*.default_ipv4_address
+}
+