Compare commits

...

2 Commits

  1. 2
      README.md
  2. 1
      terraform/env.sample
  3. 7
      terraform/main.tf
  4. 13
      terraform/modules/caddy/conf/Caddyfile-internal
  5. 19
      terraform/modules/cloudflare/records.tf
  6. 2
      terraform/modules/shynet/providers.tf
  7. 72
      terraform/modules/syncthing/conf/app.nomad
  8. 6
      terraform/modules/syncthing/job.tf
  9. 9
      terraform/modules/syncthing/providers.tf
  10. 6
      terraform/variables.tf

2
README.md

@ -27,7 +27,7 @@
- [Pihole](https://pi-hole.net/)
- [Gitea](https://gitea.io/)
- [Shynet](https://github.com/milesmcc/shynet)
- [Joplin Sync Server](https://github.com/laurent22/joplin/tree/dev/packages/server)
- [Syncthing](https://syncthing.net/)
## Blog Posts

1
terraform/env.sample

@ -3,7 +3,6 @@ CLOUDFLARE_API_TOKEN=
TF_VAR_cloudflare_caddy_api_token=
TF_VAR_shynet_postgresql_password=
TF_VAR_shynet_django_secret_key=
TF_VAR_joplin_postgresql_password=
TF_VAR_gitea_secret_key=
TF_VAR_gitea_internal_token=
TF_VAR_gitea_lfs_jwt_secret=

7
terraform/main.tf

@ -74,3 +74,10 @@ module "monitoring" {
nomad = nomad
}
}
module "syncthing" {
source = "./modules/syncthing"
providers = {
nomad = nomad
}
}

13
terraform/modules/caddy/conf/Caddyfile-internal

@ -21,8 +21,8 @@ pihole.mrkaran.dev {
}
}
joplin.mrkaran.dev {
{{ range service "joplin-web" }}
grafana.mrkaran.dev {
{{ range service "grafana-web" }}
reverse_proxy {{ .Address }}:{{ .Port }}
{{ end }}
tls {
@ -30,8 +30,8 @@ joplin.mrkaran.dev {
}
}
grafana.mrkaran.dev {
{{ range service "grafana-web" }}
prometheus.mrkaran.dev {
{{ range service "prometheus-web" }}
reverse_proxy {{ .Address }}:{{ .Port }}
{{ end }}
tls {
@ -39,11 +39,12 @@ grafana.mrkaran.dev {
}
}
prometheus.mrkaran.dev {
{{ range service "prometheus-web" }}
syncthing.mrkaran.dev {
{{ range service "syncthing-web" }}
reverse_proxy {{ .Address }}:{{ .Port }}
{{ end }}
tls {
dns cloudflare "${cloudflare_api_token}"
}
}

19
terraform/modules/cloudflare/records.tf

@ -94,21 +94,22 @@ resource "cloudflare_record" "shynet" {
}
resource "cloudflare_record" "joplin" {
resource "cloudflare_record" "koadings" {
zone_id = cloudflare_zone.mrkaran_dev.id
name = "joplin"
name = "koadings"
type = "A"
ttl = "1"
proxied = "false"
value = var.ips["floyd_tailscale"]
value = var.ips["floyd_tailscale"]
}
resource "cloudflare_record" "koadings" {
resource "cloudflare_record" "grafana" {
zone_id = cloudflare_zone.mrkaran_dev.id
name = "koadings"
name = "grafana"
type = "A"
ttl = "1"
proxied = "false"
@ -117,10 +118,10 @@ resource "cloudflare_record" "koadings" {
}
resource "cloudflare_record" "grafana" {
resource "cloudflare_record" "prometheus" {
zone_id = cloudflare_zone.mrkaran_dev.id
name = "grafana"
name = "prometheus"
type = "A"
ttl = "1"
proxied = "false"
@ -129,10 +130,10 @@ resource "cloudflare_record" "grafana" {
}
resource "cloudflare_record" "prometheus" {
resource "cloudflare_record" "syncthing" {
zone_id = cloudflare_zone.mrkaran_dev.id
name = "prometheus"
name = "syncthing"
type = "A"
ttl = "1"
proxied = "false"

2
terraform/modules/shynet/providers.tf

@ -1,7 +1,7 @@
terraform {
required_providers {
nomad = {
source = "hashicorp/nomad"
source = "hashicorp/nomad"
version = "1.4.14"
}
}

72
terraform/modules/syncthing/conf/app.nomad

@ -0,0 +1,72 @@
job "syncthing" {
datacenters = ["hydra"]
type = "service"
group "app" {
count = 1
network {
port "http" {
to = 8384
host_network = "tailscale"
}
port "listen" {
to = 22000
host_network = "tailscale"
}
port "discovery" {
to = 21027
host_network = "tailscale"
}
}
restart {
attempts = 2
interval = "2m"
delay = "30s"
mode = "fail"
}
task "web" {
driver = "docker"
service {
name = "syncthing-web"
tags = ["syncthing", "web"]
port = "http"
}
config {
image = "linuxserver/syncthing:version-v1.18.0"
# Bind the data directory to preserve config.
mount {
type = "bind"
target = "/config"
source = "/data/syncthing/config/"
readonly = false
}
mount {
type = "bind"
target = "/data"
source = "/data/syncthing/data/"
readonly = false
}
ports = ["http", "listen", "discovery"]
}
env {
PUID = 1000
PGID = 1000
TZ = "Asia/Kolkata"
}
resources {
cpu = 400
memory = 400
}
}
}
}

6
terraform/modules/syncthing/job.tf

@ -0,0 +1,6 @@
resource "nomad_job" "app" {
jobspec = templatefile("${path.module}/conf/app.nomad",{})
hcl2 {
enabled = true
}
}

9
terraform/modules/syncthing/providers.tf

@ -0,0 +1,9 @@
terraform {
required_providers {
nomad = {
source = "hashicorp/nomad"
version = "1.4.14"
}
}
required_version = ">= 0.14"
}

6
terraform/variables.tf

@ -22,12 +22,6 @@ variable "shynet_django_secret_key" {
description = "Django secret key generated for Shynet"
}
variable "joplin_postgresql_password" {
type = string
description = "Password for joplin PostgreSQL server"
}
variable "gitea_secret_key" {
type = string
description = "Global secret key"

Loading…
Cancel
Save