create multiple-vm project

This commit is contained in:
Vezpi 2025-03-23 22:55:30 +00:00
parent 0513f40af0
commit 3e5d65773c
9 changed files with 70 additions and 27 deletions

View File

@ -10,7 +10,7 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
datastore_id = "local"
node_name = var.node_name
source_raw {
file_name = "vm.cloud-config.yaml"
file_name = "${var.vm_name}.cloud-config.yaml"
data = <<-EOF
#cloud-config
hostname: ${var.vm_name}

View File

@ -5,14 +5,3 @@ terraform {
}
}
}
provider "proxmox" {
endpoint = var.proxmox_endpoint
api_token = var.proxmox_api_token
insecure = false
ssh {
agent = false
private_key = file("~/.ssh/id_ed25519")
username = "root"
}
}

View File

@ -1,14 +1,3 @@
variable "proxmox_endpoint" {
description = "Proxmox URL endpoint"
type = string
}
variable "proxmox_api_token" {
description = "Proxmox API token"
type = string
sensitive = true
}
variable "node_name" {
description = "Proxmox host for the VM"
type = string

View File

@ -1,7 +1,5 @@
module "pve_vm" {
source = "../../modules/pve_vm"
proxmox_endpoint = var.proxmox_endpoint
proxmox_api_token = var.proxmox_api_token
node_name = "zenith"
vm_name = "zenith-vm"
vm_cpu = 2

View File

@ -0,0 +1,18 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
}
}
}
provider "proxmox" {
endpoint = var.proxmox_endpoint
api_token = var.proxmox_api_token
insecure = false
ssh {
agent = false
private_key = file("~/.ssh/id_ed25519")
username = "root"
}
}

View File

@ -1,2 +1,10 @@
variable "proxmox_endpoint" {}
variable "proxmox_api_token" {}
variable "proxmox_endpoint" {
description = "Proxmox URL endpoint"
type = string
}
variable "proxmox_api_token" {
description = "Proxmox API token"
type = string
sensitive = true
}

View File

@ -0,0 +1,13 @@
module "pve_vm" {
source = "../../modules/pve_vm"
count = 2
node_name = "zenith"
vm_name = "zenith-vm-${count.index + 1}"
vm_cpu = 2
vm_ram = 2048
vm_vlan = 66
}
output "vm_ip" {
value = module.pve_vm[*].vm_ip
}

View File

@ -0,0 +1,18 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
}
}
}
provider "proxmox" {
endpoint = var.proxmox_endpoint
api_token = var.proxmox_api_token
insecure = false
ssh {
agent = false
private_key = file("~/.ssh/id_ed25519")
username = "root"
}
}

View File

@ -0,0 +1,10 @@
variable "proxmox_endpoint" {
description = "Proxmox URL endpoint"
type = string
}
variable "proxmox_api_token" {
description = "Proxmox API token"
type = string
sensitive = true
}