Ansible: Create a Tag in vCenter
Automating VMware using Ansible
In my previous article, I explained how to create a Tag Category in vCenter. Today I will explain how to create a tag in vCenter using the same category.
The community.vmware
Ansible collection provides a module called vmware_tag
to manage tags. With this module user can create, delete, and update the tags.
You can read more about the tag creation in the documentation.
Let us now, create a tag called backup_tag
with backup_category
as a tag category.
The playbook like this -
Once you run the playbook, you will presented with tag id and information about the state as follows —
TASK [Create a tag] ***************************************************************************
changed: [localhost] => {"changed": true, "tag_status": {"msg": "Tag 'backup_tag' created.", "tag_id": "urn:vmomi:InventoryServiceTag:3214373c-5fc3-4fc9-862d-87a1208d2c00:GLOBAL"}}
You can also use the vmware_tag
to update and delete the tag.
Conclusion —
In the next article we will discuss how to apply a tag to the given object.
Thanks for reading and happy automating.