OpenHaystack

This commit is contained in:
Greyscale 2025-01-21 17:47:14 +01:00
parent cd33dc7e05
commit 1bf407cf7a
Signed by: grey
GPG key ID: DDB392AE64B32D89
3 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,38 @@
# Pass-thru variables
variable "stack_name" {
type = string
}
variable "networks" {
type = list(object({
name = string
id = string
}))
default = []
description = "A list of network names to attach the service to."
}
variable "ports" {
type = list(object({
host = optional(number)
container = number
protocol = optional(string, "tcp")
}))
default = []
description = "A map of port mappings to expose on the host. The key is the host port, and the value is the container port."
validation {
error_message = "Host Ports must be between 1024 and 65535 or null."
condition = alltrue([for port in var.ports : port.host == null ? true : (port.host >= 1024 && port.host <= 65535)])
}
validation {
error_message = "Container Ports must be between 1 and 65535."
condition = alltrue([for port in var.ports : port.container >= 1 && port.container <= 65535])
}
validation {
error_message = "Protocol must be either 'tcp' or 'udp'."
condition = alltrue([for port in var.ports : port.protocol == "tcp" || port.protocol == "udp"])
}
}
variable "placement_constraints" {
default = []
type = list(string)
description = "Docker Swarm placement constraints"
}

View file

@ -0,0 +1,28 @@
module "network" {
source = "../../docker/network"
stack_name = var.stack_name
}
module "anisette" {
source = "../../docker/service"
image = "dadoum/anisette-v3-server"
stack_name = var.stack_name
service_name = "anisette"
networks = concat(var.networks, [module.network])
converge_enable = false
ports = [{ host = 6969, container = 6969, protocol = "tcp" }]
placement_constraints = var.placement_constraints
volumes = {
"anisette-v3-data" = "/home/Alcoholic/.config/anisette-v3/lib/"
}
}
module "macless-haystack" {
source = "../../docker/service"
stack_name = var.stack_name
service_name = "macless-haystack"
image = "christld/macless-haystack"
networks = concat(var.networks, [module.network])
converge_enable = false
ports = [ {host = 6176, container = 6176, protocol = "tcp"} ]
placement_constraints = var.placement_constraints
}

View file

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