rc 2
All checks were successful
Deploy VM and App / terraform-ansible-deploy (push) Successful in 2m16s

This commit is contained in:
CC
2026-09-12 17:35:07 +01:00
parent 36bef8119f
commit 6e56d3960b
7 changed files with 47 additions and 82 deletions

View File

@@ -1,26 +0,0 @@
locals {
inventory = {
all = {
vars = {
ansible_user = "cloud"
}
children = {
for svc in distinct([for k, v in var.instances : v.service_name]) :
svc => {
hosts = {
for k, v in var.instances :
v.vm_name => {
ansible_host = v.ipv4_address
}
if v.service_name == svc
}
}
}
}
}
}
resource "local_file" "inventory" {
filename = var.filename
content = yamlencode(local.inventory)
}

View File

@@ -1,7 +0,0 @@
output "filename" {
value = local_file.inventory.filename
}
output "content" {
value = local_file.inventory.content
}

View File

@@ -1,13 +0,0 @@
variable "filename" {
description = "Path to write the inventory.yml file"
type = string
}
variable "instances" {
description = "Normalized instance map keyed by instance key"
type = map(object({
service_name = string
vm_name = string
ipv4_address = string
}))
}

View File

@@ -4,6 +4,9 @@ variable "pm_api_token" { default = "terraform@pve!provider=760580c4-5c1f-462b-9
variable "storage" { default = "hlst" }
variable "bridge" { default = "vmbr0" }
variable "os_type" {
default = "alpine"
}
variable "instance_configs" {
type = list(object({
@@ -104,9 +107,16 @@ variable "vm_name" {
default = "Lab"
}
variable "service_name" {
description = "Folder name of the services"
type = string
default = "Lab"
}
variable "vm_user_sshkey" {
description = "Admin user SSH key of the VM"
type = string
default = ""
}
@@ -133,4 +143,15 @@ variable "vm_user" {
description = "Admin user of the VM"
type = string
default = "cloud"
}
variable "compose_file_content" {
description = "Rendered contents of docker-compose.yml to write to the VM"
type = string
}
variable "env_file_content" {
description = "Rendered contents of .env to write to the VM"
type = string
sensitive = true
}