From 016fbf24698cb69e05648b6840050506189f1d80 Mon Sep 17 00:00:00 2001 From: Alex-Devera Date: Tue, 30 Sep 2025 09:06:27 +0000 Subject: [PATCH] Upload files to "/" --- main.tf | 45 +++++++++++++++++++++++++++++++++++++++++++++ terraform.tfvars | 3 +++ variables.tf | 12 ++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 main.tf create mode 100644 terraform.tfvars create mode 100644 variables.tf diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..c38a128 --- /dev/null +++ b/main.tf @@ -0,0 +1,45 @@ +terraform { + required_providers { + proxmox = { + source = "Telmate/proxmox" + version = ">= 3.0.0" # подбери подходящую версию под твой PVE + } + } +} + +provider "proxmox" { + pm_api_url = var.pm_api_url + pm_api_token_id = var.pm_api_token_id + pm_api_token_secret = var.pm_api_token_secret + pm_tls_insecure = true +} + +resource "proxmox_vm_qemu" "vm" { + name = var.name + vmid = var.vmid + target_node = var.target_node + clone = var.clone_template # имя шаблона, если клонируем + os_type = "cloud-init" # если шаблон cloud-init + cpu { + cores = 2 + sockets = 1 + type = host + } + memory = 2048 + scsihw = "virtio-scsi-single" + + # пример сетевого блока + network { + id = 0 + model = "virtio" + bridge = var.bridge # обычно vmbr0 + } + + # cloud-init параметры (если шаблон cloud-init) + ciuser = var.ci_user + cipassword = var.ci_password + ipconfig0 = var.ipconfig0 # e.g. "ip=192.168.1.50/24,gw=192.168.1.1" или "ip=dhcp" + sshkeys = file(var.ssh_pubkey_path) + + # если нужно — можно добавить disk {} или disks {} в зависимости от версии провайдера +} \ No newline at end of file diff --git a/terraform.tfvars b/terraform.tfvars new file mode 100644 index 0000000..1319ea5 --- /dev/null +++ b/terraform.tfvars @@ -0,0 +1,3 @@ +pm_api_url = "https://192.168.31.30:8006/api2/json" +pm_api_token_id = "tofu@pve!infra" # твой токен ID +pm_api_token_secret = "f9f493f5-c6a0-4541-9000-e747d3216516" \ No newline at end of file diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..cb50d85 --- /dev/null +++ b/variables.tf @@ -0,0 +1,12 @@ +variable "pm_api_url" {} +variable "pm_api_token_id" {} +variable "pm_api_token_secret" {} +variable "target_node" { default = "pve" } +variable "name" { default = "otf-vm-1" } +variable "vmid" { default = 101 } +variable "clone_template" { default = "ubuntu-cloud-template" } +variable "bridge" { default = "vmbr0" } +variable "ci_user" { default = "alex" } +variable "ci_password" { default = "470389" } +variable "ipconfig0" { default = "ip=dhcp" } +variable "ssh_pubkey_path" { default = "~/.ssh/id_rsa.pub" }