VMware guest deployment using Ansible
To deploy VMware guest 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.
We will create three yml files to keep:
- vmware guest deployment code (vsphere_guest_deploy.yml)
- vmware environment login details (vsphere_creds.yml)
- variables used for the guest deployment (vsphere_var.yml)
This vsphere_guest_deploy.yml playbook will perform the following tasks:
- Make sure to have a template in the vCenter Server
- VM need to be deployed in a dedicated vm folder and resource pool
- VM folder and resource pool will be created if not available
For this deployment an application user is needed in vCenter which should have required privilege to perform all the above tasks.
Content of vCenter credentials yml file:
Content of vCenter variable file:
Content of vmware guest deployment yml:
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_guest_deploy.yml
Vault password: ********
This should help to deploy a VM in the vCenter using the template mentioned in the playbook and also it will configure the network of the guest vm which can be used to access the vm post deployment.
Comments
Post a Comment