diff --git a/content/reusable/md/chef_tags.md b/content/reusable/md/chef_tags.md index 1f9d83de43..7e93a43e90 100644 --- a/content/reusable/md/chef_tags.md +++ b/content/reusable/md/chef_tags.md @@ -1,4 +1,2 @@ -A tag is a custom description that is 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. +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. diff --git a/content/reusable/md/cookbooks_recipe_tags.md b/content/reusable/md/cookbooks_recipe_tags.md index 80be325b68..e5e6567408 100644 --- a/content/reusable/md/cookbooks_recipe_tags.md +++ b/content/reusable/md/cookbooks_recipe_tags.md @@ -1,38 +1,39 @@ -Tags can be added and removed. Machines can be checked to see if they -already have a specific tag. To use tags in your recipe simply add the -following: +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. ```ruby -tag('mytag') +tag('tag-name') ``` -To test if a machine is tagged, add the following: +To test if a machine is tagged with a specific tag, use `tagged?` with the tag name. ```ruby -tagged?('mytag') +tagged?('tag-name') ``` -to return `true` or `false`. `tagged?` can also use an array as an -argument. +This will return `true` or `false`. + +`tagged?` also accepts an array as an argument. -To remove a tag: +Remove a tag using `untag`. ```ruby -untag('mytag') +untag('tag-name') ``` For example: ```ruby -tag('machine') +tag('test_node') -if tagged?('machine') +if tagged?('test_node') Chef::Log.info("Hey I'm #{node['tags']}") end -untag('machine') +untag('test_node') -unless tagged?('machine') +unless tagged?('test_node') Chef::Log.info('I am not tagged') end ``` @@ -40,6 +41,6 @@ end Will return something like this: ```none -[Thu, 22 Jul 2010 18:01:45 +0000] INFO: Hey I'm machine -[Thu, 22 Jul 2010 18:01:45 +0000] INFO: I has no tagz +[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 ```