Information Technology Reference
In-Depth Information
Edit the
.kitchen.yml
to make sure you are using the
chef_zero
provisioner and our favorite
basebox image as shown in
Example 12-1
.
Notice there is a new addition to the
provision-
er:
stanza, the
nodes_path:
provisioner
:
name
:
chef_zero
nodes_path
:
.
.
/.
.
/
nodes
nodes_path
is a relative path pointing to the
chef-playground/nodes
directory we created
with our test data in
Chapter 11
.
Test data is normally located somewhere outside the main
cookbook source code so it doesn't get inadvertently uploaded to the Chef server.
Example 12-1. chefdk/chef-playground/cookbooks/nodes/.kitchen.yml
---
driver
:
name
:
vagrant
provisioner
:
name
:
chef_zero
nodes_path
:
.
.
/.
.
/
nodes
platforms
:
-
name
:
centos65
driver
:
box
:
learningchef
/
centos65
box_url
:
learningchef
/
centos65
suites
:
-
name
:
default
run_list
:
-
recipe
[
nodes
:
:default
]
attributes
:
Let's write a recipe that performs a search query on Chef Server for all nodes, like we did in
the previous section. Chef provides a
search()
method that you can use in your Chef code.
It takes two parameters, similar to the two
command line
parameters used in
knife search
:
search(
index
,
search_query
)
:
index
Possible values for index are
node
,
client
,
environment
,
role
, and
<name of data
bag>
. In this example, we'll be using
node
.