From 5d256b21b1e844026426f4ab22207952ecf35b7f Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Sun, 2 Oct 2011 22:33:56 +0200 Subject: [PATCH 01/22] Initial init_script type --- conf/type/__init_script/gencode-remote | 30 ++++++++++++++++++++++ conf/type/__init_script/parameter/optional | 1 + conf/type/__init_script/parameter/required | 1 + 3 files changed, 32 insertions(+) create mode 100644 conf/type/__init_script/gencode-remote create mode 100644 conf/type/__init_script/parameter/optional create mode 100644 conf/type/__init_script/parameter/required diff --git a/conf/type/__init_script/gencode-remote b/conf/type/__init_script/gencode-remote new file mode 100644 index 00000000..d9e56970 --- /dev/null +++ b/conf/type/__init_script/gencode-remote @@ -0,0 +1,30 @@ +#!/bin/sh +# +# 2010-2011 Daniel Roth (dani-cdist@d-roth.li) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# + +if [ -f "$__object/parameter/service" ]; then + service=$(cat "$__object/parameter/service") +else + service="/$__object_id" +fi + +mode=$(cat "$__object/parameter/mode") + +echo "/etc/init.d/${service} ${mode}" diff --git a/conf/type/__init_script/parameter/optional b/conf/type/__init_script/parameter/optional new file mode 100644 index 00000000..24e10984 --- /dev/null +++ b/conf/type/__init_script/parameter/optional @@ -0,0 +1 @@ +service diff --git a/conf/type/__init_script/parameter/required b/conf/type/__init_script/parameter/required new file mode 100644 index 00000000..17ab372f --- /dev/null +++ b/conf/type/__init_script/parameter/required @@ -0,0 +1 @@ +mode From 5f1afb08f6387111a754fef0bbdc1e7abe093257 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 3 Oct 2011 17:33:19 +0200 Subject: [PATCH 02/22] man page --- conf/type/__init_script/man.text | 49 ++++++++++++++++++++++ conf/type/__init_script/parameter/optional | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 conf/type/__init_script/man.text diff --git a/conf/type/__init_script/man.text b/conf/type/__init_script/man.text new file mode 100644 index 00000000..34065260 --- /dev/null +++ b/conf/type/__init_script/man.text @@ -0,0 +1,49 @@ +cdist-type__init_script(7) +============================== +Daniel Roth + + +NAME +---- +cdist-type__init_script - Use the init scripts + + +DESCRIPTION +----------- +This type can be used to control your init scripts. + + +REQUIRED PARAMETERS +------------------- +mode:: + Specifies what shall be done with the init script (usually one of 'start'|'stop'|'restart'|'reload' or 'force-reload') + + +OPTIONAL PARAMETERS +------------------- +script:: + If supplied, use this as the init-script. + Otherwise the object_id is used. The script will be pretended with '/etc/init.d/' + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Reloads the configuration for lighttpd +__init_script lighttpd --mode force-reload + +# Reloads the configuration for lighttpd +__init_script lighty --script lighttpd --mode force-reload +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011 Daniel Roth. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__init_script/parameter/optional b/conf/type/__init_script/parameter/optional index 24e10984..84f7e31d 100644 --- a/conf/type/__init_script/parameter/optional +++ b/conf/type/__init_script/parameter/optional @@ -1 +1 @@ -service +script From 342cbca533a5da451555769d55cd83b7cb0959c1 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 3 Oct 2011 18:00:07 +0200 Subject: [PATCH 03/22] additional parameter base_dir --- conf/type/__init_script/gencode-remote | 16 ++++++++++++---- conf/type/__init_script/man.text | 4 +++- conf/type/__init_script/parameter/optional | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/conf/type/__init_script/gencode-remote b/conf/type/__init_script/gencode-remote index d9e56970..9b493cfc 100644 --- a/conf/type/__init_script/gencode-remote +++ b/conf/type/__init_script/gencode-remote @@ -19,12 +19,20 @@ # # -if [ -f "$__object/parameter/service" ]; then - service=$(cat "$__object/parameter/service") +if [ -f "$__object/parameter/script" ]; then + script=$(cat "$__object/parameter/script") else - service="/$__object_id" + script="/$__object_id" fi +if [ -f "$__object/parameter/base_dir" ]; then + base_dir=$(cat "$__object/parameter/base_dir") +else + base_dir="/etc/init.d" +fi + + + mode=$(cat "$__object/parameter/mode") -echo "/etc/init.d/${service} ${mode}" +echo "${base_dir}/${script} ${mode}" diff --git a/conf/type/__init_script/man.text b/conf/type/__init_script/man.text index 34065260..898943a5 100644 --- a/conf/type/__init_script/man.text +++ b/conf/type/__init_script/man.text @@ -23,8 +23,10 @@ OPTIONAL PARAMETERS ------------------- script:: If supplied, use this as the init-script. - Otherwise the object_id is used. The script will be pretended with '/etc/init.d/' + Otherwise the object_id is used. +base_dir:: + If supplied, this type uses this directory instead of '/etc/init.d'. The parameter will not need an ending slash. EXAMPLES -------- diff --git a/conf/type/__init_script/parameter/optional b/conf/type/__init_script/parameter/optional index 84f7e31d..5551a8f2 100644 --- a/conf/type/__init_script/parameter/optional +++ b/conf/type/__init_script/parameter/optional @@ -1 +1,2 @@ script +base_dir From 2147480fcd418c21b3a539e622d9ad46641f6a6f Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 3 Oct 2011 18:35:45 +0200 Subject: [PATCH 04/22] base_dir is /etc/rc.d for archlinux /etc/init.d otherwise --- conf/type/__init_script/gencode-remote | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/conf/type/__init_script/gencode-remote b/conf/type/__init_script/gencode-remote index 9b493cfc..ff823cad 100644 --- a/conf/type/__init_script/gencode-remote +++ b/conf/type/__init_script/gencode-remote @@ -28,11 +28,13 @@ fi if [ -f "$__object/parameter/base_dir" ]; then base_dir=$(cat "$__object/parameter/base_dir") else - base_dir="/etc/init.d" + os="$(cat "$__global/explorer/os")" + case "$os" in + archlinux) base_dir="/etc/rc.d" ;; + *) base_dir="/etc/init.d" + esac fi - - mode=$(cat "$__object/parameter/mode") echo "${base_dir}/${script} ${mode}" From 40d5b9cb05f93a8fc770fd595aadc8d9cd0ce40c Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 3 Oct 2011 21:39:07 +0200 Subject: [PATCH 05/22] bsd init location --- conf/type/__init_script/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__init_script/gencode-remote b/conf/type/__init_script/gencode-remote index ff823cad..d212feb7 100644 --- a/conf/type/__init_script/gencode-remote +++ b/conf/type/__init_script/gencode-remote @@ -30,7 +30,7 @@ if [ -f "$__object/parameter/base_dir" ]; then else os="$(cat "$__global/explorer/os")" case "$os" in - archlinux) base_dir="/etc/rc.d" ;; + archlinux|netbsd|macosx|freebsd|openbsd) base_dir="/etc/rc.d" ;; *) base_dir="/etc/init.d" esac fi From 1d2ec72396498731e693f809e08104ca90240ad3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 4 Oct 2011 16:43:13 +0200 Subject: [PATCH 06/22] add paragraph to cdist-hacker that states manpages always need to build on merge request Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-hacker.text | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/man/man7/cdist-hacker.text b/doc/man/man7/cdist-hacker.text index b9f79d01..f8e3730e 100644 --- a/doc/man/man7/cdist-hacker.text +++ b/doc/man/man7/cdist-hacker.text @@ -46,9 +46,8 @@ work nor kill the authors brain: private branch! - Code to be included should be branched of the upstream "master" branch - Exception: Bugfixes to a version branch -- Code submissions should be in your master branch - - Other branches are fine as well, but you need to tell me which branch - your work is in! +- On a merge request, always name the branch I should pull from +- Always ensure **all** manpages build: ./build.sh man - If you developed more than **one** feature, consider submitting them in seperate branches. This way one feature can already be included, even if the other needs to be improved. From 9dfd6a27ad2b0e771e03d633a20248b2c7a0e102 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Wed, 5 Oct 2011 09:15:20 +0200 Subject: [PATCH 07/22] fixed broken man page --- conf/type/__init_script/man.text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__init_script/man.text b/conf/type/__init_script/man.text index 898943a5..c33ff7b7 100644 --- a/conf/type/__init_script/man.text +++ b/conf/type/__init_script/man.text @@ -1,5 +1,5 @@ cdist-type__init_script(7) -============================== +========================== Daniel Roth From aa1c13898aa6b66cb833036af43aef7facb0d363 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 13:00:00 +0200 Subject: [PATCH 08/22] add ideas about remote exec/copy Signed-off-by: Nico Schottelius --- doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot diff --git a/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot b/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot new file mode 100644 index 00000000..1dd9039d --- /dev/null +++ b/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot @@ -0,0 +1,45 @@ +Commands needed: + conf/cmd/remote_exec + conf/cmd/copy + +If ! conf/cmd/remote_exec: + use builtin +If ! conf/cmd/copy: + use builtin + + -> Depend on session! + +Builtin: + cdist.exec.run_or_fail(["scp", "-qr", source, + self.remote_user + "@" + + self.target_host + ":" + + destination]) + +self.remote_prefix = ["ssh", self.remote_user + "@" + self.target_host] + + self.remote_user = remote_user + self.remote_prefix = remote_prefix + +-------------------------------------------------------------------------------- +What is in a session? + + base_dir + target_host + +-------------------------------------------------------------------------------- +remote_user + pseudo-static, can be hardcoded again +-------------------------------------------------------------------------------- + +Result: + +os.environ['__remote_exec'] = ["ssh", "-l", "root" ] +os.environ['__remote_copy'] = ["scp", "-o" "User=root" ] + +args for __remote_exec + $1 = hostname + $2 - ... = stuff to be executed in /bin/sh on remote side + +args for __remote_copy + $1 = file here + $2 = hostname:destination From c0f04cab0f5e9ed0d0b70114111f46c6ad64dc90 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 13:20:05 +0200 Subject: [PATCH 09/22] more hints on env Signed-off-by: Nico Schottelius --- doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot b/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot index 1dd9039d..91f5d204 100644 --- a/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot +++ b/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot @@ -7,6 +7,12 @@ If ! conf/cmd/remote_exec: If ! conf/cmd/copy: use builtin +-------------------------------------------------------------------------------- + +--cmd-dir? +$__cdist_cmd_dir + +-------------------------------------------------------------------------------- -> Depend on session! Builtin: @@ -34,12 +40,26 @@ remote_user Result: os.environ['__remote_exec'] = ["ssh", "-l", "root" ] -os.environ['__remote_copy'] = ["scp", "-o" "User=root" ] + +os.environ['__remote_exec'] = ["ssh", "-o", "User=root" ] +os.environ['__remote_copy'] = ["scp", "-o", "User=root" ] args for __remote_exec $1 = hostname $2 - ... = stuff to be executed in /bin/sh on remote side + $2 - $7 = env + $7 - 12 = cmd + args for __remote_copy $1 = file here $2 = hostname:destination + +-------------------------------------------------------------------------------- +There needs to be an easy way to change those cmds! +-------------------------------------------------------------------------------- +Env-Passing: + _a=b test -> test can access $_a + _a=b test $_a -> $1 = "", because _a is *not* set within the shell + _a=b; test -> can access $_a + _a=b; test $_a -> $1 == "b" From eaf2b28fd7b9af740b511657ad66d2e3f52fa3cb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 13:34:28 +0200 Subject: [PATCH 10/22] more prefix ideas Signed-off-by: Nico Schottelius --- doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot b/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot index 91f5d204..ec89a999 100644 --- a/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot +++ b/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot @@ -44,6 +44,28 @@ os.environ['__remote_exec'] = ["ssh", "-l", "root" ] os.environ['__remote_exec'] = ["ssh", "-o", "User=root" ] os.environ['__remote_copy'] = ["scp", "-o", "User=root" ] + +__remote_exec=~/sudossh __remote_copy=... cdist config localhost + +~/sudossh hostname $@... +~/sudocopy a hostname:b + +~/chrootssh +~/chrootcopy + + + +a) + 3 cmd verzeichnnise: cdist, sudo, chroot + pro aufruf variable ändern + +b) + 1 dir, mit zeug + pro aufruf variablen ändern + + +conf/cmd/remote_exec + args for __remote_exec $1 = hostname $2 - ... = stuff to be executed in /bin/sh on remote side From ecc4fc10d73b8c56d2203e67803b3154a8a066f0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 13:34:45 +0200 Subject: [PATCH 11/22] setup __remote_exec and __remote_copy variables Signed-off-by: Nico Schottelius --- lib/cdist/config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/cdist/config.py b/lib/cdist/config.py index 51615c28..43d4bf51 100644 --- a/lib/cdist/config.py +++ b/lib/cdist/config.py @@ -297,6 +297,9 @@ def config(args): time_start = datetime.datetime.now() + os.environ['__remote_exec'] = ["ssh", "-o", "User=root" ] + os.environ['__remote_copy'] = ["scp", "-o", "User=root" ] + for host in args.host: c = Config(host, initial_manifest=args.manifest, home=args.cdist_home, debug=args.debug) if args.parallel: From 278c379e077b398685db1ebff5d72ddcc4f9b78e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 13:37:12 +0200 Subject: [PATCH 12/22] use os.environ['__remote_exec'] in exec* Signed-off-by: Nico Schottelius --- lib/cdist/exec.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py index 9cedefcc..aaa2c13f 100644 --- a/lib/cdist/exec.py +++ b/lib/cdist/exec.py @@ -20,6 +20,7 @@ # import logging +import os import subprocess log = logging.getLogger(__name__) @@ -32,7 +33,7 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs): args[0][:0] = [ "/bin/sh", "-e" ] if remote_prefix: - args[0][:0] = remote_prefix + args[0][:0] = os.environ['__remote_exec'] log.debug("Shell exec cmd: %s", args) @@ -43,8 +44,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs): subprocess.check_call(*args, **kargs) except subprocess.CalledProcessError: log.error("Code that raised the error:\n") - if remote_prefix: - run_or_fail(["cat", script], remote_prefix=remote_prefix) + + run_or_fail(["cat", script], remote_prefix=remote_prefix) else: try: @@ -60,7 +61,7 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs): def run_or_fail(*args, remote_prefix=False, **kargs): if remote_prefix: - args[0][:0] = remote_prefix + args[0][:0] = os.environ['__remote_exec'] log.debug("Exec: " + " ".join(*args)) try: From eea6a38f3342d38973fcc79ebdf4204dc94cc831 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 13:39:08 +0200 Subject: [PATCH 13/22] cat only locally :-) Signed-off-by: Nico Schottelius --- lib/cdist/exec.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py index aaa2c13f..bb375404 100644 --- a/lib/cdist/exec.py +++ b/lib/cdist/exec.py @@ -45,7 +45,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs): except subprocess.CalledProcessError: log.error("Code that raised the error:\n") - run_or_fail(["cat", script], remote_prefix=remote_prefix) + if remote_prefix: + run_or_fail(["cat", script], remote_prefix=remote_prefix) else: try: From df630e1fdf0da5049a802717e039baa75a2f734f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 13:40:46 +0200 Subject: [PATCH 14/22] user remote_prefix=True now Signed-off-by: Nico Schottelius --- lib/cdist/config.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/cdist/config.py b/lib/cdist/config.py index 43d4bf51..81c5b3fc 100644 --- a/lib/cdist/config.py +++ b/lib/cdist/config.py @@ -38,23 +38,16 @@ class Config: def __init__(self, target_host, initial_manifest=False, - remote_user="root", home=None, exec_path=sys.argv[0], debug=False): self.target_host = target_host self.debug = debug - self.remote_user = remote_user self.exec_path = exec_path - # FIXME: broken - construct elsewhere! - self.remote_prefix = ["ssh", self.remote_user + "@" + self.target_host] - self.path = cdist.path.Path(self.target_host, initial_manifest=initial_manifest, - remote_user=self.remote_user, - remote_prefix=self.remote_prefix, base_dir=home, debug=debug) @@ -78,7 +71,7 @@ class Config: cmd.append("__explorer=" + cdist.path.REMOTE_GLOBAL_EXPLORER_DIR) cmd.append(self.path.remote_global_explorer_path(explorer)) - cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=self.remote_prefix) + cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=True) output_fd.close() def run_type_explorer(self, cdist_object): @@ -105,7 +98,7 @@ class Config: log.debug("%s exploring %s using %s storing to %s", cdist_object, explorer, remote_cmd, output) - cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=self.remote_prefix) + cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True) output_fd.close() def link_emulator(self): @@ -235,8 +228,7 @@ class Config: remote_remote_code = os.path.join(remote_dir, "code-remote") if os.path.isfile(local_remote_code): self.path.transfer_file(local_remote_code, remote_remote_code) - # FIXME: remote_prefix - cdist.exec.run_or_fail([remote_remote_code], remote_prefix=self.remote_prefix) + cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True) def stage_prepare(self): """Do everything for a deploy, minus the actual code stage""" @@ -297,8 +289,8 @@ def config(args): time_start = datetime.datetime.now() - os.environ['__remote_exec'] = ["ssh", "-o", "User=root" ] - os.environ['__remote_copy'] = ["scp", "-o", "User=root" ] + os.environ['__remote_exec'] = "ssh -o User=root" + os.environ['__remote_copy'] = "scp -o User=root" for host in args.host: c = Config(host, initial_manifest=args.manifest, home=args.cdist_home, debug=args.debug) From 59bee1410147bfc40eb6387d2363e27921e859a2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 14:02:37 +0200 Subject: [PATCH 15/22] begin to eliminate remote_user/prefix from path Signed-off-by: Nico Schottelius --- lib/cdist/path.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/cdist/path.py b/lib/cdist/path.py index e416c42d..721764bf 100644 --- a/lib/cdist/path.py +++ b/lib/cdist/path.py @@ -57,8 +57,6 @@ class Path: def __init__(self, target_host, - remote_user, - remote_prefix, initial_manifest=False, base_dir=None, debug=False): @@ -72,9 +70,6 @@ class Path: self.temp_dir = tempfile.mkdtemp() self.target_host = target_host - self.remote_user = remote_user - self.remote_prefix = remote_prefix - self.conf_dir = os.path.join(self.base_dir, "conf") self.cache_base_dir = os.path.join(self.base_dir, "cache") self.cache_dir = os.path.join(self.cache_base_dir, target_host) @@ -122,10 +117,10 @@ class Path: def remote_mkdir(self, directory): """Create directory on remote side""" - cdist.exec.run_or_fail(["mkdir", "-p", directory], remote_prefix=self.remote_prefix) + cdist.exec.run_or_fail(["mkdir", "-p", directory], remote_prefix=True) def remove_remote_dir(self, destination): - cdist.exec.run_or_fail(["rm", "-rf", destination], remote_prefix=self.remote_prefix) + cdist.exec.run_or_fail(["rm", "-rf", destination], remote_prefix=True) def transfer_dir(self, source, destination): """Transfer directory and previously delete the remote destination""" From 5a7e4b2f322aaf06fcb422b72fabbcda3ae9bbf8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 15:48:44 +0200 Subject: [PATCH 16/22] quiet ssh/scp Signed-off-by: Nico Schottelius --- lib/cdist/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cdist/config.py b/lib/cdist/config.py index 81c5b3fc..7b59d416 100644 --- a/lib/cdist/config.py +++ b/lib/cdist/config.py @@ -289,8 +289,8 @@ def config(args): time_start = datetime.datetime.now() - os.environ['__remote_exec'] = "ssh -o User=root" - os.environ['__remote_copy'] = "scp -o User=root" + os.environ['__remote_exec'] = "ssh -o User=root -q" + os.environ['__remote_copy'] = "scp -o User=root -q" for host in args.host: c = Config(host, initial_manifest=args.manifest, home=args.cdist_home, debug=args.debug) From 919f67184a01bde6f45d3e36e1d94ff5a9503cbf Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 15:49:08 +0200 Subject: [PATCH 17/22] do not reference scp anymore Signed-off-by: Nico Schottelius --- lib/cdist/path.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/cdist/path.py b/lib/cdist/path.py index 721764bf..a2b47610 100644 --- a/lib/cdist/path.py +++ b/lib/cdist/path.py @@ -125,17 +125,13 @@ class Path: def transfer_dir(self, source, destination): """Transfer directory and previously delete the remote destination""" self.remove_remote_dir(destination) - cdist.exec.run_or_fail(["scp", "-qr", source, - self.remote_user + "@" + - self.target_host + ":" + - destination]) + cdist.exec.run_or_fail([os.environ['__remote_copy'], "-r", source, + self.target_host + ":" + destination]) def transfer_file(self, source, destination): """Transfer file""" - cdist.exec.run_or_fail(["scp", "-q", source, - self.remote_user + "@" + - self.target_host + ":" + - destination]) + cdist.exec.run_or_fail([os.environ['__remote_copy'], source, + self.target_host + ":" + destination]) def global_explorer_output_path(self, explorer): """Returns path of the output for a global explorer""" From 26278b1e326a4b8951e6df433b9b352985968f71 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 16:28:21 +0200 Subject: [PATCH 18/22] expose target host from config Signed-off-by: Nico Schottelius --- lib/cdist/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/cdist/config.py b/lib/cdist/config.py index 7b59d416..c027da17 100644 --- a/lib/cdist/config.py +++ b/lib/cdist/config.py @@ -43,6 +43,8 @@ class Config: debug=False): self.target_host = target_host + os.environ['target_host'] = target_host + self.debug = debug self.exec_path = exec_path From 8b561fd63ca886d20644d1e8f977258c9074947c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 16:30:06 +0200 Subject: [PATCH 19/22] fixup correct split/insert of os.environ() for target_host and args Signed-off-by: Nico Schottelius --- lib/cdist/exec.py | 8 ++++++-- lib/cdist/path.py | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py index bb375404..a9b8d147 100644 --- a/lib/cdist/exec.py +++ b/lib/cdist/exec.py @@ -33,7 +33,9 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs): args[0][:0] = [ "/bin/sh", "-e" ] if remote_prefix: - args[0][:0] = os.environ['__remote_exec'] + remote_prefix = os.environ['__remote_exec'].split() + remote_prefix.append(os.environ['target_host']) + args[0][:0] = remote_prefix log.debug("Shell exec cmd: %s", args) @@ -62,7 +64,9 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs): def run_or_fail(*args, remote_prefix=False, **kargs): if remote_prefix: - args[0][:0] = os.environ['__remote_exec'] + remote_prefix = os.environ['__remote_exec'].split() + remote_prefix.append(os.environ['target_host']) + args[0][:0] = remote_prefix log.debug("Exec: " + " ".join(*args)) try: diff --git a/lib/cdist/path.py b/lib/cdist/path.py index a2b47610..85d1a87f 100644 --- a/lib/cdist/path.py +++ b/lib/cdist/path.py @@ -125,13 +125,13 @@ class Path: def transfer_dir(self, source, destination): """Transfer directory and previously delete the remote destination""" self.remove_remote_dir(destination) - cdist.exec.run_or_fail([os.environ['__remote_copy'], "-r", source, - self.target_host + ":" + destination]) + cdist.exec.run_or_fail(os.environ['__remote_copy'].split() + + ["-r", source, self.target_host + ":" + destination]) def transfer_file(self, source, destination): """Transfer file""" - cdist.exec.run_or_fail([os.environ['__remote_copy'], source, - self.target_host + ":" + destination]) + cdist.exec.run_or_fail(os.environ['__remote_copy'].split() + + [source, self.target_host + ":" + destination]) def global_explorer_output_path(self, explorer): """Returns path of the output for a global explorer""" From 063fc61291edc18b3c0205526f903dbee47b257c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 16:41:28 +0200 Subject: [PATCH 20/22] remove legacy manpage of cdist-type-emulator Signed-off-by: Nico Schottelius --- doc/man/man1/cdist-type-emulator.text | 56 --------------------------- 1 file changed, 56 deletions(-) delete mode 100644 doc/man/man1/cdist-type-emulator.text diff --git a/doc/man/man1/cdist-type-emulator.text b/doc/man/man1/cdist-type-emulator.text deleted file mode 100644 index 507c1054..00000000 --- a/doc/man/man1/cdist-type-emulator.text +++ /dev/null @@ -1,56 +0,0 @@ -cdist-type-emulator(1) -====================== -Nico Schottelius - - -NAME ----- -cdist-type-emulator - Emulate type and record parameters and dependencies - - -SYNOPSIS --------- -cdist-type-emulator [TYPE ARGS] - - -DESCRIPTION ------------ -cdist-type-emulator is normally called through a link to it of the -name of a specifc type. It saves the given parameters into -a parameters directory and the requirements into a require file. - -It checks whether the parameters are valid: - -- are required parameter given? -- are all other required parameters specified as optional? - - -EXAMPLES --------- -Your manifest may contain stuff like this: - - --------------------------------------------------------------------------------- -__addifnosuchline /tmp/linetest --line "test" - -__motd --------------------------------------------------------------------------------- - -In both cases, cdist-type-emulator is called instead of a real type. -In the first case, the object id "/tmp/linetest" is recorded and the -parameter "line" stored with the content "test". - -In the second case, __motd must be decleared as a singleton, as the -object id is missing. - - -SEE ALSO --------- -- cdist(7) -- cdist-type-build-emulation(1) - - -COPYING -------- -Copyright \(C) 2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). From afa3920ca987347c50ffd44f9b4d11a3d28f37d3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 16:42:45 +0200 Subject: [PATCH 21/22] remove more obsolete manpages Signed-off-by: Nico Schottelius --- doc/man/man1/cdist-config.text | 48 ----------------------------- doc/man/man1/cdist-env.text | 49 ------------------------------ doc/man/man1/cdist-quickstart.text | 47 ---------------------------- 3 files changed, 144 deletions(-) delete mode 100644 doc/man/man1/cdist-config.text delete mode 100644 doc/man/man1/cdist-env.text delete mode 100644 doc/man/man1/cdist-quickstart.text diff --git a/doc/man/man1/cdist-config.text b/doc/man/man1/cdist-config.text deleted file mode 100644 index 0c8b0735..00000000 --- a/doc/man/man1/cdist-config.text +++ /dev/null @@ -1,48 +0,0 @@ -cdist-config(1) -=============== -Nico Schottelius - - -NAME ----- -cdist-config - Read basic cdist configuration - - -DESCRIPTION ------------ -Cdist-config is sourced by cdist programs and provides hints on where to find -types, manifests, etc. Generally speaking, it's just usable from within the -core and is only of interest for cdist-developers. - - -ENVIRONMENT VARIABLES ---------------------- -The following list contains environment variables that are known -to be changed by users in various situations. To change the variable, -use your current shell and export it, so all cdist-binaries know about it. - -__cdist_tmp_base_dir:: - Normally this points to /tmp. In case /tmp is not suitable for - cdist (i.e. has noexec flag setup) you can change this variable - to point to a better location. - - -EXAMPLES --------- - -If /tmp has the noexec flag, you can use $HOME/.tmp for instance: - --------------------------------------------------------------------------------- -export __cdist_tmp_base_dir=$HOME/.tmp --------------------------------------------------------------------------------- - - -SEE ALSO --------- -cdist(7) - - -COPYING -------- -Copyright \(C) 2010-2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/doc/man/man1/cdist-env.text b/doc/man/man1/cdist-env.text deleted file mode 100644 index 9a736133..00000000 --- a/doc/man/man1/cdist-env.text +++ /dev/null @@ -1,49 +0,0 @@ -cdist-env(1) -============ -Nico Schottelius - - -NAME ----- -cdist-env - Setup environment for using cdist - - -SYNOPSIS --------- -cdist-env - - -DESCRIPTION ------------ -cdist-env outputs two strings suitable for usage in your current shell, -so you can use cdist from the checkout. cdist-env essentially helps you -to easily setup PATH and MANPATH. - -If you've multiple checkouts of cdist and run cdist-env from the various -checkouts, a new run will prepend the last directory, thus ensures you -can run it multiple times and does what one expects. - -EXAMPLES --------- -For use in bourne shell variants (like dash, bash, ksh) as well as -in csh variants (csh, tcsh): - --------------------------------------------------------------------------------- -eval `./bin/cdist-env` --------------------------------------------------------------------------------- - -For bourne shell, there is also a shorter version: --------------------------------------------------------------------------------- -. ./bin/cdist-env --------------------------------------------------------------------------------- - - -SEE ALSO --------- -cdist(7) - - -COPYING -------- -Copyright \(C) 2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/doc/man/man1/cdist-quickstart.text b/doc/man/man1/cdist-quickstart.text deleted file mode 100644 index 087fd2d5..00000000 --- a/doc/man/man1/cdist-quickstart.text +++ /dev/null @@ -1,47 +0,0 @@ -cdist-quickstart(1) -=================== -Nico Schottelius - -NAME ----- -cdist-quickstart - Make use of cinit in 5 minutes - - -SYNOPSIS --------- -cdist-quickstart - - -DESCRIPTION ------------ -cdist-quickstart is an interactive guide to cdist. It should be one -of the first tools you use when you begin with cdist. - - -EXAMPLES --------- -To use cdist-quickstart, add the bin directory to your PATH, execute -cdist-quickstart and enjoy cdist: - --------------------------------------------------------------------------------- -# Bourne shell example -export PATH=$(pwd -P)/bin:$PATH - -# Alternatively, usable for csh and bsh, set's up PATH and MANPATH -eval `./bin/cdist-env` - -# Let's go! -cdist-quickstart --------------------------------------------------------------------------------- - - -SEE ALSO --------- -- cdist(7) -- cdist-env(1) - - -COPYING -------- -Copyright \(C) 2010-2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). From 7c11fa09378e63c49a52114f80f5d9e00919453f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Oct 2011 16:49:27 +0200 Subject: [PATCH 22/22] introduce unclear changes (names not yet decided) Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index 632ddb45..798c90e0 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,6 +1,7 @@ 2.0.3: * Improved logging, added --verbose, by more quiet by default * Bugfix __user: Correct quoting (Steven Armstrong) + * FIXME: Support for __remote_exec and __remote_copy 2.0.2: 2011-09-27 * Add support for detection of OpenWall Linux (Matthias Teege)