diff --git a/terraform/data.tf b/terraform/data.tf index b7ac2b8ff5ea427da0f7f703b30caa77efa0570c..d2faa1593549ae680da24af4fc676430132521fd 100644 --- a/terraform/data.tf +++ b/terraform/data.tf @@ -54,6 +54,10 @@ data "vsphere_datastore" "N4_SSD-01" { # * Network +data "vsphere_network" "dvPG-051-KSZK" { + name = "dvPG-051-KSZK" + datacenter_id = data.vsphere_datacenter.dc.id +} data "vsphere_network" "dvPG-151-Internal" { name = "dvPG-151-Internal" datacenter_id = data.vsphere_datacenter.dc.id diff --git a/terraform/example/simple-cloud-init.tf b/terraform/example/simple-cloud-init.tf new file mode 100644 index 0000000000000000000000000000000000000000..cd9b1a14dfdff0046a50f0dda1481679cf12d4d9 --- /dev/null +++ b/terraform/example/simple-cloud-init.tf @@ -0,0 +1,47 @@ +# This is a simple vm definition which uses cloud-init + +resource "vsphere_virtual_machine" "simple" { + name = "simple" + # Get your resource pool in the data.tf file + resource_pool_id = data.vsphere_resource_pool.simple.id + guest_id = "ubuntu64Guest" + num_cpus = 1 + memory = 1024 + firmware = "efi" + # Use the folder that you got access to + folder = "simple" + wait_for_guest_net_timeout = 0 # Don't wait for the network + wait_for_guest_ip_timeout = 0 # Don't wait for the network interface to get ip + sync_time_with_host = true + sync_time_with_host_periodically = false + + datastore_cluster_id = data.vsphere_datastore_cluster.SCH-Cluster-FujiStorage.id + + # Clone the existing cloudinit template vm + clone { + template_uuid = data.vsphere_virtual_machine.ubuntu2004-cloud-init.id + } + vapp { + properties = { + public-keys = null + hostname = "alma" # Hostname for the vm + instance-id = "alma" # Instance id for the vm, should be unique, so use the hostname + password = "Password" + user-data = null # Cloudinit configuration in base64. You can do something like base64encode(file(filepath)) + } + } + + network_interface { + network_id = data.vsphere_network.dvPG-051-KSZK.id + use_static_mac = false + } + + disk { + size = 16 + thin_provisioned = false + } + + cdrom { + client_device = true # CDRom should be mounted when using cloud-init + } +}