-
Notifications
You must be signed in to change notification settings - Fork 0
/
hosts.tf
76 lines (64 loc) · 2 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
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
data "template_file" "master_config" {
template = "${file("files/init.tpl")}"
count = "${var.k8s_masters}"
vars {
hostname = "${format("master%02d", count.index + 1)}"
fqdn = "${format("master%02d", count.index + 1)}.${var.domain_name}"
root_size = "40G"
}
}
data "template_file" "node_config" {
template = "${file("files/init.tpl")}"
count = "${var.k8s_nodes}"
vars {
hostname = "${format("node%02d", count.index + 1)}"
fqdn = "${format("node%02d", count.index + 1)}.${var.domain_name}"
root_size = "20G"
}
}
resource "openstack_compute_instance_v2" "master" {
name = "${format("master%02d", count.index + 1)}.${var.domain_name}"
flavor_name = "${var.master_type}"
key_pair = "${openstack_compute_keypair_v2.ssh-keypair.name}"
user_data = "${element(data.template_file.master_config.*.rendered, count.index)}"
count = "${var.k8s_masters}"
block_device {
uuid = "${element(openstack_blockstorage_volume_v2.master.*.id, count.index)}"
source_type = "volume"
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
network {
name = "${var.network_name}"
}
security_groups = [
"${var.local_ssh_sec_group}",
"${var.local_consul_sec_group}",
"${openstack_networking_secgroup_v2.k8s.name}",
]
connection {
user = "centos"
private_key = "${file(var.private_key_file)}"
}
provisioner "remote-exec" {
inline = [
"sudo rpm-ostree install unzip",
"sudo systemctl reboot",
]
}
# provisioner "file" {
# content = "${data.template_file.setup_consul.rendered}"
# destination = "/tmp/install_consul.sh"
# }
# provisioner "file" {
# source = "files/attach_data_vol.sh"
# destination = "/tmp/attach_data_vol.sh"
# }
# provisioner "remote-exec" {
# inline = [
# "sudo chmod a+x /tmp/install_consul.sh",
# "sudo /tmp/install_consul.sh"
# ]
# }
}