Install Packages after VM is created in VSphere

66 views
Skip to first unread message

harshc...@gmail.com

unread,
Jul 8, 2022, 7:31:24 AM7/8/22
to Ansible Project

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

Abhijeet Janwalkar

unread,
Jul 10, 2022, 9:39:28 AM7/10/22
to ansible...@googlegroups.com
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

--
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/72e29365-729e-4472-9f79-5a798ada0837n%40googlegroups.com.

harshc...@gmail.com

unread,
Jul 11, 2022, 12:01:50 AM7/11/22
to Ansible Project
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

Abhijeet Janwalkar

unread,
Jul 11, 2022, 4:35:56 AM7/11/22
to ansible...@googlegroups.com
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.

daeme...@gmail.com

unread,
Jul 12, 2022, 2:19:29 PM7/12/22
to Ansible Project
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


Op maandag 11 juli 2022 om 10:35:56 UTC+2 schreef abhijeet....@gmail.com:

harshc...@gmail.com

unread,
Jul 13, 2022, 12:59:13 AM7/13/22
to Ansible Project
Hello Abhijeet,

Thanks for the reply, will try that.

Thanks again

harshc...@gmail.com

unread,
Jul 13, 2022, 1:03:21 AM7/13/22
to Ansible Project
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

Seth Daemen

unread,
Jul 15, 2022, 3:52:05 PM7/15/22
to ansible...@googlegroups.com
Hello harsch,

that step is automatic zie line 14 in my example.


Op wo 13 jul. 2022 om 07:03 schreef harshc...@gmail.com <harshc...@gmail.com>:
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/QaWKNsqj11k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0838075d-7dcd-4261-9892-d003c45d138cn%40googlegroups.com.

harsh chawda

unread,
Jul 15, 2022, 11:58:38 PM7/15/22
to ansible...@googlegroups.com
Hello Daeme,

Thanks a lot for your help...😊💛

Regards
Harsh Chawda

Reply all
Reply to author
Forward
0 new messages