-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathhosts.tf
40 lines (32 loc) · 1.61 KB
/
hosts.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
resource "null_resource" "controller" {
count = "${var.controller_count}"
triggers {
hostname_prefix = "${format("controller-%02d", count.index + 1)}"
}
}
resource "null_resource" "worker" {
count = "${var.worker_count}"
triggers {
hostname_prefix = "${format("worker-%02d", count.index + 1)}"
}
}
locals {
public_ipv4 = "${concat(packet_device.controller.*.access_public_ipv4,
packet_device.worker.*.access_public_ipv4)}"
controller_hostnames = "${formatlist("%v.%v",
null_resource.controller.*.triggers.hostname_prefix,
var.server_domain)}"
worker_hostnames = "${formatlist("%v.%v",
null_resource.worker.*.triggers.hostname_prefix,
var.server_domain)}"
hostnames = "${concat(local.controller_hostnames, local.worker_hostnames)}"
hosts_entries = "${formatlist("%v %v %v",
local.public_ipv4,
concat(null_resource.controller.*.triggers.hostname_prefix,
null_resource.worker.*.triggers.hostname_prefix),
local.hostnames)}"
termination_timestamps = "${compact(concat(packet_device.controller.*.termination_timestamp,
packet_device.worker.*.termination_timestamp))}"
termination_time_remainings = "${compact(concat(packet_device.controller.*.termination_time_remaining,
packet_device.worker.*.termination_time_remaining))}"
}