This commit is contained in:
parent
7b3c46248c
commit
30c250c66a
@ -21,6 +21,10 @@ jobs:
|
||||
with:
|
||||
terraform_version: 1.6.6
|
||||
|
||||
- name: Inject sensitive secrets
|
||||
run: |
|
||||
echo 'proxmox_password = "${{ secrets.PROXMOX_PASSWORD }}"' >> terraform.tfvars
|
||||
|
||||
- name: Terraform Init
|
||||
run: terraform init
|
||||
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,2 @@
|
||||
./terraform/.terraform
|
||||
./terraform/terraform.tfvars
|
||||
terraform.tfvars
|
||||
*.tfvars
|
||||
terraform/.terraform/
|
||||
|
@ -14,10 +14,10 @@ provider "proxmox" {
|
||||
pm_tls_insecure = true
|
||||
}
|
||||
|
||||
resource "proxmox_vm_qemu" "alpine" {
|
||||
count = var.vm_count
|
||||
vmid = 400 + count.index + 1
|
||||
name = "Alpine-${count.index + 1}"
|
||||
resource "proxmox_vm_qemu" "alpacas" {
|
||||
count = var.alpaca_count
|
||||
vmid = 500 + count.index
|
||||
name = "alpaca-${count.index + 1}"
|
||||
target_node = var.target_node
|
||||
clone = var.clone_template
|
||||
sockets = var.sockets
|
||||
@ -25,7 +25,6 @@ resource "proxmox_vm_qemu" "alpine" {
|
||||
memory = var.memory
|
||||
agent = 1
|
||||
boot = "order=scsi0"
|
||||
os_type = "cloud-init"
|
||||
|
||||
disk {
|
||||
slot = "scsi0"
|
||||
@ -39,7 +38,32 @@ resource "proxmox_vm_qemu" "alpine" {
|
||||
model = "virtio"
|
||||
bridge = var.bridge
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_vm_qemu" "llamas" {
|
||||
count = var.llama_count
|
||||
vmid = 600 + count.index
|
||||
name = "llama-${count.index + 1}"
|
||||
target_node = var.target_node
|
||||
clone = var.clone_template
|
||||
sockets = var.sockets
|
||||
cores = var.cores
|
||||
memory = var.memory
|
||||
agent = 1
|
||||
boot = "order=scsi0"
|
||||
|
||||
disk {
|
||||
slot = "scsi0"
|
||||
type = "disk"
|
||||
size = var.disk_size
|
||||
storage = var.storage
|
||||
}
|
||||
|
||||
network {
|
||||
id = 0
|
||||
model = "virtio"
|
||||
bridge = var.bridge
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
output "vm_ids" {
|
||||
description = "VM IDs by name"
|
||||
output "alpaca_vm_ids" {
|
||||
value = {
|
||||
for i in range(var.vm_count) :
|
||||
"Alpine-${i + 1}" => proxmox_vm_qemu.alpine[i].vmid
|
||||
for i in range(var.alpaca_count) :
|
||||
"alpaca-${i + 1}" => proxmox_vm_qemu.alpacas[i].vmid
|
||||
}
|
||||
}
|
||||
|
||||
output "vm_names" {
|
||||
description = "VM names"
|
||||
value = [
|
||||
for vm in proxmox_vm_qemu.alpine : vm.name
|
||||
]
|
||||
output "alpaca_vm_names" {
|
||||
value = [for vm in proxmox_vm_qemu.alpacas : vm.name]
|
||||
}
|
||||
|
||||
output "vm_clones" {
|
||||
description = "Template names each VM was cloned from"
|
||||
value = [
|
||||
for vm in proxmox_vm_qemu.alpine : vm.clone
|
||||
]
|
||||
output "llama_vm_ids" {
|
||||
value = {
|
||||
for i in range(var.llama_count) :
|
||||
"llama-${i + 1}" => proxmox_vm_qemu.llamas[i].vmid
|
||||
}
|
||||
}
|
||||
|
||||
output "llama_vm_names" {
|
||||
value = [for vm in proxmox_vm_qemu.llamas : vm.name]
|
||||
}
|
||||
|
||||
|
13
terraform/terraform.tfvars
Normal file
13
terraform/terraform.tfvars
Normal file
@ -0,0 +1,13 @@
|
||||
target_node = "flex"
|
||||
clone_template = "Alpine-Template"
|
||||
vm_name = "alpine-vm"
|
||||
cores = 2
|
||||
memory = 2048
|
||||
disk_size = "15G"
|
||||
sockets = 1
|
||||
bridge = "vmbr0"
|
||||
disk_type = "scsi"
|
||||
storage = "Flash"
|
||||
pm_api_url = "https://100.105.0.115:8006/api2/json"
|
||||
pm_user = "terraform-prov@pve"
|
||||
|
@ -50,9 +50,15 @@ variable "pm_user" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "vm_count" {
|
||||
variable "alpaca_count" {
|
||||
type = number
|
||||
description = "How many Alpine VMs to create"
|
||||
default = 3
|
||||
default = 1
|
||||
description = "How many Alpaca VMs to create"
|
||||
}
|
||||
|
||||
variable "llama_count" {
|
||||
type = number
|
||||
default = 1
|
||||
description = "How many Llama VMs to create"
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user