Returning Available Tags from An Instance


I’m trying our Morpheus variables and I would like to create a task type of (shell script) to return list of tags on a server or instance that has been deployed but it returns a null value in the output.


abcTag=“<%= server.tag%>”
fooTag=“<%= instance.tag%>”

echo $abcTag
echo $fooTag

The abcTag returns nothing when ran in server context type and fooTag returns null
then when ran in instance context type the abcTag return null while the fooTag returns the label manually typed into box instead of tags created via options or Tag policy that was created, unless I’m missing something.


Hello Manny,

Tags will not available for server context, for instance, please use “instance: <%= instance.metadata%>”


1 Like

When working with variables in Morpheus, you need to make sure you specify the variable name and path correctly. As easy way to check this is to use a Python script to dump all of the variables in the instance/server context, and then view the output to make sure you are calling the correct variable.

Create a Python task in Morpheus with the following content:

import json

You can then run this task on the instance and server. View the task output and you will be able to determine the correct variable name and path to reference.

It is useful to use a JSON formater to make the output easier to read. I did a quick test in my lab and set a tag called fooTag and label called mylabel during provisioning of an instance. I then ran the Python task above in the instance context and server context.
As the tag and label were applied during instance provisioning, you will see them in the instance context.
I searched through the variable output from the Pythion task and there are a few places where the tag and label are referenced: = fooTag
input.metadata.0.value = 1 = fooTag
instance.input.metadata.0.value = 1
instance.metadata.fooTag = 1
input.tags = mylabel
instance.input.tags = mylabel
instance.tags = mylabel
instance.metadata.Morpheus Labels = mylabel

So for bash you would need to use a variable as follows:

“<= instance.metadata.fooTag>”
“<= instance.tags>”


It’s important to note that Labels != Tags.