-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Tag editing Signed-off-by: Ian Maddaus <[email protected]> * Additional revisions Signed-off-by: Ian Maddaus <[email protected]> --------- Signed-off-by: Ian Maddaus <[email protected]>
- Loading branch information
Showing
2 changed files
with
19 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,46 @@ | ||
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 | ||
``` | ||
|
||
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 | ||
``` |