-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20_res_vhi_cluster.tf
131 lines (122 loc) · 4.01 KB
/
20_res_vhi_cluster.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
## VHI MN node instances
resource "openstack_compute_instance_v2" "vhi_mn_nodes" {
count = var.mn_count # default = 3
name = "node${count.index + 1}.lab"
flavor_id = data.openstack_compute_flavor_v2.vhi-main.id
key_pair = openstack_compute_keypair_v2.ssh_key.name
block_device {
uuid = data.openstack_images_image_v2.vhi_image.id
source_type = "image"
volume_size = 150
boot_index = 0
destination_type = "volume"
delete_on_termination = true
}
block_device {
source_type = "blank"
destination_type = "volume"
volume_size = 100
boot_index = 1
delete_on_termination = true
}
block_device {
source_type = "blank"
destination_type = "volume"
volume_size = 100
boot_index = 2
delete_on_termination = true
}
network {
name = var.storage_net_name
fixed_ip_v4 = "10.0.100.1${count.index + 1}"
}
network {
name = var.private_net_name
fixed_ip_v4 = "10.0.101.1${count.index + 1}"
}
network {
name = var.public_net_name
fixed_ip_v4 = "10.0.102.1${count.index + 1}"
}
config_drive = true
user_data = templatefile(
"cloud-init/node.sh",
{
storage_ip = "10.0.100.1${count.index + 1}",
private_ip = "10.0.101.1${count.index + 1}",
public_ip = "10.0.102.1${count.index + 1}",
hostname = "node${count.index + 1}.lab",
mn_ip = "10.0.101.11",
ha_ip_public = "10.0.102.10",
ha_ip_private = "10.0.101.10",
password_root = var.password_root,
password_admin = var.password_admin,
cluster_name = var.cluster_name
} )
depends_on = [
openstack_networking_network_v2.lab-private,
openstack_networking_network_v2.lab-storage,
openstack_networking_network_v2.lab-public,
]
}
## VHI worker node instances
resource "openstack_compute_instance_v2" "vhi_worker_nodes" {
count = var.worker_count # default = 1
name = "node${count.index + 4}.lab"
flavor_id = data.openstack_compute_flavor_v2.vhi-worker.id
key_pair = openstack_compute_keypair_v2.ssh_key.name
block_device {
uuid = data.openstack_images_image_v2.vhi_image.id
source_type = "image"
volume_size = 150
boot_index = 0
destination_type = "volume"
delete_on_termination = true
}
block_device {
source_type = "blank"
destination_type = "volume"
volume_size = 100
boot_index = 1
delete_on_termination = true
}
block_device {
source_type = "blank"
destination_type = "volume"
volume_size = 100
boot_index = 2
delete_on_termination = true
}
network {
name = var.storage_net_name
fixed_ip_v4 = "10.0.100.1${count.index + 4}"
}
network {
name = var.private_net_name
fixed_ip_v4 = "10.0.101.1${count.index + 4}"
}
network {
name = var.public_net_name
fixed_ip_v4 = "10.0.102.1${count.index + 4}"
}
config_drive = true
user_data = templatefile(
"cloud-init/node.sh",
{
storage_ip = "10.0.100.1${count.index + 4}",
private_ip = "10.0.101.1${count.index + 4}",
public_ip = "10.0.102.1${count.index + 4}",
hostname = "node${count.index + 4}.lab",
mn_ip = "10.0.101.11",
ha_ip_public = "10.0.102.10",
ha_ip_private = "10.0.101.10",
password_root = var.password_root,
password_admin = var.password_admin,
cluster_name = var.cluster_name
} )
depends_on = [
openstack_networking_network_v2.lab-private,
openstack_networking_network_v2.lab-storage,
openstack_networking_network_v2.lab-public,
]
}