jclouds/jclouds — pull request #968 by nacx (2012-11-07 18:26:47+00:00)
Title: Fully support all Chef Solo features

Added the remaining features to fully support Chef Solo. These include:

* Allow users to specify custom json attributes to be computed when installing cookbooks.
* Allow users to define roles.
* Allow users to define custom databags.

The following example illustrates how the roles and databags can be used to customize the behavior of the cookbooks:

```java
// Define a role that will install an Apache with SSL support
Role webserver = Role.builder()
.name("webserver")
.installRecipe("apache2")
.installRecipe("apache2::mod_ssl")
.build();

// Define a databag containing data the cookbooks may use
DataBag databag = DataBag.builder()
.name("bootstrap")
.item("group", "{\"foo\":\"bar\"}")
.build();

// Create the Chef bootstrap statement to install Apache in a custom port
Statement chefBootstrap = ChefSolo.builder()
.cookbooksArchiveLocation("http://foo/bar/cookbooks.tar.gz")
.jsonAttributes("{\"apache\":{\"listen_ports\":[\"8888\"]}}")
.defineRole(webserver)
.defineDataBag(databag)
.installRole("webserver")
.build();

// Deploy and bootstrap the node using Chef!
compute.createNodesInGroup("group", 1, runScript(chefBootstrap)));
```