summaryrefslogtreecommitdiff
path: root/jobs/certificates.nomad.hcl
blob: 22b0ab6de2394b7810bf5cf3595a7d41218fab8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
job "certificates" {
  type = "batch"

  periodic {
    cron = "@monthly"
  }

  group "lego" {
    volume "certs" {
      type   = "host"
      source = "ca-certificates"
    }

    task "lego" {
      driver = "exec"

      volume_mount {
        volume      = "certs"
        destination = "/lego"
      }

      config {
        command = "lego"
        args = [
          "--accept-tos",
          "--path", "/lego",
          "--email", "mathias+certs@magnusson.space",
          "--dns", "cloudflare",
          "-d", "magnusson.space", "-d", "*.magnusson.space",
          "-d", "magnusson.wiki", "-d", "*.magnusson.wiki",
          "run"
        ]
      }

      artifact {
        source = "https://github.com/go-acme/lego/releases/download/v4.13.3/lego_v4.13.3_linux_amd64.tar.gz"
      }

      template {
        data = <<EOF
{{ with nomadVar "nomad/jobs/certificates" }}
CLOUDFLARE_DNS_API_TOKEN={{ .cloudflare_dns_api_token }}
{{ end }}
EOF
        destination = "local/.env"
        env         = true
      }
    }
  }
}