Playbook and role to deploy multiple vSphere virtual machines from a template using Ansible. For more information, you can refer to the related blog post.
- Python (≥ 2.6)
- Ansible
- PyVmomi
The required files are:
├── ansible.cfg
├── answerfile.yml
├── deploy-kubernetes-prod.yml
├── roles
│ └── deploy-vsphere-template
│ └── tasks
│ └── main.yml
└── vms-to-deploy
- Edit the
vms-to-deploy
file to define the number of virtual machines you want to deploy, as well as their names, datastore, IP and notes. - Edit the
answerfile.yml
file to set the correct parameter for- the infrastructure (where to deploy)
- the common options for the virtual machines
- (optional) Edit the role.
Note: Uncomment the
#resource_pool: '{{ deploy_vsphere_resourcepool }}'
line in theroles/deploy-vsphere-template/tasks/main.yml
file to deploy the virtual machines in a specific resource pool; don't forget to reflect your resource pool name in theanswerfile.yml
.
ansible-playbook -i vms-to-deploy deploy-kubernetes-prod.yml
Enjoy! :)