-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path07-provision-compute.tf
111 lines (100 loc) · 4.45 KB
/
07-provision-compute.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
102
103
104
105
106
107
108
109
110
111
# Provision compute Hosts
resource "equinix_metal_device" "compute" {
count = var.compact == "false" ? length(var.compute_names) : 3
hostname = var.compute_names[count.index].servername
project_id = var.project_id
metro = var.metro
plan = var.compute_size
operating_system = var.ubuntu_version
billing_cycle = var.billing_cycle
user_data = templatefile("build-hosts.sh", {
hostname = var.compute_names[count.index].servername
admin_vlan = var.admin_vlan.vxlan,
internal_vlan = var.internal_vlan.vxlan,
public_vlan = var.public_vlan.vxlan,
storage_vlan = var.storage_vlan.vxlan,
storagerep_vlan = var.storagerep_vlan.vxlan,
data_vlan = var.data_vlan.vxlan,
overlay_vlan = var.overlay_vlan.vxlan,
adminip = var.compute_admin_ips[count.index].adminip,
internalip = var.compute_internal_ips[count.index].internalip,
publicip = "",
storageip = var.compute_storage_ips[count.index].storageip,
storagerepip = "",
dataip = var.compute_data_ips[count.index].dataip,
admin_cidr = var.admin_cidr,
admin_gateway = var.admin_gateway,
admin_dns = var.admin_dns,
internal_cidr = var.internal_cidr,
public_cidr = "",
storage_cidr = var.storage_cidr,
storagerep_cidr = "",
data_cidr = var.data_cidr,
ubuntu_user_pw = var.ubuntu_user_pw,
inspace_internal = "true",
inspace_public = "false",
inspace_storage = "true",
inspace_storagerep = "false",
inspace_data = "true",
inspace_overlay = "true"
})
}
resource "time_sleep" "compute_allow_update" {
create_duration = "5m"
depends_on = [equinix_metal_device.compute]
}
resource "equinix_metal_device_network_type" "compute" {
count = var.compact == "false" ? length(var.compute_names) : 3
device_id = equinix_metal_device.compute[count.index].id
type = "layer2-bonded"
depends_on = [time_sleep.compute_allow_update]
}
resource "equinix_metal_port_vlan_attachment" "compute_admin" {
count = var.compact == "false" ? length(var.compute_names) : 3
device_id = equinix_metal_device.compute[count.index].id
vlan_vnid = equinix_metal_vlan.admin_vlan.vxlan
port_name = "bond0"
depends_on = [equinix_metal_device_network_type.compute]
}
resource "equinix_metal_port_vlan_attachment" "compute_internal" {
count = var.compact == "false" ? length(var.compute_names) : 3
device_id = equinix_metal_device.compute[count.index].id
vlan_vnid = equinix_metal_vlan.internal_vlan.vxlan
port_name = "bond0"
depends_on = [equinix_metal_device_network_type.compute]
}
resource "equinix_metal_port_vlan_attachment" "compute_storage" {
count = var.compact == "false" ? length(var.compute_names) : 3
device_id = equinix_metal_device.compute[count.index].id
vlan_vnid = equinix_metal_vlan.storage_vlan.vxlan
port_name = var.compute_size == "n3.xlarge.x86" ? "bond1" : "bond0"
depends_on = [equinix_metal_device_network_type.compute]
}
resource "equinix_metal_port_vlan_attachment" "compute_storagerep" {
count = var.compact == "false" ? length(var.compute_names) : 3
device_id = equinix_metal_device.compute[count.index].id
vlan_vnid = equinix_metal_vlan.storagerep_vlan.vxlan
port_name = var.compute_size == "n3.xlarge.x86" ? "bond1" : null
depends_on = [equinix_metal_device_network_type.compute]
}
resource "equinix_metal_port_vlan_attachment" "compute_data" {
count = var.compact == "false" ? length(var.compute_names) : 3
device_id = equinix_metal_device.compute[count.index].id
vlan_vnid = equinix_metal_vlan.data_vlan.vxlan
port_name = "bond0"
depends_on = [equinix_metal_device_network_type.compute]
}
resource "equinix_metal_port_vlan_attachment" "compute_overlay" {
count = var.compact == "false" ? length(var.compute_names) : 3
device_id = equinix_metal_device.compute[count.index].id
vlan_vnid = equinix_metal_vlan.overlay_vlan.vxlan
port_name = "bond0"
depends_on = [equinix_metal_device_network_type.compute]
}
resource "equinix_metal_port_vlan_attachment" "compute_external" {
count = var.compact == "false" ? length(var.compute_names) : 3
device_id = equinix_metal_device.compute[count.index].id
vlan_vnid = equinix_metal_vlan.external_vlan.vxlan
port_name = "bond0"
depends_on = [equinix_metal_device_network_type.compute]
}