Ubiquity and printers included

This commit is contained in:
Greyscale 2024-06-28 12:43:20 +02:00
parent 8b112b05ff
commit 70e46005a7
8 changed files with 187 additions and 37 deletions

View file

@ -1,4 +1,4 @@
provider "ssh" { /*provider "ssh" {
server = { server = {
host = "california.ti" host = "california.ti"
port = 22 port = 22
@ -10,22 +10,24 @@ provider "ssh" {
} }
} }
} }
#data "ssh_tunnel" "docker" { data "ssh_tunnel" "docker" {
# connection_name = "docker_socket_tunnel_california" connection_name = "docker_socket_tunnel_california"
# remote = { remote = {
# socket = "/var/run/docker.sock" socket = "/var/run/docker.sock"
# } }
#} }
*/
provider "docker" { provider "docker" {
host = "ssh://california.ti" host = "ssh://california.ti"
} }
provider "docker" { provider "docker" {
alias = "printi" alias = "printi"
host = "ssh://prin.ti" host = "ssh://prin.ti"
} }
provider "docker" { provider "docker" {
alias = "unifi" alias = "unifi"
host = "ssh://unifi.ti" host = "ssh://unifi.ti"
} }

View file

@ -1,7 +1,7 @@
module "minio" { module "minio" {
source = "./modules/minio" source = "./modules/minio"
domain = "s3.california.ti" domain = "s3.california.ti"
network = docker_network.loadbalancer network = docker_network.loadbalancer
storage_path = "/media/storage/minio" storage_path = "/media/storage/minio"
admin_username = "techinc" admin_username = "techinc"
} }

View file

@ -1,20 +1,20 @@
variable "admin_username" { variable "admin_username" {
type = string type = string
description = "The username of the admin user" description = "The username of the admin user"
default = "admin" default = "admin"
} }
variable "domain" { variable "domain" {
type = string type = string
description = "The domain name of the minio instance" description = "The domain name of the minio instance"
} }
variable "network" { variable "network" {
type = object({ type = object({
id = string id = string
name = string name = string
}) })
description = "The network to attach the minio service to" description = "The network to attach the minio service to"
} }
variable "storage_path" { variable "storage_path" {
type = string type = string
description = "The path to the storage directory to use" description = "The path to the storage directory to use"
} }

View file

@ -1,5 +1,5 @@
data "docker_registry_image" "minio" { data "docker_registry_image" "minio" {
name = "quay.io/minio/minio:latest" name = "quay.io/minio/minio:latest"
} }
resource "random_password" "minio_password" { resource "random_password" "minio_password" {
@ -13,7 +13,7 @@ locals {
} }
resource "docker_service" "minio" { resource "docker_service" "minio" {
name = "minio" name = "minio"
task_spec { task_spec {
container_spec { container_spec {
image = "${data.docker_registry_image.minio.name}@${data.docker_registry_image.minio.sha256_digest}" image = "${data.docker_registry_image.minio.name}@${data.docker_registry_image.minio.sha256_digest}"
@ -52,8 +52,8 @@ resource "docker_service" "minio" {
} }
module "minio_nginx_config" { module "minio_nginx_config" {
source = "git::https://code.techinc.nl/grey/terraform-nginx.git//nginx-site-available" source = "git::https://code.techinc.nl/grey/terraform-nginx.git//nginx-site-available"
hostname = var.domain hostname = var.domain
//certificate = acme_certificate.ooo_grey["s3"] //certificate = acme_certificate.ooo_grey["s3"]
service_name = "minio_s3" service_name = "minio_s3"
upstream_host = "${docker_service.minio.name}:9000" upstream_host = "${docker_service.minio.name}:9000"
@ -65,6 +65,6 @@ module "minio_nginx_config" {
} }
] ]
extra_locations = file("${path.module}/minio_nginx_extra.conf") extra_locations = file("${path.module}/minio_nginx_extra.conf")
allow_non_ssl = true allow_non_ssl = true
allow_ssl = false allow_ssl = false
} }

View file

@ -1,7 +1,7 @@
output "auth" { output "auth" {
value = { value = {
user = docker_service.minio.task_spec[0].container_spec[0].env.MINIO_ROOT_USER user = var.admin_username
password = nonsensitive(docker_service.minio.task_spec[0].container_spec[0].env.MINIO_ROOT_PASSWORD) password = nonsensitive(random_password.minio_password.result)
} }
} }
output "domain" { output "domain" {

View file

@ -1,4 +1,4 @@
output "minio" { output "minio" {
value = module.minio value = module.minio
} }

View file

@ -1,14 +1,49 @@
resource "docker_image" "octoprint" { resource "docker_image" "octoprint" {
provider = "docker.printi" provider = docker.printi
name = "octoprint" name = "octoprint"
build { build {
context = "${path.module}/printers" context = "${path.module}/printers"
target = "octoprint-mjpg-streamer" target = "octoprint-mjpg-streamer"
tag = ["ti-octoprint"]
}
}
resource "docker_volume" "ender5plus" {
provider = docker.printi
name = "ender5plus_config"
}
resource "docker_service" "ender5plus" {
provider = docker.printi
name = "ender5plus"
task_spec {
container_spec {
image = docker_image.octoprint.name
mounts {
target = "/octoprint"
source = docker_volume.ender5plus.name
type = "volume"
}
mounts {
target = "/dev/ttyACM0"
source = "/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A602AFFK-if00-port0"
type = "bind"
}
env = {
#ENABLE_MJPG_STREAMER = "true"
}
}
restart_policy {
condition = "any"
delay = "20s"
window = "0s"
}
}
endpoint_spec {
ports {
target_port = 80
published_port = 3000
publish_mode = "ingress"
}
} }
} }
/*
resource "docker_container" "corexy" {
provider = "docker.printi"
image = docker_image.octoprint.name
name = "corexy"
}*/

113
ubiquity.tf Normal file
View file

@ -0,0 +1,113 @@
data "docker_registry_image" "unifi_controller" {
name = "jacobalberty/unifi"
}
resource "docker_service" "unifi_controller" {
name = "unifi_controller"
provider = docker.unifi
task_spec {
container_spec {
image = "${data.docker_registry_image.unifi_controller.name}@${data.docker_registry_image.unifi_controller.sha256_digest}"
env = {
TZ = "Europe/Amsterdam"
}
mounts {
target = "/unifi"
source = "/home/techinc/unifi"
type = "bind"
}
}
restart_policy {
condition = "any"
delay = "0s"
window = "0s"
}
}
endpoint_spec {
ports {
target_port = 8443
published_port = 443
publish_mode = "ingress"
}
ports {
target_port = 8443
published_port = 8443
publish_mode = "ingress"
}
ports {
target_port = 3478
published_port = 3478
publish_mode = "ingress"
protocol = "udp"
}
ports {
target_port = 10001
published_port = 10001
publish_mode = "ingress"
protocol = "udp"
}
ports {
target_port = 8080
published_port = 8080
publish_mode = "ingress"
}
}
}
data "docker_registry_image" "http2https" {
name = "articulate/http-to-https"
}
resource "docker_service" "unifi_http2https" {
name = "http2https"
provider = docker.unifi
task_spec {
container_spec {
image = "${data.docker_registry_image.http2https.name}@${data.docker_registry_image.http2https.sha256_digest}"
}
restart_policy {
condition = "any"
delay = "0s"
window = "0s"
}
}
endpoint_spec {
ports {
target_port = 80
published_port = 80
publish_mode = "ingress"
}
}
}
data "docker_registry_image" "iperf" {
name = "loganmarchione/docker-iperf3:latest"
provider = docker.unifi
}
resource "docker_service" "unifi_iperf" {
name = "iperf"
provider = docker.unifi
task_spec {
container_spec {
image = "${data.docker_registry_image.iperf.name}@${data.docker_registry_image.iperf.sha256_digest}"
}
restart_policy {
condition = "any"
delay = "0s"
window = "0s"
}
}
endpoint_spec {
ports {
target_port = 5201
published_port = 5201
publish_mode = "ingress"
protocol = "tcp"
}
ports {
target_port = 5201
published_port = 5201
publish_mode = "ingress"
protocol = "udp"
}
}
}