Information Technology Reference
In-Depth Information
$
kitchen list
Instance Driver Provisioner Last Action
default-centos65 Vagrant ChefSolo Set Up
Now, if you log into the guest node, you should see that
chef-client
is present:
$
kitchen login default-centos65
Last login: Sat Jul 5 09:15:07 2014 from 10.0.2.2
Welcome to your Packer-built virtual machine.
[vagrant@default-centos65 ~]$
chef-client --version
Chef: 11.14.6
Your First Chef-Client Run
Although you could use
chef-apply
to execute code in a Chef recipe file like you did in
client
provides the ability to execute Chef code across multiple recipe files, which we'll see
ning a lot of Chef code. In order to make maintenance easier, one normally spreads produc-
tion code across multiple recipe files. Although
chef-apply
will do in a pinch for simple
management tasks, you'll end up using
chef-client
most of the time to manage a node
with Chef.
To show you the basics of using
chef-client
, let's create a new Chef recipe file that prints
out some of the information Chef maintains about each node.
The
log
resource can be used to print out strings from a recipe. For example, the statement
log "Hello"
in a recipe would write out the string
Hello
. Let's give this a try. We assume
you're still logged in to the node environment. Create the file
hello.rb
on the node with the
following command:
[vagrant@default-centos65 ~]$
echo 'log "Hello, this is an important message."' \
> hello.rb