update docs, document exit code bug

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
Nico Schottelius 2013-08-12 11:42:00 +02:00
parent 8fddb1692f
commit 32f878ad00
4 changed files with 79 additions and 30 deletions

View file

@ -28,6 +28,7 @@ import time
import pprint
import cdist
import cdist.context
from cdist import core
class ConfigInstall(object):
@ -107,11 +108,7 @@ class ConfigInstall(object):
def onehost(cls, host, args, parallel):
"""Configure or install ONE system"""
# FIXME: Refactor relict - remove later
log = logging.getLogger("cdist")
try:
import cdist.context
context = cdist.context.Context(
target_host=host,

View file

@ -5,40 +5,51 @@ Nico Schottelius <nico-cdist--@--schottelius.org>
NAME
----
cdist - Configuration management
cdist - Usable Configuration Management
SYNOPSIS
--------
cdist [-h] [-V]
cdist [-h] [-d] [-v] [-V] {banner,config,shell} ...
cdist banner
cdist banner [-h] [-d] [-v]
cdist config [-h] [-d] [-V] [-c CONF_DIR] [-i MANIFEST] [-p] [-s] host [host ...]
cdist shell [-h] [-d] [-v] [-s SHELL]
DESCRIPTION
-----------
cdist is the frontend executable to the cdist configuration management.
cdist supports different as explained below. The options to the main
program are:
cdist supports different subcommands as explained below.
GENERAL
-------
All commands except the following options:
-d, --debug::
Set log level to debug
-h, --help::
Show the help screen
-v, --verbose:
Set log level to info, be more verbose
-V, --version::
Show version and exit
BANNER
-------
Displays the cdist banner.
------
Displays the cdist banner. Useful for printing
cdist posters - a must have for every office.
CONFIG
------
Configure a system
Configure one or more hosts
-h, --help::
Show the help screen
@ -52,9 +63,6 @@ Configure a system
--conf-dir argument have higher precedence over those set through the
environment variable.
-d, --debug::
Enable debug output
-i MANIFEST, --initial-manifest MANIFEST::
Path to a cdist manifest or - to read from stdin
@ -70,20 +78,27 @@ Configure a system
--remote-exec REMOTE_EXEC:
Command to use for remote execution (should behave like ssh)
SHELL
-----
This command allows you to
-s/--shell::
Select shell to use, defaults to current shell
EXAMPLES
--------
--------------------------------------------------------------------------------
# Configure ikq05.ethz.ch with debug enabled
cdist config -d ikq05.ethz.ch
% cdist config -d ikq05.ethz.ch
# Configure hosts in parallel and use a different configuration directory
cdist config -c ~/p/cdist-nutzung \
% cdist config -c ~/p/cdist-nutzung \
-p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch
# Use custom remote exec / copy commands
cdist config --remote-exec /path/to/my/remote/exec \
% cdist config --remote-exec /path/to/my/remote/exec \
--remote-copy /path/to/my/remote/copy \
-p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch
@ -91,10 +106,18 @@ cdist config --remote-exec /path/to/my/remote/exec \
cdist banner
# Show help
cdist --help
% cdist --help
# Show Version
cdist --version
% cdist --version
# Enter a shell that has access to emulated types
% cdist shell
% __git
usage: __git --source SOURCE [--state STATE] [--branch BRANCH]
[--group GROUP] [--owner OWNER] [--mode MODE] object_id
--------------------------------------------------------------------------------
@ -125,5 +148,5 @@ SEE ALSO
COPYING
-------
Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is
Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -167,7 +167,7 @@ TEMPLATING
* create directory templates/ in your type (convention)
* create the template as an executable file like templates/basic.conf.sh, it will output text using shell variables for the values
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
#!/bin/sh
# in the template, use cat << eof (here document) to output the text
# and use standard shell variables in the template
@ -182,10 +182,10 @@ server {
error_log /var/log/nginx/$SERVERNAME_error.log
}
EOF
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
* in the manifest, export the relevant variables and add the following lines in your manifest:
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
# export variables needed for the template
export SERVERNAME='test"
export ROOT='/var/www/test'
@ -193,8 +193,31 @@ EOF
mkdir -p "$__object/files"
"$__type/templates/basic.conf.sh" > "$__object/files/basic.conf"
# send the rendered template
__file /etc/nginx/sites-available/test.conf --state present --source "$__object/files/basic.conf"
--------------------------------------------------------------------------------------
__file /etc/nginx/sites-available/test.conf \
--state present
--source "$__object/files/basic.conf"
--------------------------------------------------------------------------------
TESTING A NEW TYPE
------------------
If you want to test a new type on a node, you can tell cdist to only use an
object of this type: Use the '--initial-manifest' parameter
with - (stdin) as argument and feed object into stdin
of cdist:
--------------------------------------------------------------------------------
# Singleton type without parameter
echo __ungleich_munin_server | cdist --initial-manifest - munin.panter.ch
# Singleton type with parameter
echo __ungleich_munin_node --allow 1.2.3.4 | \
cdist --initial-manifest - rails-19.panter.ch
# Normal type
echo __file /tmp/stdintest --mode 0644 | \
cdist --initial-manifest - cdist-dev-01.ungleich.ch
--------------------------------------------------------------------------------
SEE ALSO
--------
@ -204,5 +227,5 @@ SEE ALSO
COPYING
-------
Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is
Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -167,10 +167,16 @@ if __name__ == "__main__":
commandline()
except KeyboardInterrupt:
exit_code = 2
pass
# FIXME: We always get exit code = 130
# exit_code = 2
# does not make a difference
except cdist.Error as e:
log.error(e)
exit_code = 1
#sys.exit(20)
#print("ok2 %s" % exit_code)
sys.exit(exit_code)