In many vmware_* modules, the datacenter parameter is marked as required - but is it really needed?
I ask because I’ve written a module, based on vmware_guest_find, that returns the Datacenter for a given VM and VCenter, which I can then feed in to the other “official” modules. My module uses the built-in function “get_parent_datacenter” (defined in https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/vmware.py) so I’m not inventing anything particularly new. My point is that if I, an amateur Python coder at best, can do this, why can’t the official modules do it by default? Is there some reason for the current behaviour that I am missing?
I’m not really confident (yet) in editing the official modules and submitting Pull Requests etc. but am happy to share my code with someone who can do this.
That’s not a datacenter issue - you can have two VMs with the same name in the same datacenter but VMWare does not recommend this - https://kb.vmware.com/s/article/2108769
That's not a datacenter issue - you can have two VMs with the same name in
the same datacenter but VMWare does not recommend this - https://kb.vmware.com/s/article/2108769
I would say it is.
A datacenter is a namespace that makes it possible to have the same name for VMs, templates, hosts, clusters, networks and datastores across datacenters. But must of them need to be uniq within the datacenter.
If no datacenter is set, the default is ‘ha-datacenter’, not ‘all the DC’
as the users may expect. So unless you are aware of that, the playbook will
access the wrong datacenter. This was source of confusion for the users.