test-kitchen/test-kitchen — pull request #280 by fnichol (2013-12-08 21:27:51+00:00)
Title: Add `json_attributes: true` config option to ChefZero provisioner.

This option allows a user to invoke chef-client without passing the
generated JSON file in the `--json-attributes` option. That way if you
have a JSON definition of your node (including a run-list), the
chef-client run will depend entirely on what is on the "Chef Server".

For example, let's assume we want a node called "mynode" to be in the
"production" chef environment. Given a .kitchen.yml with the following:

---
driver:
name: vagrant

provisioner:
name: chef_zero
json_attributes: false
client_rb:
node_name: mynode

platforms:
- name: ubuntu-12.04

suites:
- name: default

and an environment JSON description for our chef environment called
"production" in `test/integration/environments/production.json` that
looks like:

{
"name": "production",
"default_attributes": {
"myenv_attr": "Good to be in prod"
}
}

and a node JSON description for our node called "mynode" in
`test/integration/nodes/mynode.json` that looks like:

{
"id": "mynode",
"chef_environment": "production",
"run_list": [
"recipe[nginx]"
],
"normal": {
"some_attr": "hello"
},
"automatic": {
"ipaddress": "192.168.77.77"
}
}

then the instance will attempt to register with the Chef Zero server as
"mynode" (vs. "default-ubuntu-1204" in this case) and will receive a
run-list of `["recipe[nginx]"]` from the server. Additionally the
following node attributes will be setup:

* `node[:some_attr]` will be set to `"hello"`
* `node[:myenv_attr]` will be set to `"Good to be in prod"`
* `node[:ipaddress]` will be set to `"192.168.77.77"`

Note that the node JSON format assumes a Chef 11 serialized format which
Chef Zero will use under the hood. For more details, please read:

http://docs.opscode.com/essentials_node_object.html