You need to create a customization_spec in the vCenter and then refer that using
customization_spec. <https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_guest_module.html#parameter-customization_spec> BTW, if you're on 7.0.3+, cloud-init will be the way forward. https://github.com/ansible-collections/community.vmware/pull/1574/ *Kosala* On Fri, Jun 2, 2023 at 2:00 AM Tony Wong <tdubb...@gmail.com> wrote: > I want to create vm in vsphere from template and customize OS with > customization spec > > I am not sure how to apply a customization spec in ansible. any idea? > > will something like this work > > --- > > - hosts: localhost > > gather_facts: true > > connection: local > > vars_files: > > - vcenter_creds.yml > > - vars.yml > > #no_log: True > > tasks: > > - name: Clone the VM template and customize > > vmware_guest: > > hostname: "{{ vcenter_hostname }}" > > username: "{{ vcenter_username }}" > > password: "{{ vcenter_password }}" > > validate_certs: False > > name: ansible-vm > > template: "{{ template_name }}" > > datacenter: "{{ datacenter_name }}" > > folder: "/{{ datacenter_name }}/vm/Ansible-test" > > cluster: "{{ cluster_name }}" > > datastore: "{{ datastore_name }}" > > networks: > > - name: VLAN-111 > > start_connected: yes > > ip: "{{ vm_ip }}" > > netmask: "{{ vm_netmask }}" > > gateway: "{{ vm_gateway }}" > > type: static > > dns_servers: "{{ vm_dns_servers }}" > > customization: > > hostname: "ansible-vm" > > dns_servers: "{{ vm_dns_servers }}" > > state: poweredon > > wait_for_ip_address: yes > > delegate_to: localhost > > > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/b4729a2b-c090-46a2-82a8-006a1410b264n%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/b4729a2b-c090-46a2-82a8-006a1410b264n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAP7S5HYoq-fUL%3D8pbefDNNpkJ4MrQyotXbRg6GNP9ajQu97HuA%40mail.gmail.com.