Browse Source

re-arch into media directory

monicahq
Nemo 2 years ago
parent
commit
1a714d87b2
23 changed files with 146 additions and 104 deletions
  1. +9
    -23
      db/mariadb.tf
  2. +32
    -0
      db/mongorocks.tf
  3. +7
    -0
      db/outputs.tf
  4. +10
    -0
      db/variables.tf
  5. +7
    -0
      db/volumes.tf
  6. +0
    -19
      docker/data.tf
  7. +0
    -20
      docker/images.tf
  8. +1
    -1
      docker/lychee.tf
  9. +6
    -1
      docker/network.tf
  10. +0
    -12
      docker/outputs.tf
  11. +3
    -8
      docker/variables.tf
  12. +0
    -6
      docker/volumes.tf
  13. +1
    -1
      docker/wiki.tf
  14. +19
    -8
      main.tf
  15. +0
    -0
      media/conf/transmission.json
  16. +10
    -1
      media/emby.tf
  17. +1
    -1
      media/lidarr.tf
  18. +9
    -0
      media/network.tf
  19. +7
    -0
      media/outputs.tf
  20. +1
    -1
      media/radarr.tf
  21. +1
    -1
      media/sonarr.tf
  22. +12
    -1
      media/transmission.tf
  23. +10
    -0
      media/variables.tf

docker/db.tf → db/mariadb.tf View File

@ -1,26 +1,3 @@
resource "docker_container" "mongorocks" {
name = "mongorocks"
image = "${docker_image.percona-mongodb-server.latest}"
restart = "unless-stopped"
destroy_grace_seconds = 30
must_run = true
memory = 256
volumes {
volume_name = "${docker_volume.mongorocks_data_volume.name}"
container_path = "/data/db"
host_path = "${docker_volume.mongorocks_data_volume.mountpoint}"
}
command = [
"--storageEngine=rocksdb",
"--httpinterface",
"--rest",
"--master",
]
}
resource "docker_container" "mariadb" {
name = "mariadb"
image = "${docker_image.mariadb.latest}"
@ -59,3 +36,12 @@ resource "docker_container" "mariadb" {
"--version=${var.mariadb-version}-MariaDB",
]
}
resource "docker_image" "mariadb" {
name = "${data.docker_registry_image.mariadb.name}"
pull_triggers = ["${data.docker_registry_image.mariadb.sha256_digest}"]
}
data "docker_registry_image" "mariadb" {
name = "mariadb:${var.mariadb-version}"
}

+ 32
- 0
db/mongorocks.tf View File

@ -0,0 +1,32 @@
resource "docker_container" "mongorocks" {
name = "mongorocks"
image = "${docker_image.percona-mongodb-server.latest}"
restart = "unless-stopped"
destroy_grace_seconds = 30
must_run = true
memory = 256
volumes {
volume_name = "${docker_volume.mongorocks_data_volume.name}"
container_path = "/data/db"
host_path = "${docker_volume.mongorocks_data_volume.mountpoint}"
}
command = [
"--storageEngine=rocksdb",
"--httpinterface",
"--rest",
"--master",
]
}
resource "docker_image" "percona-mongodb-server" {
name = "${data.docker_registry_image.percona-mongodb-server.name}"
pull_triggers = ["${data.docker_registry_image.percona-mongodb-server.sha256_digest}"]
}
# Database versions shouldn't be upgraded
data "docker_registry_image" "percona-mongodb-server" {
name = "percona/percona-server-mongodb:3.4"
}

+ 7
- 0
db/outputs.tf View File

@ -0,0 +1,7 @@
output "names-mariadb" {
value = "${docker_container.mariadb.name}"
}
output "names-mongorocks" {
value = "${docker_container.mongorocks.name}"
}

+ 10
- 0
db/variables.tf View File

@ -0,0 +1,10 @@
variable "mariadb-version" {
description = "mariadb version to use for fetching the docker image"
default = "10.2.14"
}
variable "ips" {
type = "map"
}
variable "mysql_root_password" {}

+ 7
- 0
db/volumes.tf View File

@ -0,0 +1,7 @@
resource "docker_volume" "mariadb_volume" {
name = "mariadb_volume"
}
resource "docker_volume" "mongorocks_data_volume" {
name = "mongorocks_data_volume"
}

+ 0
- 19
docker/data.tf View File

@ -1,28 +1,9 @@
# Database versions shouldn't be upgraded
data "docker_registry_image" "mariadb" {
name = "mariadb:${var.mariadb-version}"
}
data "docker_registry_image" "percona-mongodb-server" {
name = "percona/percona-server-mongodb:3.4"
}
data "docker_registry_image" "traefik" {
# Critical and I like upgrading it
# for updating config for new features
name = "traefik:1.6-alpine"
}
# YOLO everything else
data "docker_registry_image" "emby" {
name = "emby/embyserver:latest"
}
data "docker_registry_image" "transmission" {
name = "linuxserver/transmission:latest"
}
data "docker_registry_image" "wikijs" {
name = "requarks/wiki:latest"
}


+ 0
- 20
docker/images.tf View File

@ -1,18 +1,3 @@
resource "docker_image" "emby" {
name = "${data.docker_registry_image.emby.name}"
pull_triggers = ["${data.docker_registry_image.emby.sha256_digest}"]
}
resource "docker_image" "mariadb" {
name = "${data.docker_registry_image.mariadb.name}"
pull_triggers = ["${data.docker_registry_image.mariadb.sha256_digest}"]
}
resource "docker_image" "transmission" {
name = "${data.docker_registry_image.transmission.name}"
pull_triggers = ["${data.docker_registry_image.transmission.sha256_digest}"]
}
resource "docker_image" "traefik16" {
name = "${data.docker_registry_image.traefik.name}"
pull_triggers = ["${data.docker_registry_image.traefik.sha256_digest}"]
@ -23,11 +8,6 @@ resource "docker_image" "wikijs" {
pull_triggers = ["${data.docker_registry_image.wikijs.sha256_digest}"]
}
resource "docker_image" "percona-mongodb-server" {
name = "${data.docker_registry_image.percona-mongodb-server.name}"
pull_triggers = ["${data.docker_registry_image.percona-mongodb-server.sha256_digest}"]
}
resource "docker_image" "ubooquity" {
name = "${data.docker_registry_image.ubooquity.name}"
pull_triggers = ["${data.docker_registry_image.ubooquity.sha256_digest}"]


+ 1
- 1
docker/lychee.tf View File

@ -33,5 +33,5 @@ resource "docker_container" "lychee" {
"PGID=984",
]
links = ["${docker_container.mariadb.name}"]
links = ["${var.links-mariadb}"]
}

+ 6
- 1
docker/network.tf View File

@ -1 +1,6 @@
// This is the default network we use
// for any new container
resource "docker_network" "bb8-default" {
name = "bb8"
driver = "bridge"
}

+ 0
- 12
docker/outputs.tf View File

@ -2,18 +2,6 @@ output "lychee-ip" {
value = "${docker_container.lychee.ip_address}"
}
output "names-transmission" {
value = "${docker_container.transmission.name}"
}
output "names-emby" {
value = "${docker_container.emby.name}"
}
output "names-mariadb" {
value = "${docker_container.mariadb.name}"
}
output "names-traefik" {
value = "${docker_container.traefik.name}"
}


+ 3
- 8
docker/variables.tf View File

@ -6,10 +6,6 @@ variable "web_password" {
type = "string"
}
variable "mysql_root_password" {
type = "string"
}
variable "cloudflare_key" {
type = "string"
description = "cloudflare API Key"
@ -54,7 +50,6 @@ variable "ips" {
type = "map"
}
variable "mariadb-version" {
description = "mariadb version to use for fetching the docker image"
default = "10.2.14"
}
variable "links-mariadb" {}
variable "links-mongorocks" {}

+ 0
- 6
docker/volumes.tf View File

@ -1,7 +1 @@
resource "docker_volume" "mariadb_volume" {
name = "mariadb_volume"
}
resource "docker_volume" "mongorocks_data_volume" {
name = "mongorocks_data_volume"
}

+ 1
- 1
docker/wiki.tf View File

@ -43,7 +43,7 @@ resource "docker_container" "wiki" {
"traefik.port", 9999,
"traefik.frontend.headers.customResponseHeaders", "${var.xpoweredby}||Referrer-Policy:${var.refpolicy}||X-Frame-Options:${var.xfo_allow}",
))}"
links = ["${docker_container.mongorocks.name}"]
links = ["${var.links-mongorocks}"]
env = [
"WIKI_ADMIN_EMAIL=me@captnemo.in",
"SESSION_SECRET=${var.wiki_session_secret}",


+ 19
- 8
main.tf View File

@ -17,14 +17,21 @@ module "docker" {
source = "docker"
web_username = "${var.web_username}"
web_password = "${var.web_password}"
mysql_root_password = "${var.mysql_root_password}"
cloudflare_key = "${var.cloudflare_key}"
cloudflare_email = "bb8@captnemo.in"
wiki_session_secret = "${var.wiki_session_secret}"
links-mariadb = "${module.db.names-mariadb}"
links-mongorocks = "${module.db.names-mongorocks}"
ips = "${var.ips}"
domain = "bb8.fun"
}
module "db" {
source = "db"
mysql_root_password = "${var.mysql_root_password}"
ips = "${var.ips}"
}
module "timemachine" {
source = "timemachine"
ips = "${var.ips}"
@ -56,7 +63,7 @@ module "tt-rss" {
source = "tt-rss"
domain = "rss.captnemo.in"
mysql_password = "${var.mysql-ttrss-password}"
links-db = "${module.docker.names-mariadb}"
links-db = "${module.db.names-mariadb}"
traefik-labels = "${var.traefik-common-labels}"
}
@ -81,21 +88,25 @@ module "heimdall" {
}
module "media" {
source = "media"
domain = "bb8.fun"
links-emby = "${module.docker.names-emby}"
links-transmission = "${module.docker.names-transmission}"
links-mariadb = "${module.docker.names-mariadb}"
source = "media"
domain = "bb8.fun"
// TODO: remove self links
links-emby = "${module.media.names-emby}"
links-transmission = "${module.media.names-transmission}"
links-mariadb = "${module.db.names-mariadb}"
links-mongorocks = "${module.db.names-mongorocks}"
traefik-labels = "${var.traefik-common-labels}"
airsonic-smtp-password = "${var.airsonic-smtp-password}"
airsonic-db-password = "${var.mysql_airsonic_password}"
ips = "${var.ips}"
}
module "monitoring" {
source = "monitoring"
gf-security-admin-password = "${var.gf-security-admin-password}"
domain = "bb8.fun"
transmission = "${module.docker.names-transmission}"
transmission = "${module.media.names-transmission}"
traefik-labels = "${var.traefik-common-labels}"
ips = "${var.ips}"
links-traefik = "${module.docker.names-traefik}"


docker/conf/transmission.json → media/conf/transmission.json View File


docker/emby.tf → media/emby.tf View File

@ -13,7 +13,7 @@ resource "docker_container" "emby" {
}
labels = "${merge(
local.traefik_common_labels,
var.traefik-labels,
map(
"traefik.frontend.rule", "Host:emby.in.${var.domain},emby.${var.domain}",
"traefik.frontend.passHostHeader", "true",
@ -34,3 +34,12 @@ resource "docker_container" "emby" {
"TZ=Asia/Kolkata",
]
}
resource "docker_image" "emby" {
name = "${data.docker_registry_image.emby.name}"
pull_triggers = ["${data.docker_registry_image.emby.sha256_digest}"]
}
data "docker_registry_image" "emby" {
name = "emby/embyserver:latest"
}

+ 1
- 1
media/lidarr.tf View File

@ -43,5 +43,5 @@ resource "docker_container" "lidarr" {
"TZ=Asia/Kolkata",
]
links = ["${var.links-emby}", "${var.links-transmission}"]
networks = ["${docker_network.media.id}"]
}

+ 9
- 0
media/network.tf View File

@ -0,0 +1,9 @@
resource "docker_network" "media" {
name = "media"
driver = "bridge"
ipam_config {
subnet = "172.18.0.0/16"
gateway = "172.18.0.1"
}
}

+ 7
- 0
media/outputs.tf View File

@ -0,0 +1,7 @@
output "names-transmission" {
value = "${docker_container.transmission.name}"
}
output "names-emby" {
value = "${docker_container.emby.name}"
}

+ 1
- 1
media/radarr.tf View File

@ -44,5 +44,5 @@ resource "docker_container" "radarr" {
"TZ=Asia/Kolkata",
]
links = ["${var.links-emby}", "${var.links-transmission}"]
networks = ["${docker_network.media.id}"]
}

+ 1
- 1
media/sonarr.tf View File

@ -43,5 +43,5 @@ resource "docker_container" "sonarr" {
"TZ=Asia/Kolkata",
]
links = ["${var.links-emby}", "${var.links-transmission}"]
networks = ["${docker_network.media.id}"]
}

docker/transmission.tf → media/transmission.tf View File

@ -3,7 +3,7 @@ resource "docker_container" "transmission" {
image = "${docker_image.transmission.latest}"
labels = "${merge(
local.traefik_common_labels,
var.traefik-labels,
map(
"traefik.frontend.auth.basic", "${var.basic_auth}",
"traefik.port", 9091,
@ -42,8 +42,19 @@ resource "docker_container" "transmission" {
"TZ=Asia/Kolkata",
]
networks = ["${docker_network.media.id}"]
memory = 1024
restart = "unless-stopped"
destroy_grace_seconds = 10
must_run = true
}
resource "docker_image" "transmission" {
name = "${data.docker_registry_image.transmission.name}"
pull_triggers = ["${data.docker_registry_image.transmission.sha256_digest}"]
}
data "docker_registry_image" "transmission" {
name = "linuxserver/transmission:latest"
}

+ 10
- 0
media/variables.tf View File

@ -5,9 +5,19 @@ variable "domain" {
variable "links-emby" {}
variable "links-transmission" {}
variable "links-mariadb" {}
variable "links-mongorocks" {}
variable "airsonic-smtp-password" {}
variable "airsonic-db-password" {}
variable "traefik-labels" {
type = "map"
}
// TODO: Remove duplication
variable "basic_auth" {
default = "tatooine:$2y$05$iPbatint3Gulbs6kUtyALO9Yq5sBJ..aiF82bcIziH4ytz9nFoPr6,reddit:$2y$05$ghKxSydYCpAT8r2VVMDmWO/BBecghGfLsRJUkr3ii7XxPyxBqp8Oy"
}
variable "ips" {
type = "map"
}

Loading…
Cancel
Save