Repository: ansible-collections/community.vmware

Issue:
vmware_tag_manager: allow tags to datastore clusters
##### SUMMARY
vmware_tag_manager: allow tags to be applied to datastore clusters much like they can to switches, vms, etc.

##### ISSUE TYPE
- Feature Idea

##### COMPONENT NAME
vmware_tag_manager

##### ADDITIONAL INFORMATION
As a VI Admin, it is common to need to apply tags to all items in VMware in order to track information about those items.  Additionally, in the instance of datastore clusters, these are often used to create storage policies within the environment.

```yaml
- name: "apply tags to datastore cluster"
  vmware_tag_manager:
    hostname:        "{{ vcenter_server }}"
    username:        "{{ vcenter_username }}"
    password:        "{{ vcenter_password }}"
    validate_certs:  false
    tag_names:       ["Storage:gold"]
    object_name:     "High-Performance-Datastore-Cluster"
    object_type:     "DatastoreCluster"
    state:           "present"
```




Discussion:

Resolving patch:
diff --git a/plugins/modules/vmware_tag_manager.py b/plugins/modules/vmware_tag_manager.py
--- a/plugins/modules/vmware_tag_manager.py
+++ b/plugins/modules/vmware_tag_manager.py
@@ -47,7 +47,7 @@
       description:
       - Type of object to work with.
       required: True
-      choices: [ VirtualMachine, Datacenter, ClusterComputeResource, HostSystem, DistributedVirtualSwitch, DistributedVirtualPortgroup ]
+      choices: [ VirtualMachine, Datacenter, ClusterComputeResource, HostSystem, DistributedVirtualSwitch, DistributedVirtualPortgroup, Datastore, DatastoreCluster, ResourcePool, Folder ]
       type: str
     object_name:
       description:
@@ -175,12 +175,25 @@ def __init__(self, module):
         if self.object_type == 'VirtualMachine':
             self.managed_object = self.pyv.get_vm_or_template(self.object_name)
 
+        if self.object_type == 'Folder':
+            self.managed_object = self.pyv.find_folder_by_name(self.object_name)
+
         if self.object_type == 'Datacenter':
             self.managed_object = self.pyv.find_datacenter_by_name(self.object_name)
 
+        if self.object_type == 'Datastore':
+            self.managed_object = self.pyv.find_datastore_by_name(self.object_name)
+
+        if self.object_type == 'DatastoreCluster':
+            self.managed_object = self.pyv.find_datastore_cluster_by_name(self.object_name)
+            self.object_type = 'StoragePod'
+
         if self.object_type == 'ClusterComputeResource':
             self.managed_object = self.pyv.find_cluster_by_name(self.object_name)
 
+        if self.object_type == 'ResourcePool':
+            self.managed_object = self.pyv.find_resource_pool_by_name(self.object_name)
+
         if self.object_type == 'HostSystem':
             self.managed_object = self.pyv.find_hostsystem_by_name(self.object_name)
 
@@ -302,7 +315,8 @@ def main():
         object_name=dict(type='str', required=True),
         object_type=dict(type='str', required=True, choices=['VirtualMachine', 'Datacenter', 'ClusterComputeResource',
                                                              'HostSystem', 'DistributedVirtualSwitch',
-                                                             'DistributedVirtualPortgroup']),
+                                                             'DistributedVirtualPortgroup', 'Datastore', 'ResourcePool',
+                                                             'Folder', 'DatastoreCluster']),
     )
     module = AnsibleModule(argument_spec=argument_spec)
 


Test patch: