Allow custom job_name

This commit is contained in:
Daniel Berteaud 2023-09-03 22:38:07 +02:00
parent a501abcd91
commit 392c2aa23e
4 changed files with 13 additions and 8 deletions

View File

@ -1,4 +1,4 @@
job "acme-to-vault" {
job [[ .acme.job_name | toJSON ]] {
type = "[[ if ne "" .acme.cron ]]service[[ else ]]batch[[ end ]]"
[[- template "common/job_start.tpl" dict "nomad" .nomad ]]
@ -10,17 +10,17 @@ job "acme-to-vault" {
}
service {
name = "acme-to-vault[[ .env.suffix ]]"
name = "[[ .acme.job_name ]][[ .env.suffix ]]"
port = 8787
[[ template "common/connect.tpl" dict "ctx" . "config" .acme ]]
tags = [
"[[ .traefik.instance ]].enable=true",
"[[ .traefik.instance ]].http.routers.acme-to-vault[[ .env.suffix ]].rule=PathPrefix(`/.well-known/acme-challenge/`)",
"[[ .traefik.instance ]].http.routers.acme-to-vault[[ .env.suffix ]].priority=[[ .acme.traefik.priority ]]",
"[[ .traefik.instance ]].http.routers.acme-to-vault[[ .env.suffix ]].entrypoints=[[ join (merge .acme.traefik .traefik).entrypoints "," ]]",
"[[ .traefik.instance ]].http.routers.acme-to-vault[[ .env.suffix ]].middlewares=[[ join (merge .acme.traefik .traefik).middlewares "," ]]"
"[[ .traefik.instance ]].http.routers.[[ .acme.job_name ]][[ .env.suffix ]].rule=PathPrefix(`/.well-known/acme-challenge/`)",
"[[ .traefik.instance ]].http.routers.[[ .acme.job_name ]][[ .env.suffix ]].priority=[[ .acme.traefik.priority ]]",
"[[ .traefik.instance ]].http.routers.[[ .acme.job_name ]][[ .env.suffix ]].entrypoints=[[ join (merge .acme.traefik .traefik).entrypoints "," ]]",
"[[ .traefik.instance ]].http.routers.[[ .acme.job_name ]][[ .env.suffix ]].middlewares=[[ template "common/traefik_middlewares.tpl" merge .acme.traefik .traefik ]]"
]
}
@ -32,11 +32,12 @@ job "acme-to-vault" {
}
vault {
policies = ["acme-to-vault[[ .env.suffix ]]"]
policies = ["[[ .acme.job_name ]][[ .env.suffix ]]"]
}
env {
TZ = [[ .locale.tz | toJSON ]]
LANG = [[ .locale.lang | toJSON ]]
[[- if has .acme.vault "service_name" ]]
VAULT_ADDR = "http://localhost:8200"
[[- else ]]

2
deps/common vendored

@ -1 +1 @@
Subproject commit df3e7fd52e5758d54c0dcad522260b1416d92884
Subproject commit a1738a81645748892a34d990c6df07cd1b4815ad

1
prep.d/mv_conf.sh Executable file
View File

@ -0,0 +1 @@
[[ template "common/mv_conf.sh.tpl" dict "ctx" . "services" (dict "acme-to-vault" .acme.job_name) ]]

View File

@ -1,6 +1,9 @@
---
acme:
# The name of the Nomad job
job_name: acme-to-vault
# The Docker image to use
image: danielberteaud/acme-to-vault:20230828-1