Skip to main content

Chef Infra Language: Node Tags

A tag is a custom description that’s applied to a node. A tag, once applied, can be helpful when managing nodes using knife or when building recipes by providing alternate methods of grouping similar types of information.

You can add tags, remove tags, and check if nodes have a specific tag.

To add a tag in your recipe, use tag with the tag name you want to apply to a node.


To test if a machine is tagged with a specific tag, use tagged? with the tag name.


This will return true or false.

tagged? also accepts an array as an argument.

Remove a tag using untag.


For example:


if tagged?('test_node')"Hey I'm #{node['tags']}")


unless tagged?('test_node')'I am not tagged')

Will return something like this:

[Thu, 22 Jul 2010 18:01:45 +0000] INFO: Hey I'm test_node
[Thu, 22 Jul 2010 18:01:45 +0000] INFO: I am not tagged
Edit this page on GitHub

Thank you for your feedback!


Search Results