-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnomad.tf
101 lines (86 loc) · 2.53 KB
/
nomad.tf
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
data "linuxkit_image" "nomad" {
name = "nomad"
image = "ghcr.io/resinstack/nomad:${var.nomad_version}"
command = ["/usr/bin/runsv", "/service/nomad"]
capabilities = [
"CAP_CHOWN",
"CAP_NET_ADMIN",
"CAP_SYS_ADMIN",
]
binds = [
"/etc/nomad:/etc/nomad",
"/etc/resolv.cluster:/etc/resolv.conf",
"/lib/modules:/lib/modules",
"/run:/run:rshared",
"/service:/service",
"/usr/bin/runsv:/usr/bin/runsv",
"/var:/var:rshared",
# This looks really really dumb, but hear me out: Nomad needs to
# see the consul binary while doing connect things. Rather than
# trying to include it with this nomad container and potentially
# including an out of date version and then needing to maintain
# two update criteria, we cheat and mount in the one that's at a
# particularly magic path from the adjacent consul service
# container. Don't try this at home, filmed on a closed course,
# void where prohibited.
"/containers/services/consul/lower/bin/consul:/usr/local/bin/consul",
]
rootfs_propagation = "shared"
runtime {
mkdir = flatten([[
"/var/persist/nomad",
"/var/run/config/nomad",
"/run/runit/supervise.nomad",
],
var.nomad_mkdirs,
])
}
}
data "linuxkit_file" "nomad_svc" {
path = "service/nomad/run"
contents = "#!/bin/sh\nexec /usr/local/bin/nomad agent -config /etc/nomad -config /run/config/nomad\n"
mode = "0755"
optional = false
}
data "linuxkit_file" "nomad_spr" {
path = "service/nomad/supervise"
symlink = "/run/runit/supervise.nomad"
optional = false
}
data "linuxkit_file" "nomad_base" {
path = "etc/nomad/25-base.hcl"
source = "${path.module}/files/nomad/25-base.hcl"
mode = "0644"
optional = false
}
data "linuxkit_file" "nomad_server" {
path = "etc/nomad/40-server.hcl"
source = "${path.module}/files/nomad/40-server.hcl"
mode = "0644"
optional = false
}
data "linuxkit_file" "nomad_client" {
path = "etc/nomad/40-client.hcl"
source = "${path.module}/files/nomad/40-client.hcl"
mode = "0644"
optional = false
}
data "linuxkit_file" "nomad_acl" {
path = "etc/nomad/10-acl.hcl"
contents = templatefile("${path.module}/tmpl/nomad/10-acl.hcl.tpl", {
nomad_acl_enabled = var.nomad_acl
})
mode = "0644"
optional = false
}
data "linuxkit_file" "nomad_client_vault" {
path = "etc/nomad/50-vault.hcl"
contents = <<EOT
vault {
enabled = true
address = "http://active.vault.service.consul:8200"
}
EOT
mode = "0644"
optional = false
}