community / community.vmware / 0.4.0 / module / vmware_tag_manager Manage association of VMware tags with VMware objects Authors: Abhijeet Kasurde (@Akasurde), Frederic Van Reet (@GBrawl) preview | supported by communitycommunity.vmware.vmware_tag_manager (0.4.0) — module
Install with ansible-galaxy collection install community.vmware:==0.4.0
collections: - name: community.vmware version: 0.4.0
This module can be used to assign / remove VMware tags from the given VMware objects.
Tag feature is introduced in vSphere 6 version, so this module is not supported in the earlier versions of vSphere.
All variables and VMware object names are case sensitive.
- name: Add tags to a virtual machine vmware_tag_manager: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' validate_certs: no tag_names: - Sample_Tag_0002 - Category_0001:Sample_Tag_0003 object_name: Fedora_VM object_type: VirtualMachine state: add delegate_to: localhost
- name: Specify tag and category as dict vmware_tag_manager: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' validate_certs: no tag_names: - tag: tag_0001 category: cat_0001 - tag: tag_0002 category: cat_0002 object_name: Fedora_VM object_type: VirtualMachine state: add delegate_to: localhost
- name: Remove a tag from a virtual machine vmware_tag_manager: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' validate_certs: no tag_names: - Sample_Tag_0002 object_name: Fedora_VM object_type: VirtualMachine state: remove delegate_to: localhost
- name: Add tags to a distributed virtual switch vmware_tag_manager: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' validate_certs: no tag_names: - Sample_Tag_0003 object_name: Switch_0001 object_type: DistributedVirtualSwitch state: add delegate_to: localhost
- name: Add tags to a distributed virtual portgroup vmware_tag_manager: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' validate_certs: no tag_names: - Sample_Tag_0004 object_name: Switch_0001:Portgroup_0001 object_type: DistributedVirtualPortgroup state: add delegate_to: localhost
port: default: 443 description: - The port number of the vSphere vCenter. - If the value is not specified in the task, the value of environment variable C(VMWARE_PORT) will be used instead. type: int state: choices: - present - absent - add - remove - set default: add description: - If C(state) is set to C(add) or C(present) will add the tags to the existing tag list of the given object. - If C(state) is set to C(remove) or C(absent) will remove the tags from the existing tag list of the given object. - If C(state) is set to C(set) will replace the tags of the given objects with the user defined list of tags. type: str hostname: description: - The hostname or IP address of the vSphere vCenter server. - If the value is not specified in the task, the value of environment variable C(VMWARE_HOST) will be used instead. type: str password: aliases: - pass - pwd description: - The password of the vSphere vCenter server. - If the value is not specified in the task, the value of environment variable C(VMWARE_PASSWORD) will be used instead. type: str protocol: choices: - http - https default: https description: - The connection to protocol. type: str username: aliases: - admin - user description: - The username of the vSphere vCenter server. - If the value is not specified in the task, the value of environment variable C(VMWARE_USER) will be used instead. type: str tag_names: description: - List of tag(s) to be managed. - User can also specify category name by specifying colon separated value. For example, "category_name:tag_name". - User can also specify tag and category as dict, when tag or category contains colon. See example for more information. Added in version 2.10. - User can skip category name if you have unique tag names. required: true type: list object_name: description: - Name of the object to work with. - For DistributedVirtualPortgroups the format should be "switch_name:portgroup_name" required: true type: str object_type: choices: - VirtualMachine - Datacenter - ClusterComputeResource - HostSystem - DistributedVirtualSwitch - DistributedVirtualPortgroup description: - Type of object to work with. required: true type: str validate_certs: default: true description: - Allows connection when SSL certificates are not valid. - Set to C(no) when certificates are not trusted. - If the value is not specified in the task, the value of environment variable C(VMWARE_VALIDATE_CERTS) will be used instead. type: bool
tag_status: description: metadata about tags related to object configuration returned: on success sample: current_tags: - backup - security desired_tags: - security previous_tags: - backup - security type: list