This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.tf
59 lines (54 loc) · 2.06 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
provider "packet" {
auth_token = "${var.packet_auth_token}"
}
resource "packet_project" "humio_performancetest_project" {
name = "Humio"
}
resource "packet_device" "humios" {
count = "${var.instances}"
hostname = "${format("humio%02d-%s", count.index + 1, element(var.facilities, count.index))}"
plan = "${var.humio_plan}"
facility = "${element(var.facilities, count.index)}"
operating_system = "ubuntu_18_04"
billing_cycle = "hourly"
project_id = "${packet_project.humio_performancetest_project.id}"
tags = "${compact(list(
count.index < var.zookeepers ? "zookeepers" : "",
"kafkas",
"humios"
))}"
user_data = <<USERDATA
#!/bin/bash
mkdir -p /etc/ansible/facts.d
echo '${count.index + 1}' > /etc/ansible/facts.d/cluster_index.fact
USERDATA
provisioner "remote-exec" {
inline = [
"apt -y update",
"apt -y install xfsprogs",
<<MDADM
mdadm --create /dev/md/primary $(lsblk -OJ | jq -r '.blockdevices[] | select(.rota == "0" and (has("children") | not)) | "/dev/\(.name)"') --level=0 --raid-devices=$(lsblk -OJ | jq '[.blockdevices[] | select(.rota == "0" and (has("children") | not))] | length')
MDADM
,
<<MDADM
mdadm --create /dev/md/secondary $(lsblk -OJ | jq -r '.blockdevices[] | select(.rota == "1") | "/dev/\(.name)"') --level=0 --raid-devices=$(lsblk -OJ | jq '[.blockdevices[] | select(.rota == "1")] | length')
MDADM
,
"mdadm --detail --scan >> /etc/mdadm/mdadm.conf",
"update-initramfs -u",
"sleep 5s",
"mkfs.xfs /dev/md/primary",
"mkfs.xfs /dev/md/secondary",
]
}
}
resource "packet_device" "ingesters" {
count = "${var.ingester_instances}"
hostname = "${format("ingester%02d", count.index + 1)}"
plan = "${var.ingester_plan}"
facility = "${element(var.ingester_facilities, count.index)}"
operating_system = "ubuntu_18_04"
billing_cycle = "hourly"
project_id = "${packet_project.humio_performancetest_project.id}"
tags = ["ingesters"]
}