-
Notifications
You must be signed in to change notification settings - Fork 0
/
32-anthos-pre-reqs.tf
45 lines (38 loc) · 1.21 KB
/
32-anthos-pre-reqs.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
data "template_file" "anthos_pre_reqs_script" {
template = file("anthos/pre_reqs.sh")
vars = {
anthos_version = var.anthos_version
whitelisted_key_name = var.whitelisted_key_name
vcenter_fqdn = format("vcva.%s", var.domain_name)
}
}
resource "null_resource" "anthos_pre_reqs" {
count = var.anthos_deploy_workstation_prereqs ? 1 : 0
depends_on = [null_resource.install_vpn_server]
connection {
type = "ssh"
user = "root"
private_key = file("~/.ssh/${local.ssh_key_name}")
host = packet_device.router.access_public_ipv4
}
provisioner "file" {
content = chomp(tls_private_key.anthos_ssh_key.private_key_pem)
destination = "/root/anthos/ssh_key"
}
provisioner "file" {
content = chomp(tls_private_key.anthos_ssh_key.public_key_openssh)
destination = "/root/anthos/ssh_key.pub"
}
provisioner "file" {
content = data.template_file.anthos_pre_reqs_script.rendered
destination = "/root/anthos/pre_reqs.sh"
}
provisioner "remote-exec" {
inline = [
"cd /root/anthos",
"chmod 0400 /root/anthos/ssh_key",
"chmod +x /root/anthos/pre_reqs.sh",
"/root/anthos/pre_reqs.sh"
]
}
}