Information Technology Reference
In-Depth Information
CHEF-APPLY
The
chef-apply
tool is a wrapper built on top of Chef Solo (which will be discussed in more de-
tail in
Chapter 9
). Chef Solo allows you to run Chef code locally without needing a Chef Server.
As you'll see in
Chapter 9
,
it is not convenient to execute Chef code in a
.rb
file using Chef Solo.
The
chef-apply
tool was designed to provide an easy-to-use wrapper on top of Chef Solo.
NOTE
Chef requires administrator privileges to run. If you are running User Account Control
(UAC) on Windows, make sure you
Run As Administrator
. On Linux/Mac OS X, run
chef-apply
with
sudo
privileges if you are not running as
root
.
When you run
chef-apply hello.rb
, the output should resemble, for Linux/Mac OS X:
$
sudo chef-apply hello.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* file[hello.txt] action create
- create new file hello.txt
- update content in file hello.txt from none to 40a30c
--- hello.txt 2014-08-10 22:27:44.000000000 -0700
+++ /tmp/.hello.txt20140810-14225-6e7qc7 2014-08-10 22:27:44.000000000
-0700 @@ -1 +1,2 @@
+Welcome to Chef
For Windows (Run As Administrator):
>
chef-apply hello.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* file[hello.txt] action create
- create new file hello.txt
- update content in file hello.txt from none to 40a30c
--- hello.txt 2014-07-11 12:38:30.000000000 -0700
+++ C:/Users/misheska/AppData/Local/Temp/hello.txt20140711-2344-mf17rh
@@ -1 +1,2 @@
+Welcome to Chef