Install Packages after VM is created in VSphere

Hello All,

I am Creating VM in vCenter using community.vmware.vmware_guest, after the VM is Created I have certain prerequisites to be fulfilled:

  • Do Patching
  • Do some package installation.
  • And some more

How to accomplish this. I am able to create the VM then in the next task how to connect to VM and perform the above mentioned tasks.

Just In case in Terraform there is remote-exec and local-exec modules, after creation of VM in azure i can directly connect to VM using these and do whatever i need.

Can someone please provide the roadmap.

Thanks in advance,

Regards
Harsh

Hi Harsh,

I just finished something like this.
a Role with multiple tasks to install more 6 agents, make registry changes, add HDDs and format them, add more than one NIC and assign correct IP and a lot more…

I have another role to Patch the Template working on scheduling that Role/Playbook.

Warm Regards,
Abhi

Hello Abhijeet,

Thanks a lot for your information. Is there any way i can have a look on the roles you built or how you did it? It will be really helpful.
As i am clueless on how to achieve this. I am okay till VM creation, but how to connect to the VM on the next task and do activities i am bit confused on that.

Thanks,

Regards
Harsh

Hi Harsha,
I have used an input yaml file to give all the required variable values for the role to work.
used this module community.vmware.vmware_vm_shell: extensively to avoid opening fw ports.
As I am not connecting the VM over nw i dont need to add it in the inventory.
All required installers are part of the Template but even if they are not you can use this module community.vmware.vsphere_copy to copy files without nw.

I am doing this in vCenter so that was the difference against your use case for Azure.

What I do is we create the vm. I use there a custom role for.
Then we add that machine to the inventory. This action in in memory in a prestage group.
The prestage group in the inventory has the credential and info to connect.
And then we connect to that machine in the same playbook.

For a example see: create vm

Hello Abhijeet,

Thanks for the reply, will try that.

Thanks again

Hello Daeme,

Thats just great and what i needed. Just a small doubt, what if its a single click deployment process and i want everything to be done without manual intervention. Like create VM, Do patching and the install softwares.

But here you told “Then we add that machine to the inventory” is that step manual ? If yes how to make it automated.

Thanks a lot,

Regards
Harsh Chawda

Hello harsch,

that step is automatic zie line 14 in my example.

Create a vm and do action on it (github.com)

Hello Daeme,

Thanks a lot for your help…:blush::yellow_heart:

Regards
Harsh Chawda