feat: initial homelab-gitops declarative structure (Terraform & ArgoCD)
This commit is contained in:
9
terraform/shipyard-swarm/outputs.tf
Normal file
9
terraform/shipyard-swarm/outputs.tf
Normal file
@@ -0,0 +1,9 @@
|
||||
output "swarm_services" {
|
||||
description = "Configured Docker Swarm services"
|
||||
value = [
|
||||
docker_service.gotify.name,
|
||||
docker_service.peanut.name,
|
||||
docker_service.homebox.name,
|
||||
docker_service.nginx_proxy_manager.name,
|
||||
]
|
||||
}
|
||||
20
terraform/shipyard-swarm/providers.tf
Normal file
20
terraform/shipyard-swarm/providers.tf
Normal file
@@ -0,0 +1,20 @@
|
||||
terraform {
|
||||
required_version = ">= 1.5.0"
|
||||
required_providers {
|
||||
docker = {
|
||||
source = "kreuzwerker/docker"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
|
||||
backend "http" {
|
||||
address = "https://git.snarfnet.net/api/packages/snarf/terraform/state/shipyard-swarm"
|
||||
lock_address = "https://git.snarfnet.net/api/packages/snarf/terraform/state/shipyard-swarm/lock"
|
||||
unlock_address = "https://git.snarfnet.net/api/packages/snarf/terraform/state/shipyard-swarm/lock"
|
||||
username = "snarf"
|
||||
}
|
||||
}
|
||||
|
||||
provider "docker" {
|
||||
host = var.docker_host
|
||||
}
|
||||
173
terraform/shipyard-swarm/stacks.tf
Normal file
173
terraform/shipyard-swarm/stacks.tf
Normal file
@@ -0,0 +1,173 @@
|
||||
# Swarm Overlay Network
|
||||
resource "docker_network" "homelab_public" {
|
||||
name = "homelab_public"
|
||||
driver = "overlay"
|
||||
attachable = true
|
||||
}
|
||||
|
||||
# 1. Gotify Notification Service
|
||||
resource "docker_service" "gotify" {
|
||||
name = "gotify"
|
||||
|
||||
task_spec {
|
||||
container_spec {
|
||||
image = "gotify/server:latest"
|
||||
env = {
|
||||
GOTIFY_SERVER_PORT = "80"
|
||||
TZ = "America/New_York"
|
||||
}
|
||||
mounts {
|
||||
target = "/app/data"
|
||||
source = "${var.swarm_storage_base}/gotify"
|
||||
type = "bind"
|
||||
}
|
||||
}
|
||||
restart_policy {
|
||||
condition = "any"
|
||||
}
|
||||
}
|
||||
|
||||
mode {
|
||||
replicated {
|
||||
replicas = 1
|
||||
}
|
||||
}
|
||||
|
||||
endpoint_spec {
|
||||
ports {
|
||||
target_port = 80
|
||||
published_port = 8090
|
||||
publish_mode = "ingress"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 2. Peanut UPS Service
|
||||
resource "docker_service" "peanut" {
|
||||
name = "peanut"
|
||||
|
||||
task_spec {
|
||||
container_spec {
|
||||
image = "brandawg93/peanut:latest"
|
||||
env = {
|
||||
TZ = "America/New_York"
|
||||
}
|
||||
mounts {
|
||||
target = "/config"
|
||||
source = "${var.swarm_storage_base}/peanut"
|
||||
type = "bind"
|
||||
}
|
||||
}
|
||||
restart_policy {
|
||||
condition = "any"
|
||||
}
|
||||
}
|
||||
|
||||
mode {
|
||||
replicated {
|
||||
replicas = 1
|
||||
}
|
||||
}
|
||||
|
||||
endpoint_spec {
|
||||
ports {
|
||||
target_port = 8080
|
||||
published_port = 8050
|
||||
publish_mode = "ingress"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 3. Homebox Inventory Service
|
||||
resource "docker_service" "homebox" {
|
||||
name = "homebox"
|
||||
|
||||
task_spec {
|
||||
container_spec {
|
||||
image = "ghcr.io/sysadminsmedia/homebox:latest"
|
||||
env = {
|
||||
HBOX_MODE = "production"
|
||||
HBOX_STORAGE_DATA = "/data"
|
||||
TZ = "America/New_York"
|
||||
}
|
||||
mounts {
|
||||
target = "/data"
|
||||
source = "${var.swarm_storage_base}/homebox"
|
||||
type = "bind"
|
||||
}
|
||||
}
|
||||
restart_policy {
|
||||
condition = "any"
|
||||
}
|
||||
}
|
||||
|
||||
mode {
|
||||
replicated {
|
||||
replicas = 1
|
||||
}
|
||||
}
|
||||
|
||||
endpoint_spec {
|
||||
ports {
|
||||
target_port = 7745
|
||||
published_port = 7745
|
||||
publish_mode = "ingress"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 4. Nginx Proxy Manager Service (Node-pinned to snshpd4lnxswm04)
|
||||
resource "docker_service" "nginx_proxy_manager" {
|
||||
name = "nginx-proxy-manager"
|
||||
|
||||
task_spec {
|
||||
container_spec {
|
||||
image = "jc21/nginx-proxy-manager:latest"
|
||||
env = {
|
||||
TZ = "America/New_York"
|
||||
PUID = "1000"
|
||||
PGID = "1000"
|
||||
}
|
||||
mounts {
|
||||
target = "/data"
|
||||
source = "${var.swarm_storage_base}/nginx-proxy-manager_nginx-data/_data"
|
||||
type = "bind"
|
||||
}
|
||||
mounts {
|
||||
target = "/etc/letsencrypt"
|
||||
source = "${var.swarm_storage_base}/nginx-proxy-manager_nginx-letsencrypt/_data"
|
||||
type = "bind"
|
||||
}
|
||||
}
|
||||
placement {
|
||||
constraints = ["node.hostname == snshpd4lnxswm04"]
|
||||
}
|
||||
restart_policy {
|
||||
condition = "any"
|
||||
}
|
||||
}
|
||||
|
||||
mode {
|
||||
replicated {
|
||||
replicas = 1
|
||||
}
|
||||
}
|
||||
|
||||
endpoint_spec {
|
||||
ports {
|
||||
target_port = 80
|
||||
published_port = 80
|
||||
publish_mode = "host"
|
||||
}
|
||||
ports {
|
||||
target_port = 443
|
||||
published_port = 443
|
||||
publish_mode = "host"
|
||||
}
|
||||
ports {
|
||||
target_port = 81
|
||||
published_port = 81
|
||||
publish_mode = "host"
|
||||
}
|
||||
}
|
||||
}
|
||||
11
terraform/shipyard-swarm/variables.tf
Normal file
11
terraform/shipyard-swarm/variables.tf
Normal file
@@ -0,0 +1,11 @@
|
||||
variable "docker_host" {
|
||||
type = string
|
||||
description = "Docker daemon SSH / TCP connection string"
|
||||
default = "ssh://snarf@140.44.4.71:22"
|
||||
}
|
||||
|
||||
variable "swarm_storage_base" {
|
||||
type = string
|
||||
description = "Path to NFS persistent storage mount"
|
||||
default = "/mnt/swarm_shared/legacy_volumes"
|
||||
}
|
||||
Reference in New Issue
Block a user