-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_data.tf
More file actions
53 lines (51 loc) · 1.49 KB
/
user_data.tf
File metadata and controls
53 lines (51 loc) · 1.49 KB
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
locals {
user_data_input = {
"node_class" = "nomad-server"
"datacenter" = "dc1"
"servers" = []
"interface" = "eth0"
"consul_token" = ""
"nomad_token" = ""
}
server_init_config = {
apt = {
sources = {
"hashicorp-releases.list" = {
keyid = "798AEC654E5C15428C8E42EEAA16FCBCA621E701"
source = "deb [arch=amd64] https://apt.releases.hashicorp.com $RELEASE main"
}
"docker.list" = {
keyid = "9DC858229FC7DD38854AE2D88D81803C0EBFCD88"
source = "deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable"
}
}
}
packages = [
"nomad",
"consul",
"docker-ce",
"docker-ce-cli",
"containerd.io",
"jq",
]
runcmd = [
["/usr/bin/bootstrap.sh"],
]
write_files = [
{
path = "/etc/nomad.d/nomad.hcl"
permissions = "0644"
content = templatefile("${path.module}/templates/nomad.hcl.tmpl", local.user_data_input)
}, {
path = "/etc/consul.d/consul.hcl"
permissions = "0644"
content = templatefile("${path.module}/templates/consul.hcl.tmpl", local.user_data_input)
}, {
path = "/usr/bin/bootstrap.sh"
permissions = "0755"
content = templatefile("${path.module}/templates/bootstrap.sh", local.user_data_input)
}
]
}
server_user_data = "#cloud-config\n${yamlencode(local.server_init_config)}"
}