You want to have a fresh copy instead of a template clone? Here you go
Set some variables
set GOVC_INSECURE=true
set [email protected]
set GOVC_PASSWORD=youguess
set GOVC_DATASTORE=mydatastore
set GOVC_RESOURCE_POOL=myresourcepool
set GOVC_FOLDER=myvmfolder
set CNNAME=myvm
Create the VM. This assumes the iso "ubuntu-20.04.2-live-server-amd64.iso" in folder "Ubuntu" in datastore "ISO". It will connect to mynet, make sure you have dhcp
govc datastore.mkdir %CNNAME%
govc datastore.disk.create -d=thin -size 50G %CNNAME%/os.vmdk
govc vm.create -c=4 -m=8192 -disk=%CNNAME%/os.vmdk -dump=true -g="ubuntu64Guest" -iso-datastore=ISO -iso=Ubuntu/ubuntu-20.04.2-live-server-amd64.iso -on=false -link=true -net="mynet" -net.adapter=vmxnet3 %CNNAME%
Keystroke magic. Notice windows timeout sucks so ping acts as a sleeper here. http://myurl/mydir/user-data is your config file http://myurl/mydir/meta-data can be just blank file but has to exists
govc vm.power -off %CNNAME%
govc vm.power -on %CNNAME%
ping 127.0.0.1 -n 3 > nul
govc vm.keystrokes -vm %CNNAME% -c KEY_ESC
ping 127.0.0.1 -n 2 > nul
govc vm.keystrokes -vm %CNNAME% -c KEY_ESC
ping 127.0.0.1 -n 2 > nul
govc vm.keystrokes -vm %CNNAME% -c KEY_F6
ping 127.0.0.1 -n 2 > nul
govc vm.keystrokes -vm %CNNAME% -c KEY_ESC
ping 127.0.0.1 -n 2 > nul
govc vm.keystrokes -vm %CNNAME% -s " autoinstall ds=nocloud-net;s=http://myurl/mydir"
govc vm.keystrokes -vm %CNNAME% -c KEY_ENTER