create VM from template with customiation spec

21 views
Skip to first unread message

Tony Wong

unread,
Jun 1, 2023, 10:00:29 AM6/1/23
to Ansible Project
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

---

hostslocalhost

  gather_factstrue

  connectionlocal

  vars_files:

    - vcenter_creds.yml

    - vars.yml

  #no_log: True 

  tasks:

    - nameClone the VM template and customize

      vmware_guest:

        hostname"{{ vcenter_hostname }}"

        username"{{ vcenter_username }}"

        password"{{ vcenter_password }}"

        validate_certsFalse

        nameansible-vm

        template"{{ template_name }}"

        datacenter"{{ datacenter_name }}"

        folder"/{{ datacenter_name }}/vm/Ansible-test"

        cluster"{{ cluster_name }}"

        datastore"{{ datastore_name }}"

        networks:

          - nameVLAN-111

            start_connectedyes

            ip"{{ vm_ip }}"

            netmask"{{ vm_netmask }}"

            gateway"{{ vm_gateway }}"

            typestatic

            dns_servers"{{ vm_dns_servers }}"

        customization:

          hostname"ansible-vm"

          dns_servers"{{ vm_dns_servers }}"

        statepoweredon

        wait_for_ip_addressyes

      delegate_tolocalhost

 

Kosala Atapattu

unread,
Jun 1, 2023, 4:27:40 PM6/1/23
to ansible...@googlegroups.com
You need to create a customization_spec in the vCenter and then refer that using 

customization_spec.

 

BTW, if you're on 7.0.3+, cloud-init will be the way forward.



--
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-proje...@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.

Rowe, Walter P. (Fed)

unread,
Jun 2, 2023, 7:12:07 AM6/2/23
to ansible...@googlegroups.com
That pull request is still open.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

Reply all
Reply to author
Forward
0 new messages