From a90751dcff360e6ba2ceb5902ba90f43bdc6686e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 8 Sep 2011 01:36:22 +0200 Subject: [PATCH] begin to implmenent remote execution Signed-off-by: Nico Schottelius --- bin/cdist | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/cdist b/bin/cdist index 233e6fee..d680eaa6 100755 --- a/bin/cdist +++ b/bin/cdist @@ -34,25 +34,34 @@ def exit_error(*args): def run_or_fail(*args): + newargs = ["echo"] + newargs.extend(*args) + try: - subprocess.check_call(*args) + subprocess.check_call(newargs) except CalledProcessError: - exit_error("Command failed:", *args) + exit_error("Command failed:", newargs) + +def remote_run_or_fail(hostname, *args): + newargs = ["ssh", hostname] + newargs.extend(*args) + + run_or_fail(newargs) def cdist_deploy_to(hostname): """Mimic the old deploy to: Deploy to one host""" logger("info", "Deploying to host", hostname) + init_deploy(hostname) -def init_deploy(): +def init_deploy(hostname): logger("info", "Creating clean directory structure") # Ensure there is no old stuff, neither local nor remote - run_or_fail(["echo rm -rf", "$__cdist_local_base_dir"]) + run_or_fail(["echo", "rm -rf", "$__cdist_local_base_dir"]) -# ssh "${__cdist_remote_user}@${__cdist_target_host}" \ -# "rm -rf ${__cdist_remote_base_dir}" + remote_run_or_fail(hostname, ["rm -rf", "${__cdist_remote_base_dir}"]) # # # Init base # mkdir -p "$__cdist_local_base_dir"