jclouds/jclouds — pull request #950 by nacx (2012-11-03 22:40:13+00:00)
Title: Added basic Chef Solo support

Added basic support for Chef Solo, allowing users to bootstrap nodes with Chef without having a Chef Server.

In order to bootstrap the nodes, a tarball with the cookbooks must be made available to the node. This can be done by uploading the file to the node using the jclous ssh client, or by providing a public URL where the tarball can be downloaded from. The tarball *must* have a root folder called *cookbooks* and all cookbooks must be inside it.

Once the tarball is available, the ChefSolo statement can be used to generate the bootstrap script, as follows:

```java
NodeMetadata node = getOnlyElement(compute.createNodesInGroup(group, 1, template));

SshClient ssh = compute.getContext().getUtils().sshForNode().apply(node);
ssh.connect();
ssh.put("/tmp/cookbooks.tar.gz",
Payloads.newFilePayload(new File("/Users/nacx/cookbooks.tar.gz")));
ssh.disconnect();

compute.runScriptOnNode(node.getId(), ChefSolo.builder()
.cookbooksArchiveLocation("/tmp/cookbooks.tar.gz")
.installRecipe("apache2")
.build());
```

TODO: Chef Solo also supports attributes, roles and databags, but support for them will be added in upcoming pull requests.