ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
343 stars 336 forks source link

vmware_guest Create VM with Windows Template without parameter guest_id #719

Open SilentT19 opened 3 years ago

SilentT19 commented 3 years ago
SUMMARY

When create VM with Windows template with customisation and without guest_id, the module send linux customisation

ISSUE TYPE
COMPONENT NAME

vmware_guest

ANSIBLE VERSION
2.10.7
CONFIGURATION
Ubuntu 20.04 , pyvmomi 7.0.1
vCenter Server 6.5u3n 17590285 
OS / ENVIRONMENT

OS : Windows

STEPS TO REPRODUCE

Simply use vmware_guest with windows template with customization

 name:  Deploy VM
  community.vmware.vmware_guest:
....
    template: '{{ Windows_Template }}'
...
EXPECTED RESULTS

The VM was created with customisation and without error in vcenter

ACTUAL RESULTS
-->       customization = (vim.vm.customization.Specification) {
-->          options = (vim.vm.customization.Options) null,
-->          identity = (vim.vm.customization.LinuxPrep) {

image

ansibullbot commented 3 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 3 years ago

cc @Akasurde @Tomorrow9 @goneri @lparkes @nerzhul @pdellaert @pgbidkar @warthog9 click here for bot help

SilentT19 commented 3 years ago

https://github.com/ansible-collections/community.vmware/blob/f913056612c776b6527aa3c373fe7cb7358d2762/plugins/modules/vmware_guest.py#L2303

if win in guest_id but guest_id was not required if use template

https://docs.ansible.com/ansible/2.10/collections/community/vmware/vmware_guest_module.html#parameter-guest_id

"This field is required when creating a virtual machine, not required when creating from the template."

https://github.com/ansible-collections/community.vmware/blob/f913056612c776b6527aa3c373fe7cb7358d2762/plugins/modules/vmware_guest.py#L2299

vCenter inventory output the guestid ?

SilentT19 commented 3 years ago

Perhaps this problem https://github.com/ansible-collections/community.vmware/issues/75 is related too

Akasurde commented 3 years ago

@SilentT19 Thanks for reporting this issue. GuestID information is gathered using VMware Tools installed inside the VM. If VMware tools fail to detect or wrongly report the guest id then the module would misbehave. I am afraid that there is no other way to detect guest id.

Please try updating vmware tools in Guest OS.

SilentT19 commented 3 years ago

I think that when we prepare and use a template, the guestOS is registered in the configuration of the template and it is cloned with the VM, Liked this image I think that we should use this parameter instead of that of the tools.