community / community.vmware / 4.2.0 / module / vmware_tag_info Manage VMware tag info Authors: Abhijeet Kasurde (@Akasurde)community.vmware.vmware_tag_info (4.2.0) — module
Install with ansible-galaxy collection install community.vmware:==4.2.0
collections: - name: community.vmware version: 4.2.0
This module can be used to collect information about VMware tags.
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: Get info about tag community.vmware.vmware_tag_info: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' delegate_to: localhost
- name: Get category id from the given tag community.vmware.vmware_tag_info: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' delegate_to: localhost register: tag_details
- debug: msg: "{{ tag_details.tag_facts['fedora_machines']['tag_category_id'] }}"
- name: Gather tag id from the given tag community.vmware.vmware_tag_info: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" delegate_to: localhost register: tag_results
- set_fact: tag_id: "{{ item.tag_id }}" loop: "{{ tag_results.tag_info|json_query(query) }}" vars: query: "[?tag_name==`tag0001`]"
- debug: var=tag_id
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 E(VMWARE_PORT) will be used instead. type: int 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 E(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 E(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 E(VMWARE_USER) will be used instead. type: str proxy_host: description: - Address of a proxy that will receive all HTTPS requests and relay them. - The format is a hostname or a IP. - If the value is not specified in the task, the value of environment variable E(VMWARE_PROXY_HOST) will be used instead. required: false type: str proxy_port: description: - Port of the HTTP proxy that will receive all HTTPS requests and relay them. - If the value is not specified in the task, the value of environment variable E(VMWARE_PROXY_PORT) will be used instead. required: false type: int validate_certs: default: true description: - Allows connection when SSL certificates are not valid. - Set to V(false) when certificates are not trusted. - If the value is not specified in the task, the value of environment variable E(VMWARE_VALIDATE_CERTS) will be used instead. type: bool
tag_facts: description: dictionary of tag metadata returned: on success sample: Sample_Tag_0002: tag_category_id: urn:vmomi:InventoryServiceCategory:6de17f28-7694-43ec-a783-d09c141819ae:GLOBAL tag_description: Sample Description tag_id: urn:vmomi:InventoryServiceTag:a141f212-0f82-4f05-8eb3-c49647c904c5:GLOBAL tag_used_by: [] fedora_machines: tag_category_id: urn:vmomi:InventoryServiceCategory:baa90bae-951b-4e87-af8c-be681a1ba30c:GLOBAL tag_description: '' tag_id: urn:vmomi:InventoryServiceTag:7d27d182-3ecd-4200-9d72-410cc6398a8a:GLOBAL tag_used_by: [] ubuntu_machines: tag_category_id: urn:vmomi:InventoryServiceCategory:89573410-29b4-4cac-87a4-127c084f3d50:GLOBAL tag_description: '' tag_id: urn:vmomi:InventoryServiceTag:7f3516d5-a750-4cb9-8610-6747eb39965d:GLOBAL tag_used_by: [] type: dict tag_info: description: list of tag metadata returned: on success sample: - tag_category_id: urn:vmomi:InventoryServiceCategory:6de17f28-7694-43ec-a783-d09c141819ae:GLOBAL tag_description: Sample Description tag_id: urn:vmomi:InventoryServiceTag:a141f212-0f82-4f05-8eb3-c49647c904c5:GLOBAL tag_name: Sample_Tag_0002 tag_used_by: [] - tag_category_id: urn:vmomi:InventoryServiceCategory:6de17f28-7694-43ec-a783-d09c141819ae:GLOBAL tag_description: '' tag_id: urn:vmomi:InventoryServiceTag:7d27d182-3ecd-4200-9d72-410cc6398a8a:GLOBAL tag_name: Sample_Tag_0002 tag_used_by: [] - tag_category_id: urn:vmomi:InventoryServiceCategory:89573410-29b4-4cac-87a4-127c084f3d50:GLOBAL tag_description: '' tag_id: urn:vmomi:InventoryServiceTag:7f3516d5-a750-4cb9-8610-6747eb39965d:GLOBAL tag_name: ubuntu_machines tag_used_by: [] type: list