add terraform

This commit is contained in:
oleg.vodyanov91@gmail.com 2025-05-17 23:54:26 +04:00
parent 485dfe038e
commit fc74760828
9 changed files with 90 additions and 1 deletions

7
.gitignore vendored
View File

@ -1 +1,6 @@
.venv
.venv
*terraform.tfvars
*tfstate
*tfstate.*
terraform/.terraform.lock.hcl
**/.terraform/

15
terraform/main.tf Normal file
View File

@ -0,0 +1,15 @@
provider "proxmox" {
pm_api_url = var.pm_api_url
pm_user = var.pm_user
pm_password = var.pm_password
pm_tls_insecure = true
}
module "vm" {
source = "./modules/vm"
vm_name = var.vm_name
#vm_template = var.vm_template
target_node = var.target_node
ssh_public_key = var.ssh_public_key
}

View File

@ -0,0 +1,36 @@
resource "proxmox_vm_qemu" "vm" {
name = var.vm_name
target_node = var.target_node
#clone = var.vm_template
full_clone = true
cpu {
cores = 2
sockets = 1
}
memory = 2048
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"
network {
id = 0
model = "virtio"
bridge = "vmbr0"
}
disk {
iso = "local:iso/ubuntu-24.04.2-live-server-amd64.iso"
slot = "scsi0"
type = "cdrom"
}
disk {
size = "20G"
type = "disk"
storage = "local-lvm"
slot = "scsi1"
}
sshkeys = var.ssh_public_key
}

View File

@ -0,0 +1,3 @@
output "vm_name" {
value = proxmox_vm_qemu.vm.name
}

View File

@ -0,0 +1,4 @@
variable "vm_name" {}
#variable "vm_template" {}
variable "target_node" {}
variable "ssh_public_key" {}

View File

@ -0,0 +1,8 @@
terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "3.0.1-rc9"
}
}
}

3
terraform/outputs.tf Normal file
View File

@ -0,0 +1,3 @@
output "vm_name" {
value = module.vm.vm_name
}

7
terraform/variables.tf Normal file
View File

@ -0,0 +1,7 @@
variable "pm_api_url" {}
variable "pm_user" {}
variable "pm_password" {}
variable "vm_name" {}
#variable "vm_template" {}
variable "target_node" {}
variable "ssh_public_key" {}

8
terraform/versions.tf Normal file
View File

@ -0,0 +1,8 @@
terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "3.0.1-rc9"
}
}
}