forked from ungleich-public/cdist
Merge branch 'master' into install
Conflicts: lib/cdist/config.py lib/cdist/path.py Merged changes from config.py to config_install.py Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
commit
54fb9e6c3f
14 changed files with 201 additions and 218 deletions
40
conf/type/__init_script/gencode-remote
Normal file
40
conf/type/__init_script/gencode-remote
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/script" ]; then
|
||||
script=$(cat "$__object/parameter/script")
|
||||
else
|
||||
script="/$__object_id"
|
||||
fi
|
||||
|
||||
if [ -f "$__object/parameter/base_dir" ]; then
|
||||
base_dir=$(cat "$__object/parameter/base_dir")
|
||||
else
|
||||
os="$(cat "$__global/explorer/os")"
|
||||
case "$os" in
|
||||
archlinux|netbsd|macosx|freebsd|openbsd) base_dir="/etc/rc.d" ;;
|
||||
*) base_dir="/etc/init.d"
|
||||
esac
|
||||
fi
|
||||
|
||||
mode=$(cat "$__object/parameter/mode")
|
||||
|
||||
echo "${base_dir}/${script} ${mode}"
|
51
conf/type/__init_script/man.text
Normal file
51
conf/type/__init_script/man.text
Normal file
|
@ -0,0 +1,51 @@
|
|||
cdist-type__init_script(7)
|
||||
==========================
|
||||
Daniel Roth <dani-cdist--@--d-roth.li>
|
||||
|
||||
|
||||
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.
|
||||
|
||||
base_dir::
|
||||
If supplied, this type uses this directory instead of '/etc/init.d'. The parameter will not need an ending slash.
|
||||
|
||||
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).
|
2
conf/type/__init_script/parameter/optional
Normal file
2
conf/type/__init_script/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
|||
script
|
||||
base_dir
|
1
conf/type/__init_script/parameter/required
Normal file
1
conf/type/__init_script/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
mode
|
|
@ -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)
|
||||
|
|
87
doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot
Normal file
87
doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot
Normal file
|
@ -0,0 +1,87 @@
|
|||
Commands needed:
|
||||
conf/cmd/remote_exec
|
||||
conf/cmd/copy
|
||||
|
||||
If ! conf/cmd/remote_exec:
|
||||
use builtin
|
||||
If ! conf/cmd/copy:
|
||||
use builtin
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--cmd-dir?
|
||||
$__cdist_cmd_dir
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-> 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_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
|
||||
$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"
|
|
@ -1,48 +0,0 @@
|
|||
cdist-config(1)
|
||||
===============
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
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).
|
|
@ -1,49 +0,0 @@
|
|||
cdist-env(1)
|
||||
============
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
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).
|
|
@ -1,47 +0,0 @@
|
|||
cdist-quickstart(1)
|
||||
===================
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
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).
|
|
@ -1,56 +0,0 @@
|
|||
cdist-type-emulator(1)
|
||||
======================
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
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).
|
|
@ -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.
|
||||
|
|
|
@ -24,7 +24,9 @@ import datetime
|
|||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
<<<<<<< HEAD
|
||||
import cdist.config_install
|
||||
>>>>>>> master
|
||||
|
||||
class Config(cdist.config_install.ConfigInstall):
|
||||
pass
|
||||
|
@ -35,6 +37,9 @@ def config(args):
|
|||
|
||||
time_start = datetime.datetime.now()
|
||||
|
||||
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)
|
||||
if args.parallel:
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#
|
||||
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -32,6 +33,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
|
|||
args[0][:0] = [ "/bin/sh", "-e" ]
|
||||
|
||||
if remote_prefix:
|
||||
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)
|
||||
|
@ -43,6 +46,7 @@ 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)
|
||||
|
||||
|
@ -60,6 +64,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
|
|||
|
||||
def run_or_fail(*args, remote_prefix=False, **kargs):
|
||||
if remote_prefix:
|
||||
remote_prefix = os.environ['__remote_exec'].split()
|
||||
remote_prefix.append(os.environ['target_host'])
|
||||
args[0][:0] = remote_prefix
|
||||
|
||||
log.debug("Exec: " + " ".join(*args))
|
||||
|
|
|
@ -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
|
||||
|
||||
# Input directories
|
||||
self.conf_dir = os.path.join(self.base_dir, "conf")
|
||||
self.cache_base_dir = os.path.join(self.base_dir, "cache")
|
||||
|
@ -135,28 +130,24 @@ class Path:
|
|||
# FIXME: belongs to here - clearify remote*
|
||||
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)
|
||||
|
||||
# FIXME: belongs to here - clearify remote*
|
||||
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)
|
||||
|
||||
# FIXME: belongs to here - clearify remote*
|
||||
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'].split() +
|
||||
["-r", source, self.target_host + ":" + destination])
|
||||
|
||||
# FIXME: belongs to here - clearify remote*
|
||||
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'].split() +
|
||||
[source, self.target_host + ":" + destination])
|
||||
|
||||
# FIXME: Explorer or stays
|
||||
def global_explorer_output_path(self, explorer):
|
||||
|
|
Loading…
Reference in a new issue