2022-02-28 20:07:34 +00:00
|
|
|
resource "nomad_job" "blocky" {
|
2023-08-24 19:36:47 +00:00
|
|
|
jobspec = templatefile("${path.module}/blocky.nomad", {
|
2024-08-30 18:09:59 +00:00
|
|
|
use_wesher = var.use_wesher,
|
|
|
|
module_path = path.module,
|
2023-08-24 19:36:47 +00:00
|
|
|
})
|
2022-02-28 20:07:34 +00:00
|
|
|
}
|
2023-08-29 19:48:48 +00:00
|
|
|
|
|
|
|
# Generate secrets and policies for access to MySQL
|
|
|
|
resource "nomad_acl_policy" "blocky_mysql_bootstrap_secrets" {
|
|
|
|
name = "blocky-secrets-mysql"
|
|
|
|
description = "Give access to MySQL secrets"
|
|
|
|
rules_hcl = <<EOH
|
|
|
|
namespace "default" {
|
|
|
|
variables {
|
|
|
|
path "secrets/mysql" {
|
|
|
|
capabilities = ["read"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOH
|
|
|
|
|
|
|
|
job_acl {
|
|
|
|
job_id = "blocky"
|
|
|
|
group = "blocky"
|
2023-08-29 19:59:14 +00:00
|
|
|
task = "mysql-bootstrap"
|
2023-08-29 19:48:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "random_password" "blocky_mysql_psk" {
|
|
|
|
length = 32
|
|
|
|
override_special = "!@#%&*-_="
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "nomad_variable" "blocky_mysql_psk" {
|
|
|
|
path = "secrets/mysql/allowed_psks/blocky"
|
|
|
|
items = {
|
|
|
|
psk = "blocky:${resource.random_password.blocky_mysql_psk.result}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "nomad_acl_policy" "blocky_mysql_psk" {
|
|
|
|
name = "blocky-secrets-mysql-psk"
|
|
|
|
description = "Give access to MySQL PSK secrets"
|
|
|
|
rules_hcl = <<EOH
|
|
|
|
namespace "default" {
|
|
|
|
variables {
|
|
|
|
path "secrets/mysql/allowed_psks/blocky" {
|
|
|
|
capabilities = ["read"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOH
|
|
|
|
|
|
|
|
job_acl {
|
|
|
|
job_id = "blocky"
|
|
|
|
group = "blocky"
|
|
|
|
task = "stunnel"
|
|
|
|
}
|
|
|
|
}
|
2024-06-25 00:04:03 +00:00
|
|
|
|
|
|
|
resource "nomad_variable" "blocky_lists_terraform" {
|
|
|
|
path = "blocky_lists/terraform"
|
|
|
|
items = {
|
|
|
|
smarttv_regex = file("${path.module}/list-smarttv-regex.txt")
|
|
|
|
wemo = file("${path.module}/list-wemo.txt")
|
2024-07-18 03:08:38 +00:00
|
|
|
sonos = file("${path.module}/list-sonos.txt")
|
2024-06-25 00:04:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "nomad_acl_policy" "blocky_lists" {
|
|
|
|
name = "blocky-lists"
|
|
|
|
description = "Give access Blocky lists"
|
|
|
|
rules_hcl = <<EOH
|
|
|
|
namespace "default" {
|
|
|
|
variables {
|
|
|
|
path "blocky_lists/*" {
|
|
|
|
capabilities = ["read"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOH
|
|
|
|
|
|
|
|
job_acl {
|
|
|
|
job_id = "blocky"
|
|
|
|
group = "blocky"
|
|
|
|
task = "blocky"
|
|
|
|
}
|
|
|
|
}
|