VMware Template playbook options

622 views
Skip to first unread message

Mark Matthews

unread,
Feb 16, 2016, 7:31:06 AM2/16/16
to Ansible Project
Hi 

I am setting up a new VMware virtual machine from a template using a Ansible playbook.

I want to be able to change the datastore and the network (vm_disk and vm_nic) of the VM during the setup of the VM. But when I add this information into the playbook (see below), nothing happens.
The new VM is created, but the datastore and network have not been adjust to what I requested in the playbook. They have remained the same as what the template image is.

Am I doing something incorrect in the playbook? Or is this not possible with Ansible?

Playbook (highlighted in bold is what is not being adjusted)

 ---

 - hosts: 127.0.0.1

   connection: local

   user: root

   sudo: false

   gather_facts: false

   serial: 1

   vars:

     vcenter_hostname: uk.company.local

     esxhost: 172.25.25.25

     name: TEST-SERVER01

     vmtemplate: winserver2012

     disktype: thin

     datastore: uk-datastore01

     nic_type: e1000e

     network: Web Servers

     network_type: standard

     vmcluster: UK-CLUSTER

     username: username

     password: password

     folder: Utilities

     notes: Created by Ansible

 

   tasks:

    - name: Create VM from template

      vsphere_guest:

        vcenter_hostname: "{{ vcenter_hostname }}"

        username: "{{ username }}"

        password: "{{ password }}"

        guest: "{{ name }}"

        vm_extra_config:

          notes: "{{ notes }}"

          folder: "{{ folder }}"

        from_template: yes

        template_src: "{{ vmtemplate }}"

        cluster: "{{ vmcluster }}"

        vm_disk:

          disk1:

            type: "{{ disktype }}"

            datastore: "{{ datastore }}"

        vm_nic:

          nic1:

            type: "{{ nic_type }}"

            network: "{{ network }}"

            network_type: "{{ network_type }}"

        resource_pool: "/Resources"

        

        esxi:

          datacenter: UK

          hostname: "{{ esxhost }}"



If I look at the example on the Ansible website, it doesn't look like it gives the option to allow this unless you setup a VM from an ISO file. (http://docs.ansible.com/ansible/vsphere_guest_module.html)
I ant to have the same functionality if I use a template.

Cheers
Mark 

Lim Kim Tee

unread,
Mar 24, 2016, 9:00:11 AM3/24/16
to Ansible Project
hi Mark,

I too also facing the same problem. I wanted to do the same.
By any chance you have figured it out?
Thanks. :)

Kevin Foster

unread,
Mar 28, 2016, 3:45:39 PM3/28/16
to Ansible Project
This would be a great feature.  We use templates that we get from customers with suites of software already installed so I can't build it from iso every time.

Radu Stefanache

unread,
Jun 20, 2016, 10:15:02 AM6/20/16
to Ansible Project
Hi Mark,

have you got any news on this one ?
I am currently trying to do the same thing and it does not work.
I've tried to clone the vm/template and reconfigure it while being powered off but that didn't help either.

Cheers
Radu

Dominik Bessler

unread,
Jun 20, 2016, 11:38:19 AM6/20/16
to ansible...@googlegroups.com
Try this one: https://github.com/whereismyjetpack/ansible_vcenter_module 
The Network Interface part works for me.

--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/11a7d853-6e8e-44b5-a3b3-10f88a3b7de3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages