Centos – Changing the IP of a vSphere guest VM using Ansible

ansiblecentoscentos6vmware-vsphere

I want to deploy a VM from a template on vSphere and change the new instance IP via Ansible (2.x).
I've managed to clone the template with vsphere_guest module but I didn't find a way to change the IP of the new instance.
The new instance doesn't have an IP set from the start.
The final goal is to read static IP's from a config file and generate n new VM's each with an IP from the config file.
* VMware tools installed on the guest (CentOS 6.7)

Is this something that can be achieved using Ansible?

Thanks.

Best Answer

It seems you need a few different python/ansible scripts to achieve what you like:

  • Deploy your VM from a template
  • Get corresponding IP based on the VM name
  • Change IP by tuning CentOS network configuration files

You can have a look on this repo [github]. And this one for the IP change part.

Related Topic