public static TaskFactory<?> buildChefFile(String runDirectory, String chefDirectory, String phase, Iterable<? extends String> runList, Map<String, Object> optionalAttributes) { // TODO if it's server, try knife first // TODO configure add'l properties String phaseRb = "root = File.absolute_path(File.dirname(__FILE__))\n"+ "\n"+ "file_cache_path root\n"+ // "cookbook_path root + '/cookbooks'\n"; "cookbook_path '"+chefDirectory+"'\n"; Map<String,Object> phaseJsonMap = MutableMap.of(); if (optionalAttributes!=null) phaseJsonMap.putAll(optionalAttributes); if (runList!=null) phaseJsonMap.put("run_list", ImmutableList.copyOf(runList)); Gson json = new GsonBuilder().create(); String phaseJson = json.toJson(phaseJsonMap); return Tasks.sequential("build chef files for "+phase, SshEffectorTasks.put(Urls.mergePaths(runDirectory)+"/"+phase+".rb").contents(phaseRb).createDirectory(), SshEffectorTasks.put(Urls.mergePaths(runDirectory)+"/"+phase+".json").contents(phaseJson)); }
public static TaskFactory<?> buildChefFile(String runDirectory, String chefDirectory, String phase, Iterable<? extends String> runList, Map<String, Object> optionalAttributes) { // TODO if it's server, try knife first // TODO configure add'l properties String phaseRb = "root = File.absolute_path(File.dirname(__FILE__))\n"+ "\n"+ "file_cache_path root\n"+ // "cookbook_path root + '/cookbooks'\n"; "cookbook_path '"+chefDirectory+"'\n"; Map<String,Object> phaseJsonMap = MutableMap.of(); if (optionalAttributes!=null) phaseJsonMap.putAll(optionalAttributes); if (runList!=null) phaseJsonMap.put("run_list", ImmutableList.copyOf(runList)); Gson json = new GsonBuilder().create(); String phaseJson = json.toJson(phaseJsonMap); return Tasks.sequential("build chef files for "+phase, SshEffectorTasks.put(Urls.mergePaths(runDirectory)+"/"+phase+".rb").contents(phaseRb).createDirectory(), SshEffectorTasks.put(Urls.mergePaths(runDirectory)+"/"+phase+".json").contents(phaseJson)); }