65 lines
1.5 KiB
HCL
65 lines
1.5 KiB
HCL
resource "vsphere_virtual_machine" "test-starrocks-fe-vm" {
|
|
name = "test-starrocks-fe"
|
|
resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
|
|
datastore_id = data.vsphere_datastore.datastore.id
|
|
num_cpus = 2
|
|
memory = 4096
|
|
guest_id = "ubuntu64Guest"
|
|
network_interface {
|
|
network_id = "${data.vsphere_network.network.id}"
|
|
adapter_type = "${data.vsphere_virtual_machine.template.network_interface_types[0]}"
|
|
}
|
|
|
|
clone {
|
|
template_uuid = data.vsphere_virtual_machine.template.id
|
|
}
|
|
|
|
cdrom {
|
|
client_device = true
|
|
}
|
|
|
|
vapp {
|
|
properties = {
|
|
"user-data" = base64encode(templatefile("${path.module}/cloud-init.tpl", {
|
|
ip_addr = "192.168.61.170"
|
|
gateway = "192.168.61.1"
|
|
dns1 = "192.168.61.1"
|
|
dns2 = "114.114.114.114"
|
|
hostname = "test-starrocks-fe"
|
|
ssh_key = var.ssh_key
|
|
}))
|
|
}
|
|
}
|
|
connection {
|
|
type = "ssh"
|
|
user = "ubuntu"
|
|
private_key = var.ssh_private_key_content
|
|
host = "192.168.61.170"
|
|
timeout = "2m"
|
|
}
|
|
|
|
|
|
provisioner "file" {
|
|
source = "${path.module}/scripts/setup.sh"
|
|
destination = "/home/ubuntu/setup.sh"
|
|
}
|
|
|
|
|
|
#在虚拟机里面运行脚本
|
|
provisioner "remote-exec" {
|
|
inline = [
|
|
"sudo chmod +x /home/ubuntu/setup.sh",
|
|
"sudo bash /home/ubuntu/setup.sh",
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
disk {
|
|
label = "disk0"
|
|
size = 50
|
|
}
|
|
} |