Primary mode
The following commands are available in the primary session:
help-
Prints a list of available commands
version-
Prints the Chef version
recipe-
Switches to
recipemode
attributes-
Switches to
attributesmode
run_chef-
Initiates a chef run
reset-
reinitializes shef
- echo :on|:off
-
Turns irb´s echo function on or off. Echo is on by default.
- tracing :on|:off
-
Turns irb´s function tracing feature on or off. Tracing is extremely verbose and expected to be of interest primarily to developers.
node-
Returns the node object for the current host. See knife-node(1) for more information about nodes.
ohai-
Prints the attributes of node
In addition to these commands, shef provides a DSL for accessing data on the Chef Server. When working with remote data in shef, you chain method calls in the form object type.operation, where object type is in plural form. The following object types are available:
- •
-
nodes
- •
-
roles
- •
-
data_bags
- •
-
clients
- •
-
cookbooks
For each object type the following operations are available:
- object type.all(&block)
-
Loads all items from the server. If the optional code block is given, each item will be passed to the block and the results returned, similar to ruby´s
Enumerable#mapmethod.
- object type.show(object name)
-
Aliased as object type.load
-
Loads the singular item identified by object name.
- object type.search(query, &block)
-
Aliased as object type.find
-
Runs a search against the server and returns the matching items. If the optional code block is given each item will be passed to the block and the results returned.
-
The query may be a Solr/Lucene format query given as a String, or a Hash of conditions. If a Hash is given, the options will be ANDed together. To join conditions with OR, use negative queries, or any advanced search syntax, you must provide give the query in String form.
- object type.transform(:all|query, &block)
-
Aliased as object type.bulk_edit
-
Bulk edit objects by processing them with the (required) code block. You can edit all objects of the given type by passing the Symbol
:allas the argument, or only a subset by passing a query as the argument. The query is evaluated in the same way as withsearch.
-
The return value of the code block is used to alter the behavior of
transform. If the value returned from the block isnilorfalse, the object will not be saved. Otherwise, the object is saved after being passed to the block. This behavior can be exploited to create a dry run to test a data transformation.