Formatting and friends

This commit is contained in:
Greyscale 2024-12-22 07:44:10 +01:00
parent 4927ecba4a
commit b679424f8f
Signed by: grey
GPG key ID: DDB392AE64B32D89
13 changed files with 128 additions and 7 deletions

View file

@ -7,4 +7,7 @@ output "postgres" {
output "endpoint" {
value = module.forgejo.endpoint
}
output "network" {
value = module.forgejo_network.network
}

View file

@ -39,9 +39,9 @@ variable "mounts" {
variable "ports" {
type = list(object({
host = optional(number, null)
host = optional(number, null)
container = number
protocol = optional(string, "tcp")
protocol = optional(string, "tcp")
}))
default = []
}

View file

@ -21,9 +21,9 @@ module "minio" {
MINIO_SERVER_URL = "https://${var.domain}"
MINIO_BROWSER_REDIRECT_URL = "https://${var.domain}/ui/"
#MINIO_BROWSER_REDIRECT = true
MINIO_API_ROOT_ACCESS = "on"
MINIO_API_ROOT_ACCESS = "on"
}
ports = var.ports
ports = var.ports
mounts = var.mounts
networks = var.networks
placement_constraints = var.placement_constraints
@ -48,7 +48,7 @@ module "minio" {
"traefik.http.middlewares.minio_ui.stripprefix.prefixes" = "/ui"
# Attach the middleware to the UI router
"traefik.http.routers.minio_ui.middlewares" = "minio_ui"
"traefik.http.routers.minio_ui.middlewares" = "minio_ui"
}
}

View file

@ -0,0 +1,28 @@
variable "placement_constraints" {
default = []
type = list(string)
description = "Docker Swarm placement constraints"
}
variable "networks" {
type = list(object({
name = string
id = string
}))
default = []
description = "A list of network names to attach the service to."
}
variable "traefik" {
default = null
type = object({
domain = string
port = optional(number, 80)
ssl = optional(bool)
})
description = "Whether to enable traefik for the service."
}
variable "email" {
description = "The email address to use for the pgadmin login"
type = string
}

View file

@ -0,0 +1,49 @@
resource "random_password" "default" {
length = 32
special = false
}
variable "servers" {
type = list(object({
Name = string
Group = optional(string)
Host = string
Port = number
Username = string
SSLMode = optional(string, "prefer")
MaintenanceDB = optional(string, "postgres")
Comment = optional(string, null)
UseSSHTunnel = optional(bool, null)
TunnelHost = optional(string, null)
TunnelPort = optional(number, null)
TunnelUsername = optional(string, null)
TunnelAuthentication = optional(string, null)
}))
}
module "pgadmin" {
source = "../../docker/service"
image = "dpage/pgadmin4:8"
service_name = "pgadmin"
stack_name = "pgadmin"
placement_constraints = var.placement_constraints
networks = var.networks
traefik = var.traefik
environment_variables = {
PGADMIN_DEFAULT_EMAIL = var.email
PGADMIN_DEFAULT_PASSWORD = nonsensitive(random_password.default.result)
}
configs = {
"/pgadmin4/servers.json" = jsonencode({
Servers = { for server in var.servers : index(var.servers, server) => server }
})
}
healthcheck = ["CMD", "wget", "-q", "-O", "-", "http://localhost:80/misc/ping"]
healthcheck_start_period = "60s"
converge_timeout = "5m"
}
output "credentials" {
value = {
username = var.email
password = nonsensitive(random_password.default.result)
}
}

View file

@ -0,0 +1,15 @@
terraform {
required_version = "~> 1.6"
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}

View file

@ -4,4 +4,8 @@ output "docker_service" {
output "postgres" {
value = module.postgres
}
output "network" {
value = module.network.network
}

View file

@ -19,4 +19,16 @@ output "docker_service" {
output "endpoint" {
value = "postgres://${local.username}:${local.password}@${module.service.service_name}:5432/${local.database}"
}
output "pgadmin_config" {
value = {
"Group" = var.stack_name
"Name" = module.service.service_name
"Host" = module.service.service_name
"Port" = 5432
"Username" = local.username
"MaintenanceDB" = local.database
"Comment" = "${var.stack_name} ${local.database} database"
}
}

View file

@ -19,4 +19,8 @@ output "postgres_service" {
}
output "postgres" {
value = module.postgres
}
output "network" {
value = module.network.network
}

View file

@ -9,4 +9,7 @@ output "ports" {
}
output "docker_service" {
value = module.service.docker_service
}
output "endpoint" {
value = "redis://${module.service.service_name}:6379"
}

View file

@ -7,7 +7,7 @@ variable "traefik" {
default = null
type = object({
domain = string
port = optional(number)
port = optional(number,80)
ssl = optional(bool, false)
rule = optional(string)
})

View file

@ -49,7 +49,7 @@ variable "traefik" {
default = null
type = object({
domain = string
port = optional(number)
port = optional(number,8080)
ssl = optional(bool, false)
rule = optional(string)
})

View file

@ -16,4 +16,7 @@ output "endpoint" {
}
output "postgres" {
value = module.postgres
}
output "network" {
value = module.network.network
}