Information Technology Reference
In-Depth Information
Roles and Search
Roles can be search items as well. The following example shows how you can search for a
recipe in the run list of a role. Note that you must use the \ character to escape the [ and ]
characters in the query string:
$ knife search role "run_list:recipe\[apache\]"
1 items found
chef_type: role
default_attributes:
description: Web Server
env_run_lists:
json_class: Chef::Role
name: webserver
override_attributes:
run_list:
recipe[motd]
recipe[users]
recipe[apache]
Because roles introduce the idea that a list of recipes in a run list can be expanded, there are
two ways to search for recipes in a node's run list:
knife search node "recipe:<recipe_name>"
When you do not want the search to include the expanded set of recipes within roles
knife search node "recipes:<recipe name>"
When you do want the search to expand role references
Recall that earlier in the chapter we assigned the snowman node to have the webserver role
in its run list. Implicitly, when the role reference is expanded during a Chef run, the node will
run the following recipes in the webserver role's run_list :
▪ recipe[motd]
▪ recipe[users]
▪ recipe[apache]
Search WWH ::




Custom Search