n8n ansible base

This commit is contained in:
CC
2026-05-21 13:12:12 +01:00
parent db9cc7909b
commit 089b099f7f
10 changed files with 152 additions and 18 deletions

View File

@@ -0,0 +1,26 @@
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

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

View File

@@ -0,0 +1,13 @@
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

@@ -0,0 +1,17 @@
locals {
vm_data = {
vm_tag_data = {
for k, v in var.instances :
k => {
node_name = v.node_name
vm_name = v.vm_name
tags = v.vm_tags
}
}
}
}
resource "local_file" "vm_data" {
filename = var.filename
content = yamlencode(local.vm_data)
}

View File

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

View File

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