-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
80 lines (64 loc) · 1.4 KB
/
main.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
terraform {
cloud {
organization = "ffddorf"
workspaces {
tags = [
"supernodes",
"managed",
]
}
}
required_providers {
netbox = {
source = "e-breuninger/netbox"
version = "2.0.5"
}
}
}
provider "netbox" {
server_url = var.netbox_server
api_token = var.netbox_api_token
}
module "tag" {
source = "./modules/tag"
}
module "cluster" {
source = "./modules/cluster"
}
module "network" {
source = "./modules/network"
prefix_ipv4 = var.prefix_ipv4
prefix_ipv6 = var.prefix_ipv6
tags = [module.tag.name]
}
module "tunnel" {
source = "./modules/tunnel"
tunnel_prefix_ipv4 = var.tunnel_prefix_ipv4
tunnel_prefix_ipv6 = var.tunnel_prefix_ipv6
}
data "netbox_virtual_machines" "supernodes" {
filter {
name = "cluster_id"
value = module.cluster.id
}
}
locals {
supernodes = {
for vm in data.netbox_virtual_machines.supernodes.vms :
vm.name => vm
if vm.status == "active"
}
}
module "supernode" {
source = "./modules/supernode"
cluster_id = each.value.cluster_id
vm_id = each.value.vm_id
name = each.key
prefix_ipv4_id = module.network.ipv4
prefix_ipv6_id = module.network.ipv6
tunnel_prefix_ipv4_id = module.tunnel.ipv4
tunnel_prefix_ipv6_id = module.tunnel.ipv6
core_router_names = var.core_router_names
for_each = local.supernodes
tags = [module.tag.name]
}