-
Notifications
You must be signed in to change notification settings - Fork 6
/
06_provision_storage.tf
120 lines (101 loc) · 3.29 KB
/
06_provision_storage.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
module "provision_storage_nodes" {
source = "./provision"
worker_count= "${var.storage_node_count}"
master_ip_address= "${openstack_networking_floatingip_v2.masterip.address}"
privkey= "${var.privkey}"
env_name= "${var.env_name}"
node_type="storage"
node_host_ips = "${module.compute_storage_nodes.worker-instance-fixed-ips}"
k8s_join_command = "${lookup(data.external.k8s_join_response.result, "command")}"
docker_device_list = "${module.compute_storage_nodes.worker-docker-devices}"
master_provision_dependency = "${null_resource.provision_master.id}"
}
resource "null_resource" "provision_storage_mounts" {
depends_on = ["module.provision_storage_nodes"]
count = "${var.storage_node_count}"
connection {
bastion_host = "${openstack_networking_floatingip_v2.masterip.address}"
user = "ubuntu"
private_key = "${file("${var.privkey}")}"
host = "${module.compute_storage_nodes.worker-instance-fixed-ips[count.index]}"
timeout = "5m"
}
provisioner "file" {
source = "assets/bootstrap-storage.sh"
destination = "/home/ubuntu/bootstrap-storage.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /home/ubuntu/bootstrap-storage.sh",
"sudo /home/ubuntu/bootstrap-storage.sh ${local.storage-volume-devices[count.index]}"
]
}
}
## Label the storage node
resource "null_resource" "label_storage_nodes" {
depends_on = ["module.provision_storage_nodes"]
count = "${var.storage_node_count}"
connection {
user = "ubuntu"
private_key = "${file("${var.privkey}")}"
host = "${openstack_networking_floatingip_v2.masterip.address}"
}
# Label the storage nodes that have external volumes attached
provisioner "remote-exec" {
inline = [
"kubectl label node ${var.env_name}-storage${count.index} external-storage=true"
]
}
}
resource "null_resource" "install_nfs" {
depends_on = [
"null_resource.provision_storage_mounts",
]
# Don't install if there are no storage nodes in use
count = "${(var.storage_node_count == 1) ? 1 : 0}"
connection {
user = "ubuntu"
private_key = "${file("${var.privkey}")}"
host = "${openstack_networking_floatingip_v2.masterip.address}"
}
provisioner "file" {
source = "assets/nfs"
destination = "/home/ubuntu"
}
provisioner "file" {
source = "assets/deploy-nfs.sh"
destination = "/home/ubuntu/deploy-nfs.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /home/ubuntu/deploy-nfs.sh",
"/home/ubuntu/deploy-nfs.sh"
]
}
}
resource "null_resource" "install_glfs" {
depends_on = [
"null_resource.provision_storage_mounts",
]
# Don't install if there aren't enough storage nodes in use
count = "${var.storage_node_count > 1 ? 1 : 0}"
connection {
user = "ubuntu"
private_key = "${file("${var.privkey}")}"
host = "${openstack_networking_floatingip_v2.masterip.address}"
}
provisioner "file" {
source = "assets/glfs"
destination = "/home/ubuntu"
}
provisioner "file" {
source = "assets/deploy-glfs.sh"
destination = "/home/ubuntu/deploy-glfs.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /home/ubuntu/deploy-glfs.sh",
"/home/ubuntu/deploy-glfs.sh ${var.storage_node_count}"
]
}
}