-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvsphere_controllers.tf
83 lines (69 loc) · 2.78 KB
/
vsphere_controllers.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
77
78
79
80
81
82
83
data "vsphere_virtual_machine" "controller_template" {
name = var.controller["template"]
datacenter_id = data.vsphere_datacenter.dc.id
}
resource "vsphere_tag" "controller_name" {
count = var.pod_count
name = "controller.pod${count.index + 1}.lab"
category_id = vsphere_tag_category.name.id
}
resource "vsphere_tag" "controller_lab_name" {
count = var.pod_count
name = "controller.pod${count.index + 1}.lab"
category_id = vsphere_tag_category.lab_name.id
}
resource "vsphere_tag" "controller_lab_group" {
name = "controllers"
category_id = vsphere_tag_category.lab_group.id
}
resource "vsphere_virtual_machine" "controller" {
count = var.pod_count
name = "${var.id}_controller.pod${count.index + 1}.lab"
datastore_id = data.vsphere_datastore.datastore.id
resource_pool_id = vsphere_resource_pool.resource_pool.id
folder = vsphere_folder.folder.path
network_interface {
network_id = data.vsphere_network.network.id
}
num_cpus = var.controller["cpu"]
memory = var.controller["memory"]
wait_for_guest_net_timeout = var.wait_for_guest_net_timeout
guest_id = data.vsphere_virtual_machine.controller_template.guest_id
scsi_type = data.vsphere_virtual_machine.controller_template.scsi_type
scsi_bus_sharing = data.vsphere_virtual_machine.controller_template.scsi_bus_sharing
scsi_controller_count = data.vsphere_virtual_machine.controller_template.scsi_controller_scan_count
disk {
size = var.controller["disk"]
label = "${var.id}_controller.pod${count.index + 1}.${var.id}.lab_vmdk"
eagerly_scrub = data.vsphere_virtual_machine.controller_template.disks.0.eagerly_scrub
thin_provisioned = data.vsphere_virtual_machine.controller_template.disks.0.thin_provisioned
}
clone {
template_uuid = data.vsphere_virtual_machine.controller_template.id
}
tags = [
vsphere_tag.controller_name[count.index].id,
vsphere_tag.controller_lab_name[count.index].id,
vsphere_tag.controller_lab_group.id,
vsphere_tag.owner.id,
vsphere_tag.lab_id.id,
vsphere_tag.lab_timezone.id,
vsphere_tag.ansible_connection_local.id
]
vapp {
properties = {
# "mgmt-ip" = var.controller["mgmt_ip"]
# "mgmt-mask" = var.controller["mgmt_mask"]
# "default-gw" = var.controller["default_gw"]
sysadmin-public-key = tls_private_key.generated.public_key_openssh
}
}
connection {
host = vsphere_virtual_machine.jumpbox.default_ip_address
type = "ssh"
agent = false
user = "ubuntu"
private_key = tls_private_key.generated.private_key_pem
}
depends_on = [ vsphere_virtual_machine.jumpbox ]
}