From 5312262c3fe372a3ec259b0bbd986cd58af1fed3 Mon Sep 17 00:00:00 2001 From: Luigi Oliveira Date: Wed, 3 Jan 2024 22:14:30 -0300 Subject: [PATCH] infra: Icecast deployment --- terraform/main.tf | 8 ++++ terraform/modules/icecast/conf/icecast.hcl | 46 ++++++++++++++++++++++ terraform/modules/icecast/job.tf | 6 +++ terraform/modules/icecast/providers..tf | 9 +++++ 4 files changed, 69 insertions(+) create mode 100644 terraform/modules/icecast/conf/icecast.hcl create mode 100644 terraform/modules/icecast/job.tf create mode 100644 terraform/modules/icecast/providers..tf diff --git a/terraform/main.tf b/terraform/main.tf index 0c7e55c..fbeaa0f 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -27,6 +27,14 @@ module "keycloak" { postgree_endpoint = var.endpoint KC_USER = var.kc_user KC_PASSWORD = var.kc_password + providers = { + nomad = nomad + } +} + +module "icecast" { + source = "./modules/icecast" + providers = { nomad = nomad } diff --git a/terraform/modules/icecast/conf/icecast.hcl b/terraform/modules/icecast/conf/icecast.hcl new file mode 100644 index 0000000..3a9d6ce --- /dev/null +++ b/terraform/modules/icecast/conf/icecast.hcl @@ -0,0 +1,46 @@ +job "icecast" { + datacenters = ["dc"] + type = "service" + + group "icecast" { + count = 1 + + network { + + port "icecast" { + static = 8000 + to = 8000 + } + } + + restart { + attempts = 2 + interval = "5m" + delay = "30s" + mode = "delay" + } + + task "icecast" { + driver = "docker" + + config { + image = "moul/icecast" + ports = ["icecast"] + } + env { + //TODO :) + #ICECAST_SOURCE_PASSWORD="" + #ICECAST_ADMIN_PASSWORD=bbbb + #ICECAST_PASSWORD=cccc + #ICECAST_RELAY_PASSWORD=dddd + } + + service { + name = "icecast" + port = "icecast" + provider = "nomad" + } + } + + } +} \ No newline at end of file diff --git a/terraform/modules/icecast/job.tf b/terraform/modules/icecast/job.tf new file mode 100644 index 0000000..41d312f --- /dev/null +++ b/terraform/modules/icecast/job.tf @@ -0,0 +1,6 @@ +resource "nomad_job" "app" { + jobspec = templatefile("${path.module}/conf/icecast.hcl", { + NOMAD_ALLOC_DIR = "/alloc" + + }) +} diff --git a/terraform/modules/icecast/providers..tf b/terraform/modules/icecast/providers..tf new file mode 100644 index 0000000..c693f1d --- /dev/null +++ b/terraform/modules/icecast/providers..tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + nomad = { + source = "hashicorp/nomad" + version = "2.0.0-rc.1" + } + } + required_version = ">= 0.14" +} \ No newline at end of file