templateBuilder.minRam(Integer.parseInt(minRam));
}
// note this will create a user with the same name as you on the
// node. ex. you can connect via ssh publicip
Statement bootInstructions = AdminAccess.standard();
// to run commands as root, we use the runScript option in the
// template.
templateBuilder.options(runScript(bootInstructions));
NodeMetadata node = getOnlyElement(compute.createNodesInGroup(groupName, 1, templateBuilder.build()));
System.out.printf("<< node %s: %s%n", node.getId(),
concat(node.getPrivateAddresses(), node.getPublicAddresses()));
case SOLO:
System.out.printf(">> installing [%s] on group %s as %s%n", recipes, groupName, login.identity);
Iterable<String> recipeList = Splitter.on(',').split(recipes);
ImmutableList.Builder<Statement> bootstrapBuilder = ImmutableList.builder();
bootstrapBuilder.add(new InstallGit());
// Clone community cookbooks into the node
for (String recipe : recipeList) {
bootstrapBuilder.add(CloneGitRepo.builder()
.repository("git://github.com/opscode-cookbooks/" + recipe + ".git")
.directory("/var/chef/cookbooks/" + recipe) //
.build());
}
// Configure Chef Solo to bootstrap the selected recipes
bootstrapBuilder.add(InstallRuby.builder().build());
bootstrapBuilder.add(InstallRubyGems.builder().build());
bootstrapBuilder.add(ChefSolo.builder() //
.cookbookPath("/var/chef/cookbooks") //
.runlist(RunList.builder().recipes(recipeList).build()) //
.build());
// Build the statement that will perform all the operations above
StatementList bootstrap = new StatementList(bootstrapBuilder.build());
// Run the script in the nodes of the group
runScriptOnGroup(compute, login, groupName, bootstrap);
break;
case CHEF:
// Create the connection to the Chef server
ChefService chef = initChefService(System.getProperty("chef.client"),
System.getProperty("chef.validator"));
// Build the runlist for the deployed nodes
System.out.println("Configuring node runlist in the Chef server...");
List<String> runlist = new RunListBuilder().addRecipes(recipes.split(",")).build();
chef.updateRunListForGroup(runlist, groupName);
Statement chefServerBootstrap = chef.createBootstrapScriptForGroup(groupName);
// Run the script in the nodes of the group
System.out.printf(">> installing [%s] on group %s as %s%n", recipes, groupName, login.identity);
runScriptOnGroup(compute, login, groupName, chefServerBootstrap);
break;