/** convenience for generating an {@link PlainSshExecTaskFactory} which can be further customised if desired, and then (it must be explicitly) queued */ public ProcessTaskFactory<Integer> ssh(String ...commands) { return new SshEffectorTaskFactory<Integer>(commands).machine(machine()); } }
/** task which fails if the given PID is not running */ public static SshEffectorTaskFactory<?> requirePidRunning(Integer pid) { return codePidRunning(pid).summary("PID "+pid+" is-running check (required)").requiringExitCodeZero("Process with PID "+pid+" is required to be running"); }
/** task which returns 0 if pid is running */ public static SshEffectorTaskFactory<Integer> codePidRunning(Integer pid) { return ssh("ps -p "+pid).summary("PID "+pid+" is-running check (exit code)").allowingNonZeroExitCode(); }
public static TaskFactory<?> runChef(String runDir, String phase) { // TODO chef server return SshEffectorTasks.ssh(cdAndRun(runDir, "sudo chef-solo -c "+phase+".rb -j "+phase+".json -ldebug")). summary("run chef for "+phase).requiringExitCodeZero(); }
public static TaskFactory<?> installChef(String chefDirectory, boolean force) { // TODO check on entity whether it is chef _server_ String installCmd = cdAndRun(chefDirectory, ChefBashCommands.INSTALL_FROM_OPSCODE); if (!force) installCmd = BashCommands.alternatives("which chef-solo", installCmd); return SshEffectorTasks.ssh(installCmd).summary("install chef"); }
/** task which fails if the pid in the given file is not running (or if there is no such PID file); * method accepts wildcards so long as they match a single file on the remote end (fails if 0 or 2+ matching files) */ public static SshEffectorTaskFactory<?> requirePidFromFileRunning(String pidFile) { return codePidFromFileRunning(pidFile) .summary("PID file "+pidFile+" is-running check (required)") .requiringExitCodeZero("Process with PID from file "+pidFile+" is required to be running"); }
/** as {@link #codePidRunning(Integer)} but returning boolean */ public static SshEffectorTaskFactory<Boolean> isPidRunning(Integer pid) { return codePidRunning(pid).summary("PID "+pid+" is-running check (boolean)").returning(new Function<ProcessTaskWrapper<?>, Boolean>() { @Override public Boolean apply(@Nullable ProcessTaskWrapper<?> input) { return Integer.valueOf(0).equals(input.getExitCode()); } }); }
/** as {@link #codePidFromFileRunning(String)} but returning boolean */ public static SshEffectorTaskFactory<Boolean> isPidFromFileRunning(String pidFile) { return codePidFromFileRunning(pidFile).summary("PID file "+pidFile+" is-running check (boolean)"). returning(new Function<ProcessTaskWrapper<?>, Boolean>() { @Override public Boolean apply(@Nullable ProcessTaskWrapper<?> input) { return ((Integer)0).equals(input.getExitCode()); } }); }
public String callOne(ConfigBag params) { return queue( makePartialTaskFactory(params, entity()) .summary("effector "+effector.getName()+" ssh call") ).get(); } public String callMany(Collection<Entity> targets, ConfigBag params) {
/** * @since 0.9.0 */ public static SshEffectorTaskFactory<Integer> ssh(SshMachineLocation machine, String ...commands) { return new SshEffectorTaskFactory<Integer>(machine, commands); }
public static SshPutTaskFactory put(String remoteFile) { return new SshPutEffectorTaskFactory(remoteFile); }
public static SshFetchEffectorTaskFactory fetch(String remoteFile) { return new SshFetchEffectorTaskFactory(remoteFile); }
public static TaskFactory<?> runChef(String runDir, String phase) { // TODO chef server return SshEffectorTasks.ssh(cdAndRun(runDir, "sudo chef-solo -c "+phase+".rb -j "+phase+".json -ldebug")). summary("run chef for "+phase).requiringExitCodeZero(); }
public static TaskFactory<?> installChef(String chefDirectory, boolean force) { // TODO check on entity whether it is chef _server_ String installCmd = cdAndRun(chefDirectory, ChefBashCommands.INSTALL_FROM_OPSCODE); if (!force) installCmd = BashCommands.alternatives("which chef-solo", installCmd); return SshEffectorTasks.ssh(installCmd).summary("install chef"); }
public static SshEffectorTaskFactory<Integer> ssh(String ...commands) { return new SshEffectorTaskFactory<Integer>(commands); }
/** see {@link ChefConfig#CHEF_RUN_CONVERGE_TWICE} for background on why 'twice' is available */ public static TaskFactory<?> runChef(String runDir, String phase, Boolean twice) { String cmd = "sudo chef-solo -c "+phase+".rb -j "+phase+".json -ldebug"; if (twice!=null && twice) cmd = BashCommands.alternatives(cmd, cmd); return SshEffectorTasks.ssh(cdAndRun(runDir, cmd)). summary("run chef for "+phase).requiringExitCodeZero(); }
public static TaskFactory<?> installChef(String chefDirectory, boolean force) { // TODO check on entity whether it is chef _server_ String installCmd = cdAndRun(chefDirectory, ChefBashCommands.INSTALL_FROM_OPSCODE); if (!force) installCmd = BashCommands.alternatives("which chef-solo", installCmd); return SshEffectorTasks.ssh(installCmd).summary("install chef"); }
@Override protected void createDirectory(String directoryName, String summaryForLogging) { DynamicTasks.queue(SshEffectorTasks.ssh("mkdir -p " + directoryName).summary(summaryForLogging) .requiringExitCodeZero()).get(); }
/** see {@link ChefConfig#CHEF_RUN_CONVERGE_TWICE} for background on why 'twice' is available */ public static TaskFactory<?> runChef(String runDir, String phase, Boolean twice) { String cmd = "sudo chef-solo -c "+phase+".rb -j "+phase+".json -ldebug"; if (twice!=null && twice) cmd = BashCommands.alternatives(cmd, cmd); return SshEffectorTasks.ssh(cdAndRun(runDir, cmd)). summary("run chef for "+phase).requiringExitCodeZero(); }
@Override public void changePassword(String oldPass, String newPass) { DynamicTasks.queue( SshEffectorTasks.ssh( "cd "+getRunDir(), getBaseDir()+"/bin/mysqladmin --defaults-file="+getConfigFile()+" --password=" + oldPass + " password "+newPass) .summary("setting password") .requiringExitCodeZero()); }