diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 9e669761385..5db9a29c235 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -395,7 +395,7 @@ EXAMPLES = r''' delegate_to: localhost register: deploy -- name: Clone a virtual machine from Template and customize +- name: Clone a virtual machine from Windows template and customize vmware_guest: hostname: "{{ vcenter_ip }}" username: "{{ vcenter_username }}" @@ -428,6 +428,32 @@ EXAMPLES = r''' - powershell.exe -ExecutionPolicy Unrestricted -File C:\Windows\Temp\ConfigureRemotingForAnsible.ps1 -ForceNewSSLCert -EnableCredSSP delegate_to: localhost +- name: Clone a virtual machine from Linux template and customize + vmware_guest: + hostname: "{{ vcenter_server }}" + username: "{{ vcenter_user }}" + password: "{{ vcenter_password }}" + validate_certs: no + datacenter: "{{ datacenter }}" + state: present + folder: /DC1/vm + template: "{{ template }}" + name: "{{ vm_name }}" + cluster: DC1_C1 + networks: + - name: VM Network + ip: 192.168.10.11 + netmask: 255.255.255.0 + wait_for_ip_address: True + customization: + domain: "{{ guest_domain }}" + dns_servers: + - 8.9.9.9 + - 7.8.8.9 + dns_suffix: + - example.com + - example2.com + - name: Rename a virtual machine (requires the virtual machine's uuid) vmware_guest: hostname: "{{ vcenter_ip }}" @@ -1420,7 +1446,11 @@ class PyVmomiHelper(PyVmomi): # TODO: Maybe list the different domains from the interfaces here by default ? if 'dns_suffix' in self.params['customization']: - globalip.dnsSuffixList = self.params['customization']['dns_suffix'] + dns_suffix = self.params['customization']['dns_suffix'] + if isinstance(dns_suffix, list): + globalip.dnsSuffixList = " ".join(dns_suffix) + else: + globalip.dnsSuffixList = dns_suffix elif 'domain' in self.params['customization']: globalip.dnsSuffixList = self.params['customization']['domain']