forked from hashicorp-education/learn-terraform-vsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
64 lines (50 loc) · 1.43 KB
/
main.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
provider "vsphere" {
vsphere_server = var.vsphere_server
user = var.vsphere_user
password = var.vsphere_password
# If you have a self-signed cert
allow_unverified_ssl = true
}
data "vsphere_datacenter" "dc" {
name = var.datacenter
}
data "vsphere_compute_cluster" "cluster" {
name = var.cluster
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_datastore" "datastore" {
name = var.datastore
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_network" "network" {
name = var.network_name
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_virtual_machine" "ubuntu" {
name = "/${var.datacenter}/vm/${var.ubuntu_name}"
datacenter_id = data.vsphere_datacenter.dc.id
}
resource "vsphere_virtual_machine" "learn" {
name = "learn-terraform"
resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
datastore_id = data.vsphere_datastore.datastore.id
num_cpus = 2
memory = 1024
network_interface {
network_id = data.vsphere_network.network.id
}
wait_for_guest_net_timeout = -1
wait_for_guest_ip_timeout = -1
disk {
label = "disk0"
thin_provisioned = true
size = 32
}
guest_id = "ubuntu64Guest"
clone {
template_uuid = data.vsphere_virtual_machine.ubuntu.id
}
}
output "vm_ip" {
value = vsphere_virtual_machine.learn.guest_ip_addresses
}