-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVaultServer.tf
55 lines (45 loc) · 1.43 KB
/
VaultServer.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
resource "metal_device" "vault_server" {
depends_on = [metal_ssh_key.host_key]
project_id = var.metal_project_id
metro = var.metro
plan = var.plan
operating_system = var.operating_system
hostname = format("vault%02d", count.index)
# should be an odd number
# > 1 will require update to the consul config file bootstrap values
count = var.vault_count
billing_cycle = "hourly"
connection {
user = "root"
host = self.access_public_ipv4
private_key = file(var.private_key_filename)
}
provisioner "remote-exec" {
inline = [
"ssh-keygen -A",
"apt-get update -y >> apt.out",
"apt-get install fortune tcpflow dnsutils zip asciinema -y >> apt.out",
"mkdir -p /etc/vault.d",
]
}
provisioner "file" {
source = "${path.module}/assets/vault-server-config.json"
destination = "/etc/vault.d/vault-server-config.json"
}
provisioner "file" {
source = "${path.module}/assets/StartVaultServer.sh"
destination = "/usr/local/bin/StartVaultServer.sh"
}
provisioner "file" {
source = "${path.module}/assets/vault_install.sh"
destination = "vault_install.sh"
}
provisioner "remote-exec" {
inline = [
"bash vault_install.sh > vault_install.out",
"chmod 755 /usr/local/bin/StartVaultServer.sh",
"screen -dmS vault /usr/local/bin/StartVaultServer.sh",
"sleep 10"
]
}
}