summaryrefslogtreecommitdiff
path: root/chef/distro/common/man/man1/shef.1
blob: dac41dae1ea762cc670a919e4fe1d5a2f318ade1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "SHEF" "1" "April 2013" "Chef 10.24.4" "Chef Manual"
.
.SH "NAME"
\fBshef\fR \- Interactive Chef Console
.
.SH "SYNOPSIS"
\fBshef\fR [\fInamed configuration\fR] \fI(options)\fR
.
.TP
\fB\-S\fR, \fB\-\-server CHEF_SERVER_URL\fR
The chef server URL
.
.TP
\fB\-z\fR, \fB\-\-client\fR
chef\-client mode
.
.TP
\fB\-c\fR, \fB\-\-config CONFIG\fR
The configuration file to use
.
.TP
\fB\-j\fR, \fB\-\-json\-attributes JSON_ATTRIBS\fR
Load attributes from a JSON file or URL
.
.TP
\fB\-l\fR, \fB\-\-log\-level LOG_LEVEL\fR
Set the logging level
.
.TP
\fB\-s\fR, \fB\-\-solo\fR
chef\-solo shef session
.
.TP
\fB\-a\fR, \fB\-\-standalone\fR
standalone shef session
.
.TP
\fB\-v\fR, \fB\-\-version\fR
Show chef version
.
.TP
\fB\-h\fR, \fB\-\-help\fR
Show command options
.
.P
When no \-\-config option is specified, shef attempts to load a default configuration file:
.
.IP "\(bu" 4
If a \fInamed configuration\fR is given, shef will load ~/\.chef/\fInamed configuration\fR/shef\.rb
.
.IP "\(bu" 4
If no \fInamed configuration\fR is given shef will load ~/\.chef/shef\.rb if it exists
.
.IP "\(bu" 4
Shef falls back to loading /etc/chef/client\.rb or /etc/chef/solo\.rb if \-z or \-s options are given and no shef\.rb can be found\.
.
.IP "\(bu" 4
The \-\-config option takes precedence over implicit configuration paths\.
.
.IP "" 0
.
.SH "DESCRIPTION"
\fBshef\fR is an irb(1) (interactive ruby) session customized for Chef\. \fBshef\fR serves two primary functions: it provides a means to interact with a Chef Server interactively using a convenient DSL; it allows you to define and run Chef recipes interactively\.
.
.SH "SYNTAX"
Shef uses irb\'s subsession feature to provide multiple modes of interaction\. In addition to the primary mode which is entered on start, \fBrecipe\fR and \fBattributes\fR modes are available\.
.
.SH "PRIMARY MODE"
The following commands are available in the primary session:
.
.TP
\fBhelp\fR
Prints a list of available commands
.
.TP
\fBversion\fR
Prints the Chef version
.
.TP
\fBrecipe\fR
Switches to \fBrecipe\fR mode
.
.TP
\fBattributes\fR
Switches to \fBattributes\fR mode
.
.TP
\fBrun_chef\fR
Initiates a chef run
.
.TP
\fBreset\fR
reinitializes shef
.
.TP
\fBecho :on|:off\fR
Turns irb\'s echo function on or off\. Echo is \fIon\fR by default\.
.
.TP
\fBtracing :on|:off\fR
Turns irb\'s function tracing feature on or off\. Tracing is extremely verbose and expected to be of interest primarily to developers\.
.
.TP
\fBnode\fR
Returns the \fInode\fR object for the current host\. See knife\-node(1) for more information about nodes\.
.
.TP
\fBohai\fR
Prints the attributes of \fInode\fR
.
.P
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 \fIobject type\fR\.\fIoperation\fR, where \fIobject type\fR is in plural form\. The following object types are available:
.
.IP "\(bu" 4
\fBnodes\fR
.
.IP "\(bu" 4
\fBroles\fR
.
.IP "\(bu" 4
\fBdata_bags\fR
.
.IP "\(bu" 4
\fBclients\fR
.
.IP "\(bu" 4
\fBcookbooks\fR
.
.IP "" 0
.
.P
For each \fIobject type\fR the following operations are available:
.
.TP
\fIobject type\fR\.all(\fI&block\fR)
Loads all items from the server\. If the optional code \fIblock\fR is given, each item will be passed to the block and the results returned, similar to ruby\'s \fBEnumerable#map\fR method\.
.
.TP
\fIobject type\fR\.show(\fIobject name\fR)
Aliased as \fIobject type\fR\.load
.
.IP
Loads the singular item identified by \fIobject name\fR\.
.
.TP
\fIobject type\fR\.search(\fIquery\fR, \fI&block\fR)
Aliased as \fIobject type\fR\.find
.
.IP
Runs a search against the server and returns the matching items\. If the optional code \fIblock\fR is given each item will be passed to the block and the results returned\.
.
.IP
The \fIquery\fR 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\.
.
.TP
\fIobject type\fR\.transform(:all|\fIquery\fR, \fI&block\fR)
Aliased as \fIobject type\fR\.bulk_edit
.
.IP
Bulk edit objects by processing them with the (required) code \fIblock\fR\. You can edit all objects of the given type by passing the Symbol \fB:all\fR as the argument, or only a subset by passing a \fIquery\fR as the argument\. The \fIquery\fR is evaluated in the same way as with \fBsearch\fR\.
.
.IP
The return value of the code \fIblock\fR is used to alter the behavior of \fBtransform\fR\. If the value returned from the block is \fBnil\fR or \fBfalse\fR, 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\.
.
.SH "RECIPE MODE"
Recipe mode implements Chef\'s recipe DSL\. Exhaustively documenting this DSL is outside the scope of this document\. See the following pages in the Chef documentation for more information:
.
.IP "\(bu" 4
\fIhttp://wiki\.opscode\.com/display/chef/Resources\fR
.
.IP "\(bu" 4
\fIhttp://wiki\.opscode\.com/display/chef/Recipes\fR
.
.IP "" 0
.
.P
Once you have defined resources in the recipe, you can trigger a convergence run via \fBrun_chef\fR
.
.SH "EXAMPLES"
.
.IP "\(bu" 4
A "Hello World" interactive recipe
.
.IP
chef > recipe
.
.br
chef:recipe > echo :off
.
.br
chef:recipe > file "/tmp/hello_world"
.
.br
chef:recipe > run_chef
.
.br
[Sat, 09 Apr 2011 08:56:56 \-0700] INFO: Processing file[/tmp/hello_world] action create ((irb#1) line 2)
.
.br
[Sat, 09 Apr 2011 08:56:56 \-0700] INFO: file[/tmp/hello_world] created file /tmp/hello_world
.
.br
chef:recipe > pp ls \'/tmp\'
.
.br
["\.",
.
.br
"\.\.",
.
.br
"hello_world"]
.
.IP "\(bu" 4
Search for \fInodes\fR by role, and print their IP addresses
.
.IP
chef > nodes\.find(:roles => \'monitoring\-server\') {|n| n[:ipaddress] }
.
.br
=> ["10\.254\.199\.5"]
.
.IP "\(bu" 4
Remove the role \fIobsolete\fR from every node in the system
.
.IP
chef > nodes\.transform(:all) {|n| n\.run_list\.delete(\'role[obsolete]\') }
.
.br
=> [node[chef098b2\.opschef\.com], node[ree\-woot], node[graphite\-dev], node[fluke\.localdomain], node[ghost\.local], node[kallistec]]
.
.IP "" 0
.
.SH "BUGS"
The name \fBshef\fR is clever in print but is confusing when spoken aloud\. Pronouncing \fBshef\fR as \fBchef console\fR is an imperfect workaround\.
.
.P
\fBshef\fR often does not perfectly replicate the context in which chef\-client(8) configures a host, which may lead to discrepancies in observed behavior\.
.
.P
\fBshef\fR has to duplicate much code from chef\-client\'s internal libraries and may become out of sync with the behavior of those libraries\.
.
.SH "SEE ALSO"
chef\-client(8) knife(1) \fIhttp://wiki\.opscode\.com/display/chef/Shef\fR
.
.SH "AUTHOR"
Chef was written by Adam Jacob \fIadam@opscode\.com\fR with many contributions from the community\. Shef was written by Daniel DeLeo\.
.
.SH "DOCUMENTATION"
This manual page was written by Daniel DeLeo \fIdan@opscode\.com\fR\. Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2\.0 License\.
.
.SH "CHEF"
Shef is distributed with Chef\. \fIhttp://wiki\.opscode\.com/display/chef/Home\fR