Add locals to main.tf

This commit is contained in:
2025-08-06 17:52:57 +00:00
parent 2fb1c45e87
commit 25c14e77d8
8 changed files with 127 additions and 19 deletions
+4
View File
@@ -7,6 +7,10 @@ module "services" {
source = "./services"
}
locals {
volume_host = "${module.system_globals.volume_host}/appdata"
}
module "caddy" {
source = "./modules/01-networking/caddy-service"
volume_path = "./docker/infrastructure/"
+1 -1
View File
@@ -95,7 +95,7 @@ resource "docker_volume" "caddy_config" {
// Create Caddyfile in the volume path
resource "local_file" "caddyfile" {
content = local.caddyfile_content
filename = "${var.volume_path}/caddy/Caddyfile"
filename = "${var.volume_path}/${image}/Caddyfile"
}
@@ -1,5 +1,3 @@
// Generic Docker service module
// Creates and manages a Docker container with configurable options
module "system_globals" {
source = "../../00-globals/system"
}
@@ -0,0 +1,64 @@
terraform {
required_providers {
dotenv = {
source = "germanbrew/dotenv"
}
}
}
locals {
container_name = "freeipa"
freeipa_image = "quay.io/repository/freeipa/freeipa-server"
freeipa_tag = var.image_tag
env_file = "${path.module}/.env"
freeipa_internal_port = 8443
freeipa_volumes = [
{
host_path = "${var.volume_path}/${local.container_name}/data"
container_path = "${var.volume_path}/${local.container_name}/data"
},
{
host_path = ""
container_path = "${var.volume_path}/${local.container_name}/data"
}
]
freeipa_env_vars = {
PASSWORD = var.admin_password
}
}
module "freeipa" {
source = "../../10-services-generic/docker-service"
container_name = local.container_name
image = local.freeipa_image
tag = local.freeipa_tag
volumes = local.freeipa_volumes
env_vars = local.freeipa_env_vars
networks = concat(var.networks)
restart_policy = "always"
}
output "service_definition" {
description = "General service definition with optional ingress configuration"
value = {
name = local.container_name
primary_port = local.freeipa_internal_port
endpoint = "http://${local.container_name}:${local.freeipa_internal_port}"
subdomains = ["ipa"]
ports = [
{
external = 8080
internal = 80
protocol = "tcp"
},
{
external = 8443
internal = 443
protocol = "tcp"
}
]
}
}
@@ -0,0 +1,40 @@
variable "image_tag" {
description = "The tag for the freeipa container image. Default: Latest"
type = string
default = "rocky-9"
}
variable "volume_path" {
description = "Base directory for volumes"
type = string
}
variable "networks" {
description = "List of networks to which the container should be attached"
type = list(string)
default = []
}
variable "user_id" {
description = "User ID for container permissions"
type = string
default = "1000"
}
variable "group_id" {
description = "Group ID for container permissions"
type = string
default = "1000"
}
variable "timezone" {
description = "Timezone for the container"
type = string
default = "Europe/Helsinki"
}
variable "admin_password" {
description = "Default password for logging into the IPA admin account"
type = string
}
+16
View File
@@ -14,4 +14,20 @@ module "homelab_docker_network" {
driver = "bridge"
attachable = true
subnet = "10.88.0.0/16"
}
module "freeipa" {
source = "${local.module_dir}/30-services-software/lldap-service"
volume_path = "${local.volume_path}/freeipa"
networks = [
module.homelab_docker_network.name
]
}
module "jellyfin" {
source = "${local.module_dir}/20-services-entertainment/jellyfin-service"
volume_path = "${local.volume_path}/jellyfin"
networks = [
module.homelab_docker_network.name
]
}
+2 -16
View File
@@ -1,22 +1,8 @@
output "service_definitions" {
description = "Service definitions for all services"
value = [
module.actualbudget.service_definition,
module.affine.service_definition,
module.calibre.service_definition,
module.copyparty.service_definition,
module.crawl4ai.service_definition,
module.emulatorjs.service_definition,
module.glance.service_definition,
module.linkwarden.service_definition,
module.n8n.service_definition,
module.n8n.n8n_mcp_service_definition,
module.nocodb.service_definition,
module.ntfy.service_definition,
module.portainer.service_definition,
module.pterodactyl_wings.service_definition,
module.pterodactyl_panel.service_definition,
module.searxng.service_definition
module.jellyfin.service_definition,
module.freeipa.service_definition,
]
}