Information Technology Reference
In-Depth Information
Create a Node in a Sandbox Environment
Let's use Test Kitchen to define a project that spins up a node in a sandbox environment,
similar to what we did back in
Chapter 5
before we learned how to create cookbooks.
Create a
node
directory alongside the
chef-server
cookbook you created in this chapter.
This technically isn't a cookbook—it's just a Test Kitchen project—but putting it beside the
chef-server
cookbook directory makes it convenient to go back and forth between the two.
Create the directory
~/chef-repo/cookbooks/node
, and make it the current working directory:
$
cd ~/chef-repo/cookbooks
$
mkdir node
$
cd node
The
knife client list
command should work even in this subdirectory. Verify this now:
$
knife client list
learningchef-validator
This node directory will just be a test kitchen project, not a cookbook, so run the following
commands to create a
.kitchen.yml
file for Test Kitchen:
$
kitchen init --create-gemfile
$
bundle install
Edit the
.kitchen.yml
file, as in
Example 9-5
,
to use the CentOS 6.5 basebox we prepared spe-
time, we're going to use the IP address 192.168.33.35. Make sure this address does not con-
flict with the IP address of your Chef Server, which should be 192.168.33.34.
Note that we also changed the suite name to be
node
, as this sandbox environment will be
running our node, but we also have another sandbox environment running our Chef Server.
Having different names will disambiguate the two environments.
Also, we've configured a synced folder pointing at the root
chef-repo
directory. As shown in
Figure 9-11
,
Vagrant can keep directories on your host Chef development workstation syn-
chronized with directories in the sandbox environment running on the guest.