{% raw %}The property definition for the SovLabs VM Tagging module to add a tag or tags to the VM is a JSON structure containing key/value pairs defining the following information about the tag:




cardinalitySingle (true or false)


category Description


   "name": "My Tag",
   "category":"My category",
   "tagDescription":"Some Description of my Tag", 
   "categoryDescription":"Category Description"


What if you want to use the SovLabs Template engine to set the values for these fields dynamically?

You can use the SovLabs Template engine to do this:

The VM Tagging integration runs each value through the Template Engine individually.  So to “templatize” the fields for the Tag Name, Category, cardinality, etc, you write your template like this:



  "name":"{% some templated stuff %}",  
  "category":"{% more templated stuff %}maybe some literal stuff",   
  "cardinalitySingle":"{% templated cardinality stuff %}"



{ % if some_value = "something" %}
    {"name","Tag1","category","some category"}
{% elseif  some_property == "something else" %}
   {"name": "Tag2", "category":"some category2"}
{% endif %}


Even though this comes out of Template Tester with valid JSON, the VMTagging workflow does not pass the entire code block through the Template Renderer in one chunk, so using this as your SovLabs_CreateTag_VMW_ property definition value would result in an error:


Error in (Workflow:VM Tagging machineProvisioned / Normailze Tags (item9)#10) Unable to parse tag property SovLabs_CreateTags_VMW_test :SyntaxError: Unexpected token in object literal {% endraw %}

Recommended Reading