Information Technology Reference
In-Depth Information
We're also introducing some new syntax in the
suites:
stanza. We set the environment for
our sandbox node in its
/etc/chef/client.rb
, like so:
suites
:
-
name
:
prod
provisioner
:
client_rb
:
environment
:
production
.
.
.
Nodes can be a member of only one environment at a time. The environment is a setting in
the
/etc/chef/client.rb
file. If this is not set, a node uses the default environment named
_de-
fault
.
Outside of this simulated setup, you would use the
chef-client::config
recipe to change
the value of the
environment
setting in
/etc/chef/client.rb
, using the following node attrib-
node
.
default
[
'chef_client'
][
'config'
][
'environment'
] =
'production'
We also show how a
private_network
IP address can be set in the
suites:
stanza instead
of the
provisioner:
stanza:
suites
:
-
name
:
prod
.
.
.
driver
:
network
:
- [
"private_network"
, {
ip
:
"192.168.33.15"
}
]
When a value is set in the
provisioner:
stanza in Test Kitchen, the values are inherited by
all the items in the
suites:
stanza. In this case, we're going to want our production and dev
sandbox environments to have different IP addresses, so we move the
private_network
set-
ting to be under
suites
.
Example 15-5. chefdk/chef-zero/cookbooks/apache/.kitchen.yml
---
driver
:
name
:
vagrant