Deploy VMware VM Template and run script locally on VM

I was able to deploy VMs from a template and they get renamed but the hostname doesn’t actually get updated. I am still trying to figure out how to do that but I have a bash script that I run on the VM, SUSE 15 Linux server, which joins to a domain and adds to SUSE Manager. For the life of me I cannot figure out what I need to add to my Ansible playbook so when these VMs get deployed from the template the hostname gets updated with what I configured and that script gets run with the appropriate switches.

Any guidance or help would be appreciated.

Can you share the Ansible Script that you have, Are you using the customization parameter?

Also, have you tried using some sort of Pipeline where you can run a second Script using Ansible.builtin.hostname

i did something like that recently with Windows Server 2019.
Used module community.vmware.vmware_guest:
and under
customization:

hostname: ‘{{ vm.Name }}’

to run various commands and install agents i used
community.vmware.vmware_vm_shell:

In my case the agents were already on the template.
But there is another module which will help you copy files to VM without using network.
Hope that helps.

Abhi