Created
July 21, 2021 15:54
-
-
Save jonchen727/e142ef6b254b14004c01a471e037cd70 to your computer and use it in GitHub Desktop.
vsphere ubuntu example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_resource_pool" "pool" { | |
name = var.resourcepool | |
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.ubuntu_name | |
datacenter_id = data.vsphere_datacenter.dc.id | |
} | |
resource "vsphere_virtual_machine" "k8Master1-0" { | |
name = "k8Master1-0" | |
resource_pool_id = data.vsphere_resource_pool.pool.id | |
datastore_id = data.vsphere_datastore.datastore.id | |
network_interface { | |
network_id = data.vsphere_network.network.id | |
adapter_type = "vmxnet3" | |
} | |
num_cpus = 4 | |
memory = 4128 | |
wait_for_guest_net_timeout = 0 | |
wait_for_guest_ip_timeout = 0 | |
disk { | |
label = "disk0" | |
thin_provisioned = true | |
size = 16 | |
} | |
guest_id = "ubuntu64Guest" | |
clone { | |
template_uuid = data.vsphere_virtual_machine.ubuntu.id | |
customize { | |
network_interface { | |
ipv4_address = "192.168.0.208" | |
ipv4_netmask = 24 | |
} | |
ipv4_gateway = "192.168.0.1" | |
linux_options { | |
host_name = "k8Master1-0" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment