Hi all,
I’m trying to set up a playbook that creates VMs on a vSphere server based on a template. I’ve created a playbook that uses the vmware_guest module, I’ve created a template in vSphere, and I’ve also created an OS customisation specification. The VM creation works but I can’t get the OS customisation to work. It’s not giving any errors, it’s just not doing the customisation. All I’m really wanting out of it is to change the hostname of the new VM to match the VM name. If I launch a VM from the template in the vSphere web client and specify my customisation template in the wizard it works, so I’m confident everything on the vSphere side is fine.
My environment is as follows
Target: vSphere 5.5u3
Template: CentOS 7 with open-vm-tools and perl installed
Control machine: MacOS 10.13.6
Ansible version: 2.6.3
Python version: 2.7.10
Here’s my playbook step:
`
- name: Create VM
vmware_guest:
hostname: “{{ vsphere_host }}”
username: “{{ vsphere_login }}”
password: “{{ vsphere_password }}”
esxi_hostname: “{{ esxi_host }}”
validate_certs: False
template: centos-basic-template
customization_spec: “Base Linux”
datacenter: dev
state: poweredon
wait_for_ip_address: yes
folder: /
name: “new-vm”
`
One thing I noticed in the verbose output of the ansible-playbook command was that it seems to think the VM is RHEL7 even though the template (and the newly created VM) show the OS as Centos:
"hw_guest_full_name": "Red Hat Enterprise Linux 7 (64-bit)", "hw_guest_ha_state": null, "hw_guest_id": "rhel7_64Guest",
I’ve tried using the customization parameter (just specifying hostname) instead of customization_spec but I get the error “Failed to create a virtual machine : fault.NicSettingMismatch.summary” if I do that. I haven’t gone down the troubleshooting path for that one yet as I’d much prefer to use the customisation spec defined in vSphere.
Am I missing something? Or is there a bug in the vmware_guest module?
Thanks in advance for any help,
Matt