Deploy VMware VM Template and run script locally on VM

110 views
Skip to first unread message

Brian Watters

unread,
Jun 29, 2022, 3:13:06 PM6/29/22
to Ansible Project
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.

david...@mycit.ie

unread,
Jun 29, 2022, 3:54:39 PM6/29/22
to Ansible Project
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

Abhijeet Janwalkar

unread,
Jun 30, 2022, 3:54:04 AM6/30/22
to ansible...@googlegroups.com
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
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d2025661-3e06-4fc8-91ad-cd173b76b85fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages