VMware OVA deployment using ansible


To deploy OVA on VMware platform using ansible a provision server is required from where ansible playbooks need to be executed. Follow the steps as mentioned in how to build ansible provision server for VMware and make the provision server ready.

With the help of vmware_deploy_ovf module ansible can deploy VMware OVA. Let say the requirement is to deploy the OVA in a vm folder and under a resource pool in hosts view, then it should go through the following check points:

  • Create vm folder and resource pool if not present
  • OVA should be available in the provision server
Before deploying the OVA, extract the OVA and check the custom section of .ovf file to see what all variable need to pass in the playbook at the time of deployment.

We will create three yml files to keep:

  • vmware ova deployment code (vsphere_ova_deploy.yml)
  • vmware environment login details (vsphere_creds.yml)
  • variables used for the guest deployment (vsphere_var.yml)


In my example, I have to pass the following variables as a requirement by my OVA. But it will change from ova to ova.


Content of vCenter credentials yml file 'vsphere_creds.yml':


Content of vCenter variable file 'vsphere_var.yml':


Content of vmware guest deployment yml file 'vsphere_ova_deploy.yml':



NOTE: Using 'properties' parameter we are passing the value to actual variable available in the OVA.


Its not a good practice to keep the vCenter credentials in plain text. So using ansible-vault encrypt the file:

# ansible-vault  encrypt  vsphere_creds.yml
   New Vault password: ******
   Confirm New Vault password: ******


Now deploy the vm using ansible playbook:

# ansible-playbook  --ask-vault-pass  vsphere_ova_deploy.yml
Vault password: ********


This should help to deploy a VM from OVA in the vCenter using playbook and also it will configure the network of the guest vm which can be used to access the vm post deployment.

Comments

Popular posts from this blog

VNC Configuration using Ansible in CentOS 7

How to build Ubuntu Server 20.04 LTS OVA with vAPP Properties ?

LVM Configuration using Ansible in CentOS 7