-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm.tf
56 lines (51 loc) · 1.79 KB
/
vm.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
resource "vsphere_virtual_machine" "vm" {
name = count.index > 0 ? "${var.vsphere_vm_name}-${count.index + 1}" : var.vsphere_vm_name
folder = var.vsphere_vm_folder_path
count = var.vm_count
resource_pool_id = data.vsphere_resource_pool.pool.id
datastore_id = data.vsphere_datastore.datastore.id
firmware = var.firmware
num_cpus = var.vm_num_cpus
memory = var.vm_memory
guest_id = data.vsphere_virtual_machine.template.guest_id
scsi_type = data.vsphere_virtual_machine.template.scsi_type
annotation = var.annotation
network_interface {
network_id = data.vsphere_network.network.id
adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
}
disk {
label = var.vm_disk_label
size = var.vm_disk_size
eagerly_scrub = data.vsphere_virtual_machine.template.disks[0].eagerly_scrub
thin_provisioned = data.vsphere_virtual_machine.template.disks[0].thin_provisioned
}
clone {
template_uuid = data.vsphere_virtual_machine.template.id
}
provisioner "remote-exec" {
connection {
type = "ssh"
host = self.default_ip_address
user = var.vm_ssh_user
password = var.vm_ssh_password
agent = var.ssh_agent
}
inline = var.bootstrap
}
provisioner "remote-exec" {
connection {
type = "ssh"
host = self.default_ip_address
user = var.vm_ssh_user
password = var.vm_ssh_password
agent = var.ssh_agent
}
inline = [
"sudo echo '${count.index > 0 ? "${var.vsphere_vm_name}-${count.index + 1}" : var.vsphere_vm_name}' | sudo tee /etc/hostname",
"sudo systemd-machine-id-setup",
"sudo reboot -f"
]
on_failure = continue
}
}