From d91d1fb6506b2d928f20154e879518a5cd69df66 Mon Sep 17 00:00:00 2001 From: Rafael Laszlo <rlacko99@gmail.com> Date: Mon, 8 Nov 2021 18:57:47 +0100 Subject: [PATCH] Add simple example and vlan 51 --- terraform/data.tf | 4 +++ terraform/example/simple-cloud-init.tf | 47 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 terraform/example/simple-cloud-init.tf diff --git a/terraform/data.tf b/terraform/data.tf index b7ac2b8..d2faa15 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 0000000..cd9b1a1 --- /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 + } +} -- GitLab