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.

On Tuesday, February 16, 2016 at 6:31:06 AM UTC-6, Mark Matthews wrote:
>
> 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 
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ab16f571-ab3d-4eac-ab4d-5bba9eb938cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to