Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

cloud/vmware_guest.py

ANSIBLE VERSION

ansible 2.3.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansible/infra/library', u'/usr/lib/python2.7/site-packages/ara/plugins/modules']
python version = 2.7.5 (default, Sep 15 2016, 22:37:39) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

CONFIGURATION

N.A.

OS / ENVIRONMENT

Red Hat Enterprise Linux 7.3

VMware Vsphere 6.0

SUMMARY

When you try to create a 2-disks vm with each disk on a different datastore, both are created on the datastore specified as the first one.

STEPS TO REPRODUCE

Create a playbook with the below example and specify 2 different datastores as the datastore and the disk2_datastore variables.

- name: Create VM from template
vmware_guest:
name: "{{ inventory_hostname }}"

hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: False

esxi_hostname: "{{ esxhost }}"
datacenter: "{{ datacenter }}"

template: '{{ os_family}}{{ os_vers }}{{os_arch}}-template'
folder: "{{ folder | default('/vm') }}"

hardware:
num_cpus: "{{ vm_cpus }}"
memory_mb: "{{ vm_memory * 1024 | default(1024) }}"

disk:
- size_gb: "{{ disk_size | default(10) }}"
type: thin
datastore: "{{ datastore }}"
autoselect_datastore: False
- size_gb: "{{ disk2_size | default(10) }}"
type: thin
datastore: "{{ disk2_datastore }}"
autoselect_datastore: False

networks:
- name: "{{ vlan }}"
ip: "{{ primary_ip }}"
netmask: "{{ netmask }}"
gateway: "{{ gateway }}"
- name: "{{ nic2_vlan }}"
ip: "{{ nic2_ip }}"
netmask: "{{ nic2_netmask }}"

customization:
domain: "{{ domain }}"
dns_servers: "{{ dns_servers }}"

annotation: "Created with Ansible"
wait_for_ip_address: true

register: newvm
delegate_to: localhost

EXPECTED RESULTS

The new vm is created with the each disk on the his own datastore

ACTUAL RESULTS

The new vm is created with the both disks on the same datastore

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

vmware_guest

ANSIBLE VERSION

ansible 2.4.0
config file = /opt/it-infra/ansible.cfg
configured module search path = [u'/opt/it-infra/library']
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

OS / ENVIRONMENT

VMware Vsphere 6.5 Cluster

Deploy Windows Server 2016 Template with additional disks,...

SUMMARY

When a VM gets created from an Template and new Disks getting added on different Datastore

it place the new disks on the Same Datastore, and not on the defined

Tryed it with 2.3 and latest devel

STEPS TO REPRODUCE

- name: "Test Vsphere"
hosts: fj-v-file1
gather_facts: false
vars:
vsphere_cluster: "{{vsphere_default_cluster}}"
vsphere_datacenter: "{{vsphere_default_datacenter}}"
vsphere_user: "{{vsphere_vmc1_user}}"
vsphere_pw: "{{vsphere_vmc1_password}}"
vsphere_host: "{{vsphere_default_vcenter}}"
VMConfiguration:
name: fj-v-file1
primary_esxhost: "fj-p-vmnode1.vsphere.local"
annotation: "Fileserver for Management and Research"
template: "server2016core-v1"
disk:
# OS Disk
- size_gb: 146
type: thin
datastore: "ds-lun-11-sys1"
autoselect_datastore: false

# Verwaltung/LMTZ File Share = 1000GB * 1,07
- size_gb: 1070
type: thin
datastore: "ds-lun-25-vwfs"
autoselect_datastore: false

# BLT File Shares = 2000GB * 1,07
- size_gb: 2140
type: thin
datastore: "ds-lun-25-vwfs"
autoselect_datastore: false

# JR File Shares = 2000GB * 1,07
- size_gb: 2140
type: thin
datastore: "ds-lun-25-vwfs"
autoselect_datastore: false

hardware:
memory_mb: 4096
networks:
- name: "23-VWResource"
mac: "00:50:56:8E:35:97"

tasks:
- name: "Create VM"
tags: vsphere
delegate_to: 127.0.0.1
vmware_guest:
name: "{{VMConfiguration.name}}"
annotation: "{{VMConfiguration.annotation}}"
hostname: "{{vsphere_host}}"
cluster: "{{vsphere_cluster}}"
datacenter: "{{vsphere_datacenter}}"
template: "{{VMConfiguration.template}}"
username: "{{vsphere_user}}"
password: "{{vsphere_pw}}"
wait_for_ip_address: no
validate_certs: False
state: present
customization:
password: "nothing"
disk: "{{VMConfiguration.disk}}"
hardware: "{{VMConfiguration.hardware}}"

EXPECTED RESULTS

VM gets Created with Disks on the defined datastore

ACTUAL RESULTS

All Disks getting placed on the first datastore "ds-lun-11-sys1"

Looks like it ignore the defined Datastore

Datastore is there (See it in vsphere client and on the Host where the vm gets placed)

changed: [fj-v-file1 -> 127.0.0.1] => {
"changed": true,
"failed": false,
"instance": {
"annotation": "Fileserver for Management and Research",
"current_snapshot": null,
"customvalues": {},
"guest_tools_status": "guestToolsNotRunning",
"guest_tools_version": "10272",
"hw_guest_full_name": null,
"hw_guest_id": null,
"hw_interfaces": [],
"hw_memtotal_mb": 4096,
"hw_name": "fj-v-file1",
"hw_power_status": "poweredOff",
"hw_processor_count": 2,
"hw_product_uuid": "420ede86-9d81-067f-f0a6-3c57d48938a4",
"ipv4": null,
"ipv6": null,
"module_hw": true,
"snapshots": []
},
"invocation": {
"module_args": {
"annotation": "Fileserver for Management and Research",
"cluster": "vmc1",
"customization": {
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
},
"customvalues": [],
"datacenter": "FJ",
"disk": [
{
"autoselect_datastore": false,
"datastore": "ds-lun-11-sys1",
"size_gb": 146,
"type": "thin"
},
{
"autoselect_datastore": false,
"datastore": "ds-lun-25-vwfs",
"size_gb": 1070,
"type": "thin"
},
{
"autoselect_datastore": false,
"datastore": "ds-lun-25-vwfs",
"size_gb": 2140,
"type": "thin"
},
{
"autoselect_datastore": false,
"datastore": "ds-lun-25-vwfs",
"size_gb": 2140,
"type": "thin"
}
],
"esxi_hostname": null,
"folder": "/vm",
"force": false,
"guest_id": null,
"hardware": {
"memory_mb": 4096
},
"hostname": "172.16.125.200",
"is_template": false,
"linked_clone": false,
"name": "fj-v-file1",
"name_match": "first",
"networks": [],
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"resource_pool": null,
"snapshot_src": null,
"state": "present",
"template": "server2016core-v1",
"template_src": "server2016core-v1",
"username": "ansible@vsphere.local",
"uuid": null,
"validate_certs": false,
"wait_for_ip_address": false
}
}
}