-
Notifications
You must be signed in to change notification settings - Fork 0
/
09-deploy-vcva.tf
74 lines (65 loc) · 1.91 KB
/
09-deploy-vcva.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
data "template_file" "deploy_vcva_script" {
template = file("templates/deploy_vcva.py")
vars = {
private_subnets = jsonencode(var.private_subnets)
vcenter_network = var.vcenter_portgroup_name
esx_passwords = jsonencode(packet_device.esxi_hosts.*.root_password)
dc_name = var.vcenter_datacenter_name
sso_password = random_string.sso_password.result
cluster_name = var.vcenter_cluster_name
}
}
data "template_file" "claim_vsan_disks" {
template = file("templates/vsan_claim.py")
vars = {
vcenter_fqdn = format("vcva.%s", var.domain_name)
vcenter_user = "[email protected]"
vcenter_pass = random_string.sso_password.result
}
}
resource "null_resource" "deploy_vcva" {
depends_on = [
null_resource.apply_esx_network_config,
null_resource.download_vcenter_iso
]
connection {
type = "ssh"
user = "root"
private_key = file("~/.ssh/${local.ssh_key_name}")
host = packet_device.router.access_public_ipv4
}
provisioner "file" {
content = data.template_file.claim_vsan_disks.rendered
destination = "/root/vsan_claim.py"
}
provisioner "file" {
content = data.template_file.deploy_vcva_script.rendered
destination = "/root/deploy_vcva.py"
}
provisioner "file" {
source = "templates/extend_datastore.sh"
destination = "/root/extend_datastore.sh"
}
provisioner "remote-exec" {
inline = [
"python3 /root/deploy_vcva.py",
"sleep 60",
]
}
}
resource "null_resource" "vsan_claim" {
depends_on = [null_resource.deploy_vcva]
count = var.esxi_host_count == 1 ? 0 : 1
connection {
type = "ssh"
user = "root"
private_key = file("~/.ssh/${local.ssh_key_name}")
host = packet_device.router.access_public_ipv4
}
provisioner "remote-exec" {
inline = [
"python3 /root/vsan_claim.py",
"sleep 90"
]
}
}