} catch (Exception e) {
throw propagate(e);
}
String chefConfigDir = "{root}etc{fs}chef";
Statement createChefConfigDir = exec("{md} " + chefConfigDir);
Statement createClientRb = appendFile(chefConfigDir + "{fs}client.rb", ImmutableList.of("require 'rubygems'",
"require 'ohai'", "o = Ohai::System.new", "o.all_plugins",
String.format("node_name \"%s-\" + o[:ipaddress]", group), "log_level :info", "log_location STDOUT",
String.format("validation_client_name \"%s\"", validatorClientName),
String.format("chef_server_url \"%s\"", endpoint.get())));
Statement createValidationPem = appendFile(chefConfigDir + "{fs}validation.pem",
Splitter.on('\n').split(Pems.pem(validatorKey)));
String chefBootFile = chefConfigDir + "{fs}first-boot.json";
Statement createFirstBoot = appendFile(chefBootFile, Collections.singleton(json.toJson(bootstrapConfig)));
Statement runChef = exec("chef-client -j " + chefBootFile);
return newStatementList(installChefGems, createChefConfigDir, createClientRb, createValidationPem,
createFirstBoot, runChef);
}