Create vSphere VM from Template using Ansible

Ansible is the glue for VMware and DevOps, Many DevOps engineers use vRealize Automation to automate the Provisioning of VMs but there are a lot of chances that VMware isn’t the only infrastructure tool your company uses.

Ansible helps you to do provisioning on multiple clouds, in this blog I try to explain the creation of Virtual Machine from a template on VMware vCenter

Ansible provides various modules to manage the VMware Infrastructure, which included datacenter, cluster, host system and virtual machine.

As a pre-requisite we need to install pyVmomi, the VMware modules are written over the top of VMware VSphere API SDK for Python ( PyVmomi), You can install pyVmomi using pip

pip install pyvmomi

Ansible playbook are expressed in YAML format and have a minimum of syntax, which intentionally tires to not be a programming language or script but rather a model of a configuration or a process

Here is the PlayBook to create a VM from template

Create a file test.yml and paste the below code and change the details under the vmware guest

Run the above playbook by

ansible-playbook test.yml --connection=local

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from

Subscribe now to keep reading and get access to the full archive.

Continue reading