2022-11-11 21:34:08 +00:00
|
|
|
job "${name}" {
|
|
|
|
region = "global"
|
|
|
|
datacenters = ["dc1"]
|
|
|
|
|
|
|
|
type = "service"
|
2023-07-07 00:23:20 +00:00
|
|
|
priority = ${priority}
|
2022-11-11 21:34:08 +00:00
|
|
|
|
|
|
|
group "${name}" {
|
2023-07-07 22:51:19 +00:00
|
|
|
count = ${count}
|
2023-08-24 22:41:18 +00:00
|
|
|
%{~ if length(job_meta) > 0 }
|
|
|
|
meta = {
|
|
|
|
%{ for k, v in job_meta ~}
|
|
|
|
${k} = ${jsonencode(v)}
|
|
|
|
%{ endfor ~}
|
|
|
|
}
|
|
|
|
%{~ endif ~}
|
2023-07-07 22:51:19 +00:00
|
|
|
|
2022-11-11 21:34:08 +00:00
|
|
|
network {
|
|
|
|
mode = "bridge"
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if service_port != null }
|
2022-11-11 21:34:08 +00:00
|
|
|
port "main" {
|
2023-08-24 19:36:47 +00:00
|
|
|
%{~ if use_wesher ~}
|
2023-03-24 23:32:37 +00:00
|
|
|
host_network = "wesher"
|
2023-08-24 19:36:47 +00:00
|
|
|
%{~ endif ~}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if service_port_static ~}
|
2023-07-07 23:33:36 +00:00
|
|
|
static = ${service_port}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ else ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
to = ${service_port}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ for port in ports }
|
2022-11-15 19:43:05 +00:00
|
|
|
port "${port.name}" {
|
|
|
|
%{ if port.host_network != null }host_network = "${port.host_network}"%{ endif ~}
|
2023-07-24 22:21:41 +00:00
|
|
|
%{ if port.from != null }to = ${port.from}%{ endif ~}
|
2022-11-15 19:43:05 +00:00
|
|
|
%{ if port.to != null }to = ${port.to}%{ endif ~}
|
|
|
|
%{ if port.static != null }static = ${port.static}%{ endif ~}
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ for constraint in constraints }
|
2023-04-20 23:47:07 +00:00
|
|
|
constraint {
|
|
|
|
attribute = "${constraint.attribute}"
|
|
|
|
operator = "${constraint.operator}"
|
|
|
|
value = "${constraint.value}"
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
|
|
|
%{~ if length(group_meta) > 0 }
|
2023-01-11 23:40:42 +00:00
|
|
|
meta = {
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ for k, v in group_meta ~}
|
2023-01-11 23:40:42 +00:00
|
|
|
${k} = ${jsonencode(v)}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
2023-01-11 23:40:42 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if sticky_disk }
|
2022-11-11 21:34:08 +00:00
|
|
|
ephemeral_disk {
|
|
|
|
migrate = true
|
|
|
|
sticky = true
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ for host_volume in host_volumes }
|
2022-11-11 21:34:08 +00:00
|
|
|
volume "${host_volume.name}" {
|
|
|
|
type = "host"
|
|
|
|
read_only = ${host_volume.read_only}
|
|
|
|
source = "${host_volume.name}"
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
|
|
|
%{~ if service_port != null }
|
2022-11-11 21:34:08 +00:00
|
|
|
service {
|
|
|
|
name = "${replace(name, "_", "-")}"
|
2023-03-24 18:24:36 +00:00
|
|
|
provider = "nomad"
|
2022-11-11 21:34:08 +00:00
|
|
|
port = "main"
|
|
|
|
|
2023-03-24 18:24:36 +00:00
|
|
|
tags = [
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if prometheus == true ~}
|
2023-03-24 18:24:36 +00:00
|
|
|
"prometheus.scrape",
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if ingress ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
"traefik.enable=true",
|
|
|
|
"traefik.http.routers.${name}.entryPoints=websecure",
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if try(ingress_rule, null) != null ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
"traefik.http.routers.${name}.rule=${ingress_rule}",
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ for middleware in ingress_middlewares ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
"traefik.http.routers.${name}.middlewares=${middleware}",
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
|
|
|
%{~ endif ~}
|
|
|
|
%{~ for tag in service_tags ~}
|
2022-11-15 19:43:05 +00:00
|
|
|
"${tag}",
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
]
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ for custom_service in custom_services ~}
|
2023-07-24 22:21:20 +00:00
|
|
|
service {
|
|
|
|
name = "${custom_service.name}"
|
|
|
|
provider = "nomad"
|
|
|
|
port = "${custom_service.port}"
|
|
|
|
|
|
|
|
tags = ${jsonencode(custom_service.tags)}
|
|
|
|
}
|
|
|
|
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
task "${name}" {
|
|
|
|
driver = "docker"
|
2023-08-24 22:41:18 +00:00
|
|
|
%{~ if length(task_meta) > 0 }
|
2023-01-11 23:40:42 +00:00
|
|
|
meta = {
|
2023-08-24 22:41:18 +00:00
|
|
|
%{ for k, v in task_meta ~}
|
2023-01-11 23:40:42 +00:00
|
|
|
${k} = ${jsonencode(v)}
|
|
|
|
%{ endfor ~}
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2023-01-11 23:40:42 +00:00
|
|
|
|
2022-11-11 21:34:08 +00:00
|
|
|
config {
|
|
|
|
image = "${image}"
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~if image_pull_timeout != null ~}
|
2023-02-27 19:48:24 +00:00
|
|
|
image_pull_timeout = "${image_pull_timeout}"
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if service_port != null ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
ports = ["main"]
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if length(try(args, [])) > 0 ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
args = ${jsonencode(args)}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if length(docker_devices) > 0 ~}
|
2023-04-20 23:47:07 +00:00
|
|
|
devices = [
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ for dev in docker_devices ~}
|
2023-04-20 23:47:07 +00:00
|
|
|
{
|
|
|
|
host_path = "${dev.host_path}"
|
|
|
|
container_path = "${dev.container_path}"
|
|
|
|
},
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
2023-04-20 23:47:07 +00:00
|
|
|
]
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ for template in templates ~}
|
|
|
|
%{~ if template.mount && !template.env }
|
2022-11-11 21:34:08 +00:00
|
|
|
mount {
|
|
|
|
type = "bind"
|
|
|
|
target = "${template.dest}"
|
|
|
|
source = "${template.dest_prefix}/${template.dest}"
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ endfor ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if length(env) > 0 }
|
2022-11-11 21:34:08 +00:00
|
|
|
env = {
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ for k, v in env ~}
|
|
|
|
"${k}" = ${jsonencode(v)}
|
|
|
|
%{~ endfor ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ for volume in host_volumes }
|
2022-11-11 21:34:08 +00:00
|
|
|
volume_mount {
|
|
|
|
volume = "${volume.name}"
|
|
|
|
destination = "${volume.dest}"
|
|
|
|
read_only = ${volume.read_only}
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
|
|
|
%{~ for template in templates }
|
2022-11-11 21:34:08 +00:00
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
${template.data}
|
|
|
|
EOF
|
|
|
|
destination = "${coalesce(template.dest_prefix, "$${NOMAD_TASK_DIR}")}/${template.dest}"
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if template.left_delimiter != null }
|
|
|
|
left_delimiter = "${template.left_delimiter}"
|
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if template.right_delimiter != null }
|
|
|
|
right_delimiter = "${template.right_delimiter}"
|
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if template.change_mode != null }
|
|
|
|
change_mode = "${template.change_mode}"
|
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if template.change_signal != null }
|
|
|
|
change_signal = "${template.change_signal}"
|
|
|
|
%{~ endif ~}
|
2023-11-06 22:41:13 +00:00
|
|
|
%{~ if template.change_script != null }
|
|
|
|
change_script {
|
|
|
|
command = "${template.change_script.command}"
|
|
|
|
args = ${jsonencode(template.change_script.args)}
|
|
|
|
timeout = "${template.change_script.timeout}"
|
|
|
|
fail_on_error = ${template.change_script.fail_on_error}
|
|
|
|
}
|
|
|
|
%{~ endif ~}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if template.env != null }
|
|
|
|
env = ${template.env}
|
|
|
|
%{~ endif ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endfor ~}
|
|
|
|
%{~ if resources != null }
|
2022-11-11 21:34:08 +00:00
|
|
|
resources {
|
|
|
|
cpu = ${resources.cpu}
|
|
|
|
memory = ${resources.memory}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if resources.memory_max != null ~}
|
|
|
|
memory_max = ${resources.memory_max}
|
|
|
|
%{~ endif ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if mysql_bootstrap != null }
|
2023-07-25 17:59:33 +00:00
|
|
|
task "mysql-bootstrap" {
|
2022-11-11 21:34:08 +00:00
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
hook = "prestart"
|
|
|
|
sidecar = false
|
|
|
|
}
|
|
|
|
|
|
|
|
config {
|
|
|
|
image = "mariadb:10"
|
|
|
|
args = [
|
2023-05-09 20:20:36 +00:00
|
|
|
"/usr/bin/timeout",
|
|
|
|
"2m",
|
2022-11-11 21:34:08 +00:00
|
|
|
"/bin/bash",
|
|
|
|
"-c",
|
2023-05-09 20:20:36 +00:00
|
|
|
"until /usr/bin/mysql --defaults-extra-file=$${NOMAD_SECRETS_DIR}/my.cnf < $${NOMAD_SECRETS_DIR}/bootstrap.sql; do sleep 10; done",
|
2022-11-11 21:34:08 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
[client]
|
2023-05-09 20:20:36 +00:00
|
|
|
host=127.0.0.1
|
|
|
|
port=3306
|
2022-11-11 21:34:08 +00:00
|
|
|
user=root
|
2023-08-29 19:48:48 +00:00
|
|
|
{{ with nomadVar "secrets/mysql" -}}
|
2023-03-24 18:24:36 +00:00
|
|
|
password={{ .mysql_root_password }}
|
2022-11-11 21:34:08 +00:00
|
|
|
{{ end -}}
|
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/my.cnf"
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
2023-03-25 05:58:44 +00:00
|
|
|
{{ with nomadVar "nomad/jobs/${name}" -}}
|
|
|
|
{{ $db_name := .${mysql_bootstrap.db_name_key} }}
|
2023-03-24 18:24:36 +00:00
|
|
|
CREATE DATABASE IF NOT EXISTS `{{ .${mysql_bootstrap.db_name_key} }}`
|
2022-11-11 21:34:08 +00:00
|
|
|
CHARACTER SET = 'utf8mb4'
|
|
|
|
COLLATE = 'utf8mb4_unicode_ci';
|
2023-03-24 18:24:36 +00:00
|
|
|
CREATE USER IF NOT EXISTS '{{ .${mysql_bootstrap.db_user_key} }}'@'%'
|
|
|
|
IDENTIFIED BY '{{ .${mysql_bootstrap.db_pass_key} }}';
|
|
|
|
GRANT ALL ON `{{ .${mysql_bootstrap.db_name_key} }}`.*
|
|
|
|
TO '{{ .${mysql_bootstrap.db_user_key} }}'@'%';
|
2023-03-25 05:58:44 +00:00
|
|
|
%{ if mysql_bootstrap.add_ro ~}
|
|
|
|
{{ with nomadService "grafana" }}{{ with nomadVar "nomad/jobs" -}}
|
|
|
|
-- Grant grafana read_only user access to db
|
|
|
|
GRANT SELECT ON `{{ $db_name }}`.* to '{{ .db_user_ro }}'@'%';
|
|
|
|
{{ end }}{{ end }}
|
|
|
|
%{~ endif }
|
2022-11-11 21:34:08 +00:00
|
|
|
{{ else -}}
|
|
|
|
SELECT 'NOOP';
|
|
|
|
{{ end -}}
|
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/bootstrap.sql"
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
|
|
|
memory = 50
|
|
|
|
}
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if postgres_bootstrap != null }
|
2023-07-25 17:59:33 +00:00
|
|
|
task "postgres-bootstrap" {
|
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
hook = "prestart"
|
|
|
|
sidecar = false
|
|
|
|
}
|
|
|
|
|
|
|
|
config {
|
|
|
|
image = "postgres:14"
|
|
|
|
args = [
|
|
|
|
"/usr/bin/timeout",
|
|
|
|
"2m",
|
|
|
|
"/bin/bash",
|
|
|
|
"-c",
|
|
|
|
"until /bin/bash $${NOMAD_TASK_DIR}/bootstrap.sh; do sleep 10; done",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ if length(postgres_bootstrap.databases) > 0 ~}
|
|
|
|
%{ for db_name in postgres_bootstrap.databases }
|
2023-07-25 23:40:35 +00:00
|
|
|
/usr/bin/createdb ${db_name}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ endfor ~}
|
|
|
|
%{ else ~}
|
2023-07-25 23:40:35 +00:00
|
|
|
{{ with nomadVar "nomad/jobs/${name}" }}/usr/bin/createdb {{ .${postgres_bootstrap.db_name_key} }}{{ end }}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ endif ~}
|
2023-07-25 23:40:35 +00:00
|
|
|
/usr/bin/psql -X -f $${NOMAD_SECRETS_DIR}/bootstrap.sql
|
2023-07-25 17:59:33 +00:00
|
|
|
EOF
|
2023-07-25 23:40:35 +00:00
|
|
|
destination = "$${NOMAD_TASK_DIR}/bootstrap.sh"
|
2023-07-25 17:59:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
PGHOSTADDR=127.0.0.1
|
|
|
|
PGPORT=5432
|
2023-08-29 19:48:48 +00:00
|
|
|
{{ with nomadVar "secrets/postgres" }}
|
2023-07-25 17:59:33 +00:00
|
|
|
PGUSER={{ .superuser }}
|
|
|
|
# TODO: Passfile?
|
|
|
|
PGPASSWORD={{ .superuser_pass }}
|
|
|
|
{{ end }}
|
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/db.env"
|
|
|
|
env = true
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
{{ with nomadVar "nomad/jobs/${name}" -}}
|
|
|
|
DO $$
|
|
|
|
BEGIN
|
|
|
|
CREATE ROLE {{ .${postgres_bootstrap.db_user_key} }} LOGIN PASSWORD '{{ .${postgres_bootstrap.db_pass_key} }}';
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ if length(postgres_bootstrap.databases) > 0 ~}
|
2023-07-25 23:40:35 +00:00
|
|
|
%{ for db_name in postgres_bootstrap.databases }
|
|
|
|
GRANT ALL ON DATABASE "${db_name}" TO {{ .${postgres_bootstrap.db_user_key} }};
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ endfor ~}
|
|
|
|
%{ else ~}
|
2023-07-25 17:59:33 +00:00
|
|
|
GRANT ALL ON DATABASE "{{ .${postgres_bootstrap.db_name_key} }}" TO {{ .${postgres_bootstrap.db_user_key} }};
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ endif ~}
|
2023-07-25 17:59:33 +00:00
|
|
|
EXCEPTION WHEN duplicate_object THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE;
|
|
|
|
END
|
|
|
|
$$;
|
|
|
|
{{ end }}
|
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/bootstrap.sql"
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
|
|
|
memory = 50
|
|
|
|
}
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
|
|
|
%{~ if use_mysql || use_redis || use_ldap || use_postgres }
|
2023-05-09 20:20:36 +00:00
|
|
|
task "stunnel" {
|
2023-03-25 05:58:44 +00:00
|
|
|
driver = "docker"
|
|
|
|
|
2023-05-09 20:20:36 +00:00
|
|
|
lifecycle {
|
|
|
|
hook = "prestart"
|
|
|
|
sidecar = true
|
|
|
|
}
|
|
|
|
|
2023-03-25 05:58:44 +00:00
|
|
|
config {
|
|
|
|
image = "alpine:3.17"
|
|
|
|
args = ["/bin/sh", "$${NOMAD_TASK_DIR}/start.sh"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
2023-08-07 18:31:35 +00:00
|
|
|
cpu = ${stunnel_resources.cpu}
|
|
|
|
memory = ${stunnel_resources.memory}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ if stunnel_resources.memory_max != null ~}
|
|
|
|
memory_max = ${stunnel_resources.memory_max}
|
|
|
|
%{~ endif ~}
|
2023-03-25 05:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
set -e
|
|
|
|
apk add stunnel
|
|
|
|
exec stunnel {{ env "NOMAD_TASK_DIR" }}/stunnel.conf
|
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_TASK_DIR}/start.sh"
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
syslog = no
|
|
|
|
foreground = yes
|
|
|
|
delay = yes
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ if use_mysql }
|
2023-05-09 20:20:36 +00:00
|
|
|
[mysql_client]
|
|
|
|
client = yes
|
|
|
|
accept = 127.0.0.1:3306
|
2023-08-24 22:37:42 +00:00
|
|
|
{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "mysql-tls" }}
|
2023-05-09 20:20:36 +00:00
|
|
|
connect = {{ .Address }}:{{ .Port }}
|
2023-08-24 22:37:42 +00:00
|
|
|
{{ end }}
|
2023-05-09 20:20:36 +00:00
|
|
|
PSKsecrets = {{ env "NOMAD_SECRETS_DIR" }}/mysql_stunnel_psk.txt
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ endif ~}
|
|
|
|
%{ if use_redis }
|
2023-03-25 05:58:44 +00:00
|
|
|
[redis_client]
|
|
|
|
client = yes
|
|
|
|
accept = 127.0.0.1:6379
|
2023-08-24 22:37:42 +00:00
|
|
|
{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "redis-${name}" }}
|
2023-03-25 05:58:44 +00:00
|
|
|
connect = {{ .Address }}:{{ .Port }}
|
2023-08-24 22:37:42 +00:00
|
|
|
{{ end }}
|
2023-05-09 20:20:36 +00:00
|
|
|
PSKsecrets = {{ env "NOMAD_SECRETS_DIR" }}/redis_stunnel_psk.txt
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ endif }
|
|
|
|
%{ if use_ldap }
|
2023-07-07 00:16:36 +00:00
|
|
|
[ldap_client]
|
|
|
|
client = yes
|
|
|
|
accept = 127.0.0.1:389
|
2023-08-24 22:37:42 +00:00
|
|
|
{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "lldap-tls" }}
|
2023-07-07 00:16:36 +00:00
|
|
|
connect = {{ .Address }}:{{ .Port }}
|
2023-08-24 22:37:42 +00:00
|
|
|
{{ end }}
|
2023-07-07 00:16:36 +00:00
|
|
|
PSKsecrets = {{ env "NOMAD_SECRETS_DIR" }}/ldap_stunnel_psk.txt
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ endif ~}
|
|
|
|
%{ if use_postgres ~}
|
2023-07-25 17:59:33 +00:00
|
|
|
[postgres_client]
|
|
|
|
client = yes
|
|
|
|
accept = 127.0.0.1:5432
|
2023-08-24 22:37:42 +00:00
|
|
|
{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "postgres-tls" }}
|
2023-07-25 17:59:33 +00:00
|
|
|
connect = {{ .Address }}:{{ .Port }}
|
2023-08-24 22:37:42 +00:00
|
|
|
{{ end }}
|
2023-07-25 17:59:33 +00:00
|
|
|
PSKsecrets = {{ env "NOMAD_SECRETS_DIR" }}/postgres_stunnel_psk.txt
|
2023-08-24 22:37:42 +00:00
|
|
|
%{ endif ~}
|
2023-03-25 05:58:44 +00:00
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_TASK_DIR}/stunnel.conf"
|
|
|
|
}
|
2023-05-09 20:20:36 +00:00
|
|
|
%{~ if use_mysql }
|
2023-03-25 05:58:44 +00:00
|
|
|
template {
|
|
|
|
data = <<EOF
|
2023-08-29 19:48:48 +00:00
|
|
|
{{- with nomadVar "secrets/mysql/allowed_psks/${name}" }}{{ .psk }}{{ end -}}
|
2023-05-09 20:20:36 +00:00
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/mysql_stunnel_psk.txt"
|
2023-03-25 05:58:44 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2023-05-09 20:20:36 +00:00
|
|
|
%{~ if use_redis }
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
2023-07-19 17:57:33 +00:00
|
|
|
{{- with nomadVar "nomad/jobs/${name}/${name}/stunnel" }}{{ .redis_stunnel_psk }}{{ end -}}
|
2023-05-09 20:20:36 +00:00
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/redis_stunnel_psk.txt"
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2023-07-07 00:16:36 +00:00
|
|
|
%{~ if use_ldap }
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
2023-08-29 19:48:48 +00:00
|
|
|
{{- with nomadVar "secrets/ldap/allowed_psks/${name}" }}{{ .psk }}{{ end -}}
|
2023-07-07 00:16:36 +00:00
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/ldap_stunnel_psk.txt"
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2023-07-25 17:59:33 +00:00
|
|
|
%{~ if use_postgres }
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
2023-08-29 19:48:48 +00:00
|
|
|
{{- with nomadVar "secrets/postgres/allowed_psks/${name}" }}{{ .psk }}{{ end -}}
|
2023-07-25 17:59:33 +00:00
|
|
|
EOF
|
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/postgres_stunnel_psk.txt"
|
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2023-03-25 05:58:44 +00:00
|
|
|
}
|
2023-08-24 22:37:42 +00:00
|
|
|
%{~ endif ~}
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
|
|
|
}
|