Merge remote-tracking branch 'telmich/master' into filestate

Conflicts:
	conf/type/__file/gencode-local

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2012-01-09 10:45:27 +01:00
commit 8c1aa87296
271 changed files with 17717 additions and 3049 deletions

7
.gitignore vendored
View file

@ -11,5 +11,8 @@ doc/man/man7/cdist-type__*.text
doc/man/man7/cdist-reference.text
doc/man/man*/docbook-xsl.css
# Ignore cache for version control
cache/
# Ignore cdist cache for version control
/cache/
# Python / cache
__pycache__/

View file

@ -1,40 +0,0 @@
cat << eof
Hey hackers,
this README is for you, for those who want to dig into cdist, hack it or try
to get a deeper understanding. Please read doc/man/man7/cdist-hacker.text.
I hope you have a lot of fun with cdist, because it was also a lot of fun to
develop it!
-- Nico, 20110324
## Running cdist when developing
This file is suitable for execution and saving the objects and
explorers from cdist. I usually do it like this:
% ./HACKERS_README
################################################################################
eof
set -x
# Tell the user what we do, so this script makes sense during execution
# prepare use (only from top level directory)
export PATH="$(pwd -P)/bin:$PATH"
export __cdist_conf_dir="$(pwd -P)/conf"
# Allow user to supply hostname
target="${1:-localhost}"
# And use hostname as basedir (dangerous, but hackers know what they do)
export __cdist_local_base_dir="/tmp/$target"
# Run the real script
cdist-deploy-to "$target"
# Display results
find "${__cdist_local_base_dir}"

74
README
View file

@ -15,7 +15,7 @@
"P' "" ""
[[!toc levels=2]]
[[!toc levels=3]]
## Introduction
@ -38,13 +38,13 @@ Design | Define target state, do not focus on methods or scripts
Design | Push architecture: Instantly apply your changes
Small core | cdist's core is very small - less code, less bugs
Fast development | Focus on straightforwardness of type creation is a main development objective
Modern Programming Language | cdist is written in Python
Requirements, Scalability | No central server needed, cdist operates in push mode and can be run from any computer
Requirements, Scalability, Upgrade | cdist only needs to be updated on the master, not on the target hosts
Requirements, Security | Uses well-know [SSH](http://www.openssh.com/) as transport protocol
Requirements, Simplicity | Requires only shell and SSH server on the target
UNIX | Reuse of existing tools like cat, find, mv, ...
UNIX, familar environment, documentation | Is available as manpages and HTML
UNIX, simplicity, familar environment | cdist is written in POSIX shell
UNIX, simplicity, familar environment | cdist is configured in POSIX shell
"""]]
@ -53,8 +53,6 @@ UNIX, simplicity, familar environment | cdist is configured in POSIX shell
The cdist documentation is included as manpages in the distribution.
* You can [browse the documentation of the latest version online](man) as well.
* Or you can watch the youtube **video**
[cdist installation and first usage in less than 60 seconds][http://www.youtube.com/watch?v=PRMjzy48eTI).
* Have a look at the [given speeches](speeches)
### OS support
@ -63,12 +61,14 @@ cdist was tested or is know to run on at least
* [Archlinux](http://www.archlinux.org/)
* [Debian](http://www.debian.org/)
* [CentOS](http://www.centos.org/)
* [Fedora](http://fedoraproject.org/)
* [Gentoo](http://www.gentoo.org/)
* [Mac OS X](http://www.apple.com/macosx/)
* [OpenBSD](http://www.openbsd.org)
* [Redhat](http://www.redhat.com/)
* [Ubuntu](http://www.ubuntu.com/)
* [XenServer](http://www.citrix.com/xenserver/)
## Requirements
@ -76,7 +76,9 @@ cdist was tested or is know to run on at least
### Server
* A posix like shell
* Python (>= 3.2 required)
* SSH-Client
* Asciidoc (for building the manpages)
### Client ("target host")
@ -84,21 +86,54 @@ cdist was tested or is know to run on at least
* SSH-Server
## Getting cdist
## Installation
### Preperation
Ensure you have Python 3.x and the **argparse** module installed on
the machine you use to **deploy to the targets**.
#### Archlinux
Archlinux already has python >= 3.2, so you only need to do:
pacman -S python
#### Debian
aptitude install python3 python3-setuptools
easy_install3 argparse
#### Gentoo
Gentoo only provides python 3.2 in testing packages (http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=3&chap=3).
If you want to ensure nothing breaks you must set back the python version to what was default before.
emerge -av =python-3.2.2 --autounmask-write
emerge -av =python-3.2.2
eselect python list
eselect python list set python3.2
#### Max OS X
Ensure you have port installed and configured (http://www.macports.org/install.php).
port install python32
ln -s /opt/local/bin/python3.2 /opt/local/bin/python3
### Get cdist
You can clone cdist from git, which gives you the advantage of having
a version control in place for development of your own stuff as well.
### Installation
To install cdist, execute the following commands:
git clone git://git.schottelius.org/cdist
cd cdist
export PATH=$PATH:$(pwd -P)/bin
# If you want the manpages (requires gmake and asciidoc to be installed)
./build.sh man
# If you want the manpages
./build man
export MANPATH=$MANPATH:$(pwd -P)/doc/man
@ -109,11 +144,12 @@ how to use cdist.
There are at least the following branches available:
* master: the development branch
* 1.7: Bugfixes, cleanups, new type and explorer rename
* Development: master
* 2.0: Python rewrite of cdist core
Old versions:
* 1.7: Bugfixes, cleanups, new type and explorer rename
* 1.6: New types, cleaned up \_\_package* types, internal cleanup
* 1.5: Focus on object orientation instead of global stage orientation
* 1.4: Support for redefiniton of objects (if equal)
@ -129,13 +165,13 @@ may vanish at any point. To select a specific branch use
git checkout -b <name> origin/<name>
# Stay on a specific version
version=1.7
version=2.0
git checkout -b $version origin/$version
### Mirrors
* git://github.com/telmich/cdist.git ([github](https://github.com/telmich/cdist))
* git://git.sans.ethz.ch/cdist ([sans](http://git.sans.ethz.ch/?p=cdist;a=summary))
* git://git.code.sf.net/p/cdist/code ([sourceforge](https://sourceforge.net/p/cdist/code))
## Update
@ -144,13 +180,21 @@ To upgrade cdist in the current branch use
git pull
# Also update the manpages
./build.sh man
./build man
export MANPATH=$MANPATH:$(pwd -P)/doc/man
If you stay on a version branche (i.e. 1.0, 1.1., ...), nothing should break.
The master branch on the other hand is the development branch and may not be
working, break your setup or eat the tree in your garden.
### Upgrading from 1.7 to 2.0
* Ensure python (>= 3.2) is installed on the server
* Use "cdist config host" instead of "cdist-deploy-to host"
* Use "cdist config -p host1 host2" instead of "cdist-mass-deploy"
* Use "cdist banner" for fun
* Use **\_\_object_fq** instead of **\_\_self** in manifests
### Upgrading from 1.6 to 1.7
* If you used the global explorer **hardware_type**, you need to change

234
bin/cdist Executable file
View file

@ -0,0 +1,234 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
def commandline():
"""Parse command line"""
import argparse
import cdist.banner
import cdist.config
import cdist.install
# Construct parser others can reuse
parser = {}
# Options _all_ parsers have in common
parser['loglevel'] = argparse.ArgumentParser(add_help=False)
parser['loglevel'].add_argument('-d', '--debug',
help='Set log level to debug', action='store_true',
default=False)
parser['loglevel'].add_argument('-v', '--verbose',
help='Set log level to info, be more verbose',
action='store_true', default=False)
# Main subcommand parser
parser['main'] = argparse.ArgumentParser(description='cdist ' + cdist.VERSION,
parents=[parser['loglevel']])
parser['main'].add_argument('-V', '--version',
help='Show version', action='version',
version='%(prog)s ' + cdist.VERSION)
parser['sub'] = parser['main'].add_subparsers(title="Commands")
# Banner
parser['banner'] = parser['sub'].add_parser('banner',
parents=[parser['loglevel']])
parser['banner'].set_defaults(func=cdist.banner.banner)
# Config and install (common stuff)
parser['configinstall'] = argparse.ArgumentParser(add_help=False)
parser['configinstall'].add_argument('host', nargs='+',
help='one or more hosts to operate on')
parser['configinstall'].add_argument('-c', '--cdist-home',
help='Change cdist home (default: .. from bin directory)',
action='store')
parser['configinstall'].add_argument('-i', '--initial-manifest',
help='Path to a cdist manifest or \'-\' to read from stdin.',
dest='manifest', required=False)
parser['configinstall'].add_argument('-p', '--parallel',
help='Operate on multiple hosts in parallel',
action='store_true', dest='parallel')
parser['configinstall'].add_argument('-s', '--sequential',
help='Operate on multiple hosts sequentially (default)',
action='store_false', dest='parallel')
# Config
parser['config'] = parser['sub'].add_parser('config',
parents=[parser['loglevel'], parser['configinstall']])
parser['config'].set_defaults(func=config)
# Install
parser['install'] = parser['sub'].add_parser('install',
parents=[parser['loglevel'], parser['configinstall']])
parser['install'].set_defaults(func=install)
for p in parser:
parser[p].epilog = "Get cdist at http://www.nico.schottelius.org/software/cdist/"
args = parser['main'].parse_args(sys.argv[1:])
# Loglevels are handled globally in here and debug wins over verbose
if args.verbose:
logging.root.setLevel(logging.INFO)
if args.debug:
logging.root.setLevel(logging.DEBUG)
log.debug(args)
args.func(args)
def config(args):
configinstall(args, mode=cdist.config.Config)
def install(args):
configinstall(args, mode=cdist.install.Install)
def configinstall(args, mode):
"""Configure or install remote system"""
import multiprocessing
import time
initial_manifest_tempfile = None
if args.manifest == '-':
# read initial manifest from stdin
import tempfile
handle, initial_manifest_temp_path = tempfile.mkstemp(prefix='cdist.stdin.')
with os.fdopen(handle, 'w') as fd:
fd.write(sys.stdin.read())
args.manifest = initial_manifest_temp_path
import atexit
atexit.register(lambda: os.remove(initial_manifest_temp_path))
try:
process = {}
failed_hosts = []
time_start = time.time()
for host in args.host:
if args.parallel:
log.debug("Creating child process for %s", host)
process[host] = multiprocessing.Process(target=configinstall_onehost, args=(host, args, mode, True))
process[host].start()
else:
if not configinstall_onehost(host, args, mode, parallel=False):
failed_hosts.append(host)
if args.parallel:
for p in process.keys():
log.debug("Joining process %s", p)
process[p].join()
if not process[p].exitcode == 0:
failed_hosts.append(p)
if len(failed_hosts) > 0:
log.warn("Failed to deploy to the following hosts: " +
" ".join(failed_hosts))
time_end = time.time()
log.info("Total processing time for %s host(s): %s", len(args.host),
(time_end - time_start))
except KeyboardInterrupt:
if args.parallel:
for p in process.keys():
# NOT needed: KeyBoardInterrupet (aka SIGINT)
# is forwarded to processes spawned by multiprocess!
# pid = process[p].pid.__str__()
#log.warn("Terminating deploy " + p + " (" + pid + ")")
# process[p].terminate()
pass
sys.exit(0)
def configinstall_onehost(host, args, mode, parallel):
"""Configure or install ONE remote system"""
try:
import cdist.context
context = cdist.context.Context(
target_host=host,
initial_manifest=args.manifest,
base_path=args.cdist_home,
exec_path=sys.argv[0],
debug=args.debug)
c = mode(context)
c.deploy_and_cleanup()
context.cleanup()
except cdist.Error as e:
log.error(e)
return False
except KeyboardInterrupt:
# Do not care in sequential mode, catch in parallel mode
if not parallel:
raise
else:
# Catch here, above does not need to know about our errors
return False
return True
def emulator():
"""Prepare and run emulator"""
try:
import cdist.emulator
emulator = cdist.emulator.Emulator(sys.argv)
emulator.run()
except cdist.Error as e:
log.error(e)
sys.exit(1)
if __name__ == "__main__":
try:
import logging
import os
import re
import sys
cdistpythonversion = '3.2'
if sys.version < cdistpythonversion:
print('Cdist requires Python >= ' + cdistpythonversion +
' on the source host.')
sys.exit(1)
# Ensure our /lib/ is included into PYTHON_PATH
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), '../lib')))
# And now import our stuff
import cdist
log = logging.getLogger("cdist")
logging.basicConfig(format='%(levelname)s: %(message)s')
if re.match("__", os.path.basename(sys.argv[0])):
emulator()
else:
commandline()
except KeyboardInterrupt:
sys.exit(0)
sys.exit(0)

View file

@ -1,50 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# This binary is executed on the remote side to execute code
#
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<object> <type>"
set -ue
__cdist_object_self="$1"; shift
__cdist_code_type="$1"; shift
if [ ! -d "$(__cdist_object_dir "$__cdist_object_self")" ]; then
__cdist_exit_err "Object undefined"
fi
__cdist_code="$(__cdist_object_code "$__cdist_object_self" "${__cdist_code_type}")"
__cdist_echo info "Checking code-${__cdist_code_type}"
if [ -e "$__cdist_code" ]; then
if [ -f "$__cdist_code" ]; then
if [ -x "$__cdist_code" ]; then
__cdist_echo info "Executing code-${__cdist_code_type}"
__cdist_exec_fail_on_error "$__cdist_code"
else
__cdist_exit_err "$__cdist_code exists, but is not executable."
fi
else
__cdist_exit_err "$__cdist_code exists, but is not a file."
fi
fi

View file

@ -1,438 +0,0 @@
#!/bin/sh
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
__cdist_version="1.7.0"
# Fail if something bogus is going on
set -u
################################################################################
# cconf standard vars prefixed with cdist
__cdist_pwd="$(pwd -P)"
__cdist_mydir="${0%/*}";
__cdist_abs_mydir="$(cd "$__cdist_mydir" && pwd -P)"
__cdist_myname=${0##*/};
__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname"
################################################################################
# Names / Constants
#
# Most values can be overriden from outside, so you can
# customise paths as you like (for distributors, geeks and hackers)
#
: ${__cdist_name_bin:=bin}
: ${__cdist_name_cache:=cache}
: ${__cdist_name_code:=code}
: ${__cdist_name_conf_dir:=conf}
: ${__cdist_name_dot_cdist:=.cdist}
: ${__cdist_name_explorer:=explorer}
: ${__cdist_name_gencode:=gencode}
: ${__cdist_name_gencode_local:=local}
: ${__cdist_name_gencode_remote:=remote}
: ${__cdist_name_global:=global}
: ${__cdist_name_host:=host}
: ${__cdist_name_init:=init}
: ${__cdist_name_manifest:=manifest}
: ${__cdist_name_object:=object}
: ${__cdist_name_object_finished:=done}
: ${__cdist_name_object_prepared:=prepared}
: ${__cdist_name_object_id:=object_id}
: ${__cdist_name_object_source:=source}
: ${__cdist_name_objects_created:=.objects_created}
: ${__cdist_name_out_dir:=out}
: ${__cdist_name_parameter:=parameter}
: ${__cdist_name_parameter_required:=required}
: ${__cdist_name_parameter_optional:=optional}
: ${__cdist_name_require:=require}
: ${__cdist_name_self:=self}
: ${__cdist_name_singleton:=singleton}
: ${__cdist_name_target_host:=target_host}
: ${__cdist_name_target_user:=target_user}
: ${__cdist_name_type:=type}
: ${__cdist_name_type_bin:=type_bin}
: ${__cdist_name_type_explorer:=type_explorer}
: ${__cdist_name_type_explorer_pushed:=.explorer_pushed}
# Used for IDs: Allow everything not starting with - and .
: ${__cdist_sane_regexp:=[^-\.].*}
# Default remote user
: ${__cdist_remote_user:=root}
################################################################################
# Exported variable names (usable for non core
#
: ${__cdist_name_var_explorer:=__$__cdist_name_explorer}
: ${__cdist_name_var_type_explorer:=__$__cdist_name_type_explorer}
: ${__cdist_name_var_global:=__$__cdist_name_global}
: ${__cdist_name_var_manifest:=__$__cdist_name_manifest}
: ${__cdist_name_var_target_host:=__$__cdist_name_target_host}
: ${__cdist_name_var_target_user:=__$__cdist_name_target_user}
: ${__cdist_name_var_object:=__$__cdist_name_object}
: ${__cdist_name_var_object_id:=__$__cdist_name_object_id}
: ${__cdist_name_var_self:=__$__cdist_name_self}
: ${__cdist_name_var_type:=__$__cdist_name_type}
################################################################################
# Tempfiles
#
: ${__cdist_tmp_base_dir=/tmp}
__cdist_tmp_dir=$(mktemp -d "$__cdist_tmp_base_dir/cdist.XXXXXXXXXXXX")
__cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX")
################################################################################
# Local Base
#
: ${__cdist_local_base_dir:=$__cdist_tmp_dir}
# Cache may *NOT* be below __cdist_local_base_dir!
: ${__cdist_local_base_cache_dir:=$__cdist_abs_mydir/../$__cdist_name_cache}
: ${__cdist_conf_dir:="$(cd "$__cdist_abs_mydir/../conf" && pwd -P)"}
: ${__cdist_explorer_dir:=$__cdist_conf_dir/$__cdist_name_explorer}
: ${__cdist_manifest_dir:=$__cdist_conf_dir/$__cdist_name_manifest}
: ${__cdist_manifest_init:=$__cdist_manifest_dir/$__cdist_name_init}
: ${__cdist_type_dir:=$__cdist_conf_dir/$__cdist_name_type}
################################################################################
# Local output
#
: ${__cdist_out_dir:=$__cdist_local_base_dir/$__cdist_name_out_dir}
: ${__cdist_out_explorer_dir:=$__cdist_out_dir/$__cdist_name_explorer}
: ${__cdist_out_object_dir:=$__cdist_out_dir/$__cdist_name_object}
: ${__cdist_out_type_dir:=$__cdist_out_dir/$__cdist_name_type}
: ${__cdist_out_type_bin_dir:=$__cdist_out_dir/$__cdist_name_type_bin}
: ${__cdist_objects_created:=$__cdist_out_object_dir/$__cdist_name_objects_created}
################################################################################
# Remote base
#
: ${__cdist_remote_base_dir:=/var/lib/cdist}
: ${__cdist_remote_bin_dir:=$__cdist_remote_base_dir/$__cdist_name_bin}
: ${__cdist_remote_conf_dir:=$__cdist_remote_base_dir/$__cdist_name_conf_dir}
: ${__cdist_remote_explorer_dir:=$__cdist_remote_conf_dir/$__cdist_name_explorer}
: ${__cdist_remote_type_dir:=$__cdist_remote_conf_dir/$__cdist_name_type}
################################################################################
# Remote output
#
: ${__cdist_remote_out_dir:=$__cdist_remote_base_dir/$__cdist_name_out_dir}
: ${__cdist_remote_out_explorer_dir:=$__cdist_remote_out_dir/$__cdist_name_explorer}
: ${__cdist_remote_out_object_dir:=$__cdist_remote_out_dir/$__cdist_name_object}
################################################################################
# Internal functions
#
__cdist_echo()
{
__cdist_echo_type="$1"; shift
set +u
if [ "$__cdist_object_self" ]; then
__cdist_echo_prefix="${__cdist_object_self}:"
else
__cdist_echo_prefix="core: "
fi
set -u
case "$__cdist_echo_type" in
debug)
set +u
if [ "$__cdist_debug" ]; then
echo $__cdist_echo_prefix "Debug: $@"
fi
set -u
;;
info)
echo $__cdist_echo_prefix "$@"
;;
warn)
echo $__cdist_echo_prefix "Warning: $@"
;;
error)
echo $__cdist_echo_prefix "Error: $@" >&2
;;
*)
echo "CORE BUG, who created the broken commit in $0?" >&2
exit 23
;;
esac
}
__cdist_exec_fail_on_error()
{
set +e
sh -e "$@"
if [ "$?" -ne 0 ]; then
__cdist_echo error "$1 exited non-zero"
__cdist_echo warn "Faulty code:"
cat "$1"
__cdist_exit_err "Aborting due to non-zero exit code."
fi
}
__cdist_exit_err()
{
__cdist_echo error "$@"
exit 1
}
__cdist_usage()
{
__cdist_exit_err "$__cdist_myname: $@"
}
__cdist_init_deploy()
{
__cdist_echo info "Creating clean directory structure "
# Ensure there is no old stuff, neither local nor remote
rm -rf "$__cdist_local_base_dir"
ssh "${__cdist_remote_user}@$1" "rm -rf ${__cdist_remote_base_dir}"
# Init base
mkdir -p "$__cdist_local_base_dir"
ssh "${__cdist_remote_user}@$1" "mkdir -p ${__cdist_remote_base_dir}"
# Link configuration source directory - consistent with remote
ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir"
}
################################################################################
# Cache
#
__cdist_cache_dir()
{
cd "${__cdist_local_base_cache_dir}" && pwd -P
}
__cdist_host_cache_dir()
{
echo "$(__cdist_cache_dir)/$1"
}
################################################################################
# Object
#
__cdist_object_code()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_code}-$2"
}
__cdist_object_prepared()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_object_prepared}"
}
__cdist_object_finished()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_object_finished}"
}
__cdist_object_dir()
{
echo "$(__cdist_object_base_dir "$1")/${__cdist_name_dot_cdist}"
}
__cdist_object_base_dir()
{
echo "${__cdist_out_object_dir}/$1"
}
__cdist_object_id_from_object()
{
echo "${1#*/}"
}
# Find objects, remove ./ and /MARKER
__cdist_object_list()
{
local basedir="$1"; shift
# Use subshell to prevent changing cwd in program
(
cd "${basedir}"
find . -name "$__cdist_name_dot_cdist" | \
sed -e 's;^./;;' -e "s;/${__cdist_name_dot_cdist}\$;;"
)
}
__cdist_object_parameter_dir()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_parameter}"
}
__cdist_object_require()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_require}"
}
__cdist_object_source_name()
{
echo "$1/${__cdist_name_object_source}"
}
__cdist_object_source()
{
cat "$(__cdist_object_source_name "$1")"
}
__cdist_object_source_add()
{
echo "$__cdist_manifest" >> "$(__cdist_object_source_name "$1")"
}
__cdist_object_type_explorer_dir()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_explorer}"
}
################################################################################
# Remote
#
__cdist_remote_object_base_dir()
{
echo "${__cdist_remote_out_object_dir}/$1"
}
__cdist_remote_object_dir()
{
echo "$(__cdist_remote_object_base_dir "$1")/${__cdist_name_dot_cdist}"
}
__cdist_remote_object_parameter_dir()
{
echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_parameter}"
}
__cdist_remote_object_type_explorer_dir()
{
echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_explorer}"
}
__cdist_remote_type_explorer_dir()
{
echo "${__cdist_remote_type_dir}/$1/${__cdist_name_explorer}"
}
################################################################################
# Traps
#
__cdist_tmp_removal()
{
rm -rf "${__cdist_tmp_dir}"
}
# Does not work in children, will be called again in every script!
# Use only in interactive "front end" scripts
__cdist_kill_on_interrupt()
{
__cdist_tmp_removal
kill 0
exit 1
}
# Remove tempfiles at normal exit
trap __cdist_tmp_removal EXIT
################################################################################
# Type
#
__cdist_type_dir()
{
echo "${__cdist_type_dir}/$1"
}
__cdist_type_explorer_dir()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_explorer}"
}
__cdist_type_from_object()
{
echo "${1%%/*}"
}
__cdist_type_has_explorer()
{
# We only create output, if there's at least one explorer
# and can thus be used as a boolean ;-)
if [ -d "$(__cdist_type_explorer_dir "$1")" ]; then
ls -1 "$(__cdist_type_explorer_dir "$1")"
fi
}
__cdist_type_explorer_pushed()
{
[ -f "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}" ] \
&& grep -x -q "$1" "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}"
}
__cdist_type_explorer_pushed_add()
{
[ -d "$__cdist_out_type_dir" ] || mkdir "$__cdist_out_type_dir"
echo "$1" >> "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}"
}
__cdist_type_gencode()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}-$2"
}
__cdist_type_manifest()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_manifest}"
}
__cdist_type_parameter_dir()
{
echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}"
}
__cdist_type_parameter_optional()
{
echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_optional"
}
__cdist_type_parameter_required()
{
echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_required"
}
__cdist_type_singleton()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_singleton}"
}

View file

@ -1,59 +0,0 @@
#!/bin/sh
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Deploy configuration to a host
#
. cdist-config
[ $# -eq 1 ] || __cdist_usage "<target host>"
set -eu
# Kill children on interrupt - only in interactive scripts
trap __cdist_kill_on_interrupt INT TERM
__cdist_target_host="$1"
# Make target host available for non-core
export $__cdist_name_var_target_host="$__cdist_target_host"
export $__cdist_name_var_target_user="$__cdist_remote_user"
# Export variables for core, which others do not reset
export __cdist_local_base_dir
__cdist_echo info "cdist $__cdist_version: Configuring $__cdist_target_host "
################################################################################
# See cdist-stages(7)
#
# Prepare local and remote directories
__cdist_init_deploy "$__cdist_target_host"
# Transfer cdist executables
__cdist_echo info "Transferring cdist binaries to the target host "
cdist-dir push "$__cdist_target_host" \
"${__cdist_abs_mydir}" "${__cdist_remote_bin_dir}"
cdist-explorer-run-global "$__cdist_target_host"
cdist-manifest-run-init "$__cdist_target_host"
cdist-object-all "$__cdist_target_host" cdist-object-prepare
cdist-object-all "$__cdist_target_host" cdist-object-run
cdist-cache "$__cdist_target_host"
__cdist_echo info "cdist $__cdist_version: Successfully finished run"

View file

@ -1,51 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Push a directory to a target, both sides have the same name (i.e. explorers)
# or
# Pull a directory from a target, both sides have the same name (i.e. explorers)
#
. cdist-config
[ $# -eq 4 ] || __cdist_usage "<push|pull> <target host> <src dir> <dst dir>"
set -ue
__cdist_action="$1"; shift
__cdist_target_host="$1"; shift
__cdist_src_dir="$1"; shift
__cdist_dst_dir="$1"; shift
# This will be the destination directory, so no subdirectories
# of the same name are created, if the directory is already existing
__cdist_top_dir="${__cdist_dst_dir%/*}"
if [ "$__cdist_action" = "push" ]; then
ssh "${__cdist_remote_user}@${__cdist_target_host}" \
"mkdir -p \"${__cdist_dst_dir}\""
scp -qr "$__cdist_src_dir" \
"${__cdist_remote_user}@${__cdist_target_host}:${__cdist_top_dir}"
elif [ "$__cdist_action" = "pull" ]; then
mkdir -p "${__cdist_dst_dir}"
scp -qr "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_src_dir}" \
"${__cdist_top_dir}"
else
__cdist_exit_err "Unknown action $__cdist_action"
fi

View file

@ -1,43 +0,0 @@
#!/bin/sh
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Copy & run the global explorers, i.e. not bound to types
#
. cdist-config
[ $# -eq 1 ] || __cdist_usage "<target_host>"
set -ue
__cdist_target_host="$1"; shift
__cdist_echo info "Running global explorers "
# copy the explorers
cdist-dir push "$__cdist_target_host" \
"${__cdist_explorer_dir}" "${__cdist_remote_explorer_dir}"
# run the initial explorers remotely
cdist-run-remote "${__cdist_target_host}" cdist-remote-explorer-run \
"$__cdist_name_var_explorer" "$__cdist_remote_explorer_dir" \
"$__cdist_remote_out_explorer_dir"
# retrieve the results
cdist-dir pull "$__cdist_target_host" \
"${__cdist_remote_out_explorer_dir}" "${__cdist_out_explorer_dir}"

View file

@ -1,56 +0,0 @@
#!/bin/sh
#
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Let's build a cconfig tree from a configuration
# And save it into the cache tree
#
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <manifest>"
set -u
__cdist_target_host="$1"; shift
__cdist_manifest="$1"; shift
################################################################################
# Export information for cdist-type-emulator or manifest
#
# Config dir should not get reset - FIXME: why did I do this?
export __cdist_conf_dir
# Used to record the source in the object
export __cdist_manifest
# Export information for manifests - __cdist_out_dir comes from cdist-config
export __global="$__cdist_out_dir"
################################################################################
# The actual run
#
# Ensure binaries exist and are up-to-date
cdist-type-build-emulation "${__cdist_out_type_bin_dir}" \
|| __cdist_exit_err "Failed to build type emulation binaries"
# prepend our path, so all cdist tools come before other tools
export PATH="${__cdist_out_type_bin_dir}:$PATH"
__cdist_exec_fail_on_error "${__cdist_manifest}"

View file

@ -1,75 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Deploy configuration to many hosts
#
. cdist-config
[ $# -ge 1 ] || __cdist_usage "[-p] <target host> [target host ]"
set -u
# Kill children on interrupt - only in interactive scripts
trap __cdist_kill_on_interrupt INT TERM
filter()
{
awk -v host=$1 '{ print "[" host "] " $0 }'
}
parallel=""
if [ "$1" = "-p" ]; then
parallel=yes
shift
fi
i=0
while [ $# -gt 0 ]; do
if [ "$parallel" ]; then
cdist-deploy-to "$1" | filter "$1" &
# Record pid and host for use later
i=$((i+1))
eval pid_$i=$!
eval host_$i=\$1
else
cdist-deploy-to "$1" | filter "$1"
fi
shift
done
e=0
if [ "$parallel" ]; then
__cdist_echo info "Waiting for cdist-deploy-to jobs to finish"
while [ "$i" -gt 0 ]; do
eval pid=\$pid_$i
wait "$pid"
if [ $? -ne 0 ]; then
e=$((e+1))
eval e_host_$e=\$host_$i
fi
i=$((i-1))
done
fi
# Display all failed hosts after all runs are done, so the sysadmin gets them
while [ "$e" -gt 0 ]; do
eval host=\$host_$e
__cdist_echo error "Configuration of host $host failed."
e=$((e-1))
done

View file

@ -1,56 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
# Run the given command for each created object.
#
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <command>"
set -eu
__cdist_target_host="$1"; shift
__cdist_command="$1"; shift
__cdist_objects="$__cdist_tmp_dir/objects"
# Ensure object dir exists, so marker can be created
mkdir -p "${__cdist_out_object_dir}"
# Loop until we do not create new objects anymore
# which is equal to all objects have been run
touch "$__cdist_objects_created"
while [ -f "$__cdist_objects_created" ]; do
# Assume we're done after this run
rm "$__cdist_objects_created"
# Get listing of objects
__cdist_object_list "$__cdist_out_object_dir" > "$__cdist_objects"
# NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP
while read __cdist_object; do
set -- "$@" "$__cdist_object"
done < "$__cdist_objects"
while [ $# -gt 0 ]; do
__cdist_object="$1"; shift
$__cdist_command "$__cdist_target_host" "$__cdist_object"
done
done

View file

@ -1,67 +0,0 @@
#!/bin/sh
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
# Run the explorers for the given object on the target host.
#
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
set -eu
__cdist_target_host="$1"; shift
__cdist_object_self="$1"; shift
__cdist_object_id="$(__cdist_object_id_from_object "$__cdist_object_self")"
__cdist_type="$(__cdist_type_from_object "$__cdist_object_self")"
# Check if type of object has >= 1 explorer
__cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")"
# Run the type explorers for the current object if any
if [ "$__cdist_has_explorer" ]; then
if ! __cdist_type_explorer_pushed "$__cdist_type"; then
src_dir="$(__cdist_type_explorer_dir "$__cdist_type")"
dst_dir="$(__cdist_remote_type_explorer_dir "$__cdist_type")"
__cdist_echo info "Transfering explorers for $__cdist_type "
cdist-dir push "$__cdist_target_host" "$src_dir" "$dst_dir"
__cdist_type_explorer_pushed_add "$__cdist_type"
fi
__cdist_echo info "Running explorers"
# Copy object parameters
cdist-dir push "$__cdist_target_host" \
"$(__cdist_object_parameter_dir "$__cdist_object_self")" \
"$(__cdist_remote_object_parameter_dir "$__cdist_object_self")"
# Execute explorers
cdist-run-remote "$__cdist_target_host" \
"$__cdist_name_var_object=\"$(__cdist_remote_object_dir "$__cdist_object_self")\"" \
"$__cdist_name_var_object_id=\"$__cdist_object_id\"" \
"$__cdist_name_var_self=\"$__cdist_object_self\"" \
cdist-remote-explorer-run \
"$__cdist_name_var_type_explorer" \
"$(__cdist_remote_type_explorer_dir "$__cdist_type")" \
"$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")"
# Copy back results
cdist-dir pull "$__cdist_target_host" \
"$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")" \
"$(__cdist_object_type_explorer_dir "$__cdist_object_self")"
fi

View file

@ -1,62 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Generate code from one object (object must be relative path!)
# WARNING: OUTPUT ON STDOUT, ERRORS NEED TO BE ON STDERR!
#
. cdist-config
[ $# -eq 3 ] || __cdist_usage "<target host>" "<object>" "<type>"
set -eu
__cdist_target_host="$1"; shift
__cdist_object_self="$1"; shift
__cdist_gencode_type="$1"; shift
__cdist_type="$(__cdist_type_from_object "$__cdist_object_self")"
__cdist_type_gencode="$(__cdist_type_gencode "$__cdist_type" "$__cdist_gencode_type")"
__cdist_code_output="$(__cdist_object_code "$__cdist_object_self" "$__cdist_gencode_type")"
# export variables for the gencode script
export __object_id="$(__cdist_object_id_from_object "$__cdist_object_self")"
export __object="$(__cdist_object_dir "$__cdist_object_self")"
export __global="$__cdist_out_dir"
if [ -x "$__cdist_type_gencode" ]; then
__cdist_exec_fail_on_error "$__cdist_type_gencode" > "$__cdist_tmp_file"
else
if [ -e "$__cdist_type_gencode" ]; then
__cdist_exit_err "$__cdist_type_gencode exists, but is not executable"
fi
# Ensure it's empty, if there is no gencode
: > "$__cdist_tmp_file"
fi
# Only create code, if gencode created output
if [ "$(wc -l < "$__cdist_tmp_file")" -gt 0 ]; then
cat - "$__cdist_tmp_file" << eof > "$__cdist_code_output"
#
# The following code was generated by $__cdist_type_gencode
#
eof
chmod u+x "${__cdist_code_output}"
fi

View file

@ -1,58 +0,0 @@
#!/bin/sh
#
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
# Run the manifest for the given object.
#
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
set -eu
__cdist_target_host="$1"; shift
__cdist_object_self="$1"; shift
# FIXME: rename to __cdist_object_dir (everywhere!)
__cdist_cur_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
__cdist_object_id="$(__cdist_object_id_from_object "$__cdist_object_self")"
__cdist_echo info "Checking manifest "
__cdist_type="$(__cdist_type_from_object "$__cdist_object_self")"
__cdist_manifest="$(__cdist_type_manifest "$__cdist_type")"
if [ -f "$__cdist_manifest" ]; then
if [ -x "$__cdist_manifest" ]; then
# Make __cdist_manifest available for cdist-type-emulator
export __cdist_manifest
__cdist_echo info "Executing manifest "
export $__cdist_name_var_object="$__cdist_cur_object_dir"
export $__cdist_name_var_object_id="$__cdist_object_id"
export $__cdist_name_var_type="$(__cdist_type_dir "$__cdist_type")"
cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest"
# Tell cdist-object-run-all that there may be new objects
touch "$__cdist_objects_created"
else
__cdist_exit_err "${__cdist_manifest} needs to be executable."
fi
fi

View file

@ -1,47 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
# For the given object:
# - run type explorers
# - run type manifest
#
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
set -eu
__cdist_target_host="$1"; shift
__cdist_object_self="$1"; shift
__cdist_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
[ -d "$__cdist_object_dir" ] || __cdist_exit_err "Object undefined"
# Export to non-core for use in manifest and gencode scripts
export $__cdist_name_var_self=$__cdist_object_self
__cdist_object_prepared="$(__cdist_object_prepared "$__cdist_object_self")"
if [ ! -f "$__cdist_object_prepared" ]; then
__cdist_echo info "Preparing object"
cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object_self"
cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object_self"
# Mark this object as prepared
touch "$__cdist_object_prepared"
fi

View file

@ -1,65 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
# For the given object:
# - run type explorers
# - run type manifest
# - generate code
# - copy object to target
# - execute code on target
#
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
set -eu
__cdist_target_host="$1"; shift
__cdist_object_self="$1"; shift
__cdist_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
[ -d "$__cdist_object_dir" ] || __cdist_exit_err "Object undefined"
# Export to non-core for use in manifest and gencode scripts
export $__cdist_name_var_self=$__cdist_object_self
__cdist_object_finished="$(__cdist_object_finished "$__cdist_object_self")"
if [ ! -f "$__cdist_object_finished" ]; then
# Resolve dependencies, if any
__cdist_object_require="$(__cdist_object_require "$__cdist_object_self")"
if [ -f "$__cdist_object_require" ]; then
# NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP
while read __cdist_requirement; do
set -- "$@" "$__cdist_requirement"
done < "$__cdist_object_require"
while [ $# -gt 0 ]; do
__cdist_requirement="$1"; shift
__cdist_echo info "Resolving requirement $__cdist_requirement"
cdist-object-run "$__cdist_target_host" "$__cdist_requirement"
done
fi
cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object_self"
cdist-object-push "$__cdist_target_host" "$__cdist_object_self"
cdist-object-code-run "$__cdist_target_host" "$__cdist_object_self"
# Mark this object as done
touch "$__cdist_object_finished"
fi

View file

@ -1,310 +0,0 @@
#!/bin/sh
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Give the user an introduction into cdist
#
. cdist-config
set -eu
banner="cdist-quickstart>"
continue="Press enter to continue or ctrl-c to abort."
create_continue="Press enter to create the described files/directories"
__prompt()
{
echo -n "$banner" "$@"
read answer
}
################################################################################
# Intro of quickstart
#
cat << eof
$banner cdist version $__cdist_version
Welcome to the interactive guide to cdist!
This is the interactive tutorial and beginners help for cdist and here's
our schedule:
- Stages: How cdist operates
- Explorer: Explore facts of the target host
- Manifest: Map configurations to hosts
- Types: Bundled functionality
- Deploy a configuration to the local host!
eof
__prompt "$continue"
################################################################################
# Stages
#
cat << eof
To deploy configurations to a host, you call
cdist-deploy-to <hostname>
which makes calls to other scripts, which realise the so called "stages".
Usually you'll not notice this, but in case you want to debug or hack cdist,
you can run each stage on its own. Besides that, you just need to remember
that the command cdist-deploy-to is the main cdist command.
See also:
Source of cdist-deploy-to(1), cdist-stages(7)
eof
__prompt "$continue"
################################################################################
# Explorer
#
cat << eof
The first thing cdist always does is running different explorers on the
target host. The explorers can be found in the directory
${__cdist_explorer_dir}
An explorer is executed on the target host and its output is saved to a file.
You can use these files later to decide what or how to configure the host.
For a demonstration, we'll call the OS explorer locally now, but remember:
This is only for demonstration, normally it is run on the target host.
The os explorer will which either displays the detected operating system or
nothing if it does not know your OS.
See also:
cdist-explorer(7)
eof
explorer="${__cdist_explorer_dir}/os"
__prompt "Press enter to execute $explorer"
set -x
"$explorer"
set +x
################################################################################
# Manifest
#
cat << eof
The initial manifest is the entry point for cdist to find out, what you would
like to have configured. It is located at
${__cdist_manifest_init}
And can be as simple as
--------------------------------------------------------------------------------
__file /etc/cdist-configured --type file
--------------------------------------------------------------------------------
See also:
cdist-manifest(7)
eof
__prompt "$continue"
cat << eof
Let's take a deeper look at the initial manifest to understand what it means:
__file /etc/cdist-configured --type file
| | | \\
| | The parameter type \\ With the value file
| |
| |
| | This is the object id
|
__file is a so called "type"
This essentially looks like a standard command executed in the shell.
eof
__prompt "$continue"
cat << eof
And that's exactly true. Manifests are shell snippets that can use
types as commands with arguments. cdist prepends a special path
that contain links to the cdist-type-emulator, to \$PATH, so you
can use your types as a command.
This is also the reason why types should always be prefixed with
"__", to prevent collisions with existing binaries.
The object id is unique per type and used to prevent you from creating
the same object twice.
Parameters are type specific and are always specified as --parameter <value>.
See also:
cdist-type-build-emulation(1), cdist-type-emulator(1)
eof
__prompt "$continue"
################################################################################
# Types
#
cat << eof
Types are bundled functionality and are the main component of cdist.
If you want to have a feature x, you write the type __x. Types are stored in
${__cdist_type_dir}
And cdist ships with some types already!
See also:
cdist-type(7)
eof
__prompt "Press enter to see available types"
set -x
ls ${__cdist_type_dir}
set +x
cat << eof
Types consist of the following parts:
- ${__cdist_name_parameter} (${__cdist_name_parameter_required}/${__cdist_name_parameter_optional}
- ${__cdist_name_manifest}
- ${__cdist_name_explorer}
- ${__cdist_name_gencode}
eof
__prompt "$continue"
cat << eof
Every type must have a directory named ${__cdist_name_parameter}, which
contains required or optional parameters (in newline seperated files).
If an object of a specific type was created in the initial manifest,
the manifest of the type is run and may create other objects.
A type may have ${__cdist_name_explorer}, which are very similar to the
${__cdist_name_explorer} seen above, but with a different purpose:
They are specific to the type and are not relevant for other types.
You may use them for instance to find out details on the target host,
so you can decide what to do on the target host eventually.
After the ${__cdist_name_manifest} and the ${__cdist_name_explorer} of
a type have been run, ${__cdist_name_gencode} is executed, which creates
code to be executed on the target on stdout.
eof
__prompt "$continue"
################################################################################
# Deployment
#
cat << eof
Now you've got some basic knowledge about cdist, let's configure your a host!
Ensure that you have a ssh server running on the host and that you can login as root.
eof
__prompt "Enter hostname or press enter for localhost: "
if [ "$answer" ]; then
host="$answer"
else
host="localhost"
fi
manifestinit="conf/manifest/init"
cat << eof
I'll know setup $manifestinit, containing the following code:
--------------------------------------------------------------------------------
# Every machine becomes a marker, so sysadmins know that automatic
# configurations are happening
__file /etc/cdist-configured
case "\$__target_host" in
$host)
__link /tmp/cdist-testfile --source /etc/cdist-configured --type symbolic
__addifnosuchline /tmp/cdist-welcome --line "Welcome to cdist"
;;
esac
--------------------------------------------------------------------------------
WARNING: This will overwrite ${manifestinit}.
eof
cat > "$__cdist_abs_mydir/../$manifestinit" << eof
# Every machine becomes a marker, so sysadmins know that automatic
# configurations are happening
__file /etc/cdist-configured
case "\$__target_host" in
$host)
__link /tmp/cdist-testfile --source /etc/cdist-configured --type symbolic
__addifnosuchline /tmp/cdist-welcome --line "Welcome to cdist"
;;
esac
eof
chmod u+x "$__cdist_abs_mydir/../$manifestinit"
cmd="cdist-deploy-to $host"
__prompt "Press enter to run \"$cmd\""
# No quotes, we need field splitting
$cmd
################################################################################
# End
#
cat << eof
--------------------------------------------------------------------------------
That's it, this is the end of the cdist-quickstart.
I hope you've got some impression on how cdist works, here are again some
pointers on where to continue to read:
cdist(7), cdist-deploy-to(1), cdist-type(7), cdist-stages(7)
eof

View file

@ -1,68 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# This binary is executed on the remote side to execute explorers
#
# It supports different variables names to be used, so __explorers
# and __type_explorers can be submitted :-)
#
. cdist-config
[ $# -eq 3 ] || __cdist_usage "<variable name> <explorer dir> <out dir>"
set -ue
# Variable that defines the home of the explorers
__cdist_variable_name="$1"; shift
# Find explorers here
__cdist_explorer_dir="$1"; shift
# Write output here
__cdist_my_out_dir="$1"; shift
# Setup environment
export $__cdist_variable_name="$__cdist_explorer_dir"
export __global="$__cdist_remote_out_dir"
mkdir -p "$__cdist_my_out_dir"
# Ensure there is at least one explorer
num="$(ls -1 "$__cdist_explorer_dir" | wc -l)"
if [ "$num" -lt 1 ]; then
__cdist_exit_err "${__cdist_explorer_dir}: Contains no explorers"
fi
# Execute all explorers
for explorer in "$__cdist_explorer_dir/"*; do
explorer_name="${explorer##*/}"
if [ -f "$explorer" ]; then
if [ ! -x "$explorer" ]; then
__cdist_exit_err "Explorer \"$explorer\" exists, but is not executable."
fi
# Execute explorers and save results in remote destination directory
"$explorer" > "${__cdist_my_out_dir}/$explorer_name"
else
if [ -e "$explorer" ]; then
__cdist_exit_err "Explorer \"$explorer\" exists, but is not a file."
fi
fi
done

View file

@ -1,43 +0,0 @@
#!/bin/sh
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
# Build pseudo binaries for type emulation
#
. cdist-config
[ $# -eq 1 ] || __cdist_usage "<out dir>"
set -eu
__cdist_output_dir="$1"; shift
__cdist_type_emulator="$__cdist_abs_mydir/cdist-type-emulator"
if [ ! -d "${__cdist_type_dir}" ]; then
__cdist_exit_err "$__cdist_type_dir must exist and contain available types"
fi
# Get Types
cd "${__cdist_type_dir}"
ls -1 > "${__cdist_tmp_file}"
# Create binaries
mkdir -p "${__cdist_output_dir}"
while read type; do
ln -sf "${__cdist_type_emulator}" "${__cdist_output_dir}/${type}"
done < "${__cdist_tmp_file}"

View file

@ -1,182 +0,0 @@
#!/bin/sh
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Wrapper script that generates cconfig from arguments
#
# This script will be called everytime the manifest decides to create
# a new type
#
. cdist-config
set -u
################################################################################
# Prepare object and type
#
__cdist_type="$__cdist_myname"
# Find out whether type is a singleton or regular type
if [ -f "$(__cdist_type_singleton "$__cdist_type")" ]; then
__cdist_object_id="$__cdist_name_singleton"
else
[ $# -ge 1 ] || __cdist_usage "<id> <options>"
__cdist_object_id="$1"; shift
fi
# Verify object id
__cdist_object_id_sane=$(echo "$__cdist_object_id" | grep "^${__cdist_sane_regexp}\$")
if [ -z "$__cdist_object_id_sane" ]; then
__cdist_usage "Insane object id, ${__cdist_object_id}."
fi
# Prevent double slash if id begins with /
if [ "$(echo $__cdist_object_id | grep "^/")" ]; then
__cdist_object_self="${__cdist_type}${__cdist_object_id}"
else
__cdist_object_self="${__cdist_type}/${__cdist_object_id}"
fi
################################################################################
# Internal quirks
#
# Append id for error messages
__cdist_myname="$__cdist_myname ($__cdist_object_id)"
################################################################################
# Create object in tmpdir first
#
# Save original destination
__cdist_out_object_dir_orig="$__cdist_out_object_dir"
# Store to tmp now
__cdist_out_object_dir="$__cdist_tmp_dir"
__cdist_new_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
# Initialise object
mkdir -p "${__cdist_new_object_dir}"
# Record parameter
__cdist_parameter_dir="$(__cdist_object_parameter_dir "$__cdist_object_self")"
mkdir -p "${__cdist_parameter_dir}"
while [ $# -gt 0 ]; do
opt="$1"; shift
echo "$opt" | grep -q "^--${__cdist_sane_regexp}\$" || \
__cdist_usage "Provide sane options"
opt_file="${opt#--}"
[ $# -ge 1 ] || __cdist_usage "Missing value for $opt"
value="$1"; shift
echo "${value}" > "${__cdist_parameter_dir}/${opt_file}"
done
# Record requirements
# it's fine, if it's not set
set +u
for requirement in $require; do
echo $requirement >> "$(__cdist_object_require "$__cdist_object_self")"
__cdist_echo info "Recording requirement $requirement"
done
set -u
################################################################################
# Check newly created object
#
#
# Ensure required parameters are given
#
if [ -f "$(__cdist_type_parameter_required "$__cdist_type")" ]; then
while read required; do
if [ ! -f "${__cdist_parameter_dir}/${required}" ]; then
__cdist_usage "Missing required parameter $required"
fi
done < "$(__cdist_type_parameter_required "$__cdist_type")"
fi
#
# Ensure that only optional or required parameters are given
#
if [ -f "$(__cdist_type_parameter_optional "$__cdist_type")" ]; then
cat "$(__cdist_type_parameter_optional "$__cdist_type")" > \
"$__cdist_tmp_file"
fi
if [ -f "$(__cdist_type_parameter_required "$__cdist_type")" ]; then
cat "$(__cdist_type_parameter_required "$__cdist_type")" >> \
"$__cdist_tmp_file"
fi
cd "$__cdist_parameter_dir"
for parameter in $(ls -1); do
is_valid=$(grep "^$parameter\$" "$__cdist_tmp_file")
[ "$is_valid" ] || __cdist_usage "Unknown parameter $parameter"
done
################################################################################
# Merge object
#
# Restore original destination
__cdist_out_object_dir="$__cdist_out_object_dir_orig"
__cdist_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
#
# If the object already exists and is exactly the same, merge it. Otherwise fail.
#
if [ -e "${__cdist_object_dir}" ]; then
# Allow diff to fail
set +e
diff -ru "${__cdist_new_object_dir}/${__cdist_name_parameter}" \
"${__cdist_object_dir}/${__cdist_name_parameter}" \
> "$__cdist_tmp_file"; ret=$?
set -e
if [ "$ret" != 0 ]; then
# Go to standard error
exec >&2
echo "${__cdist_object_self} already exists differently."
echo "Recorded source(s):"
__cdist_object_source "${__cdist_object_dir}"
echo "Differences:"
cat "$__cdist_tmp_file"
__cdist_exit_err "Aborting due to object conflict."
fi
else
#
# Move object into tree:
# Create full path minus .cdist and move .cdist
#
__cdist_new_object_base_dir="$(__cdist_object_base_dir "$__cdist_object_self")"
mkdir -p "$__cdist_new_object_base_dir"
mv "$__cdist_new_object_dir" "$__cdist_new_object_base_dir"
fi
# Add "I was here message"
__cdist_object_source_add "${__cdist_object_dir}"

View file

@ -1,83 +0,0 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Create a new type from scratch
#
. cdist-config
[ $# -eq 1 ] || __cdist_usage "<type>"
set -eu
__cdist_type="$1"; shift
__cdist_my_type_dir="$(__cdist_type_dir "$__cdist_type")"
if [ -d "$__cdist_my_type_dir" ]; then
__cdist_usage "Type $__cdist_type already exists"
fi
echo "Creating type $__cdist_type in $__cdist_my_type_dir ..."
# Base
mkdir -p "$__cdist_my_type_dir"
# Parameter
mkdir -p "$(__cdist_type_parameter_dir "$__cdist_type")"
touch "$(__cdist_type_parameter_dir "$__cdist_type")/${__cdist_name_parameter_required}"
touch "$(__cdist_type_parameter_dir "$__cdist_type")/${__cdist_name_parameter_optional}"
# Manifest
cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$__cdist_my_type_dir/${__cdist_name_manifest}"
#
# This is the manifest, which can be used to create other objects like this:
# __file /path/to/destination --source /from/where/
#
# To tell cdist to make use of it, you need to make it executable (chmod +x)
#
#
eof
# Gencode remote
cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$(__cdist_type_dir "$__cdist_type")/${__cdist_name_gencode}-${__cdist_name_gencode_remote}"
#
# This file should generate code on stdout, which will be collected by cdist
# and run on the target.
#
# To tell cdist to make use of it, you need to make it executable (chmod +x)
#
#
eof
cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$(__cdist_type_dir "$__cdist_type")/${__cdist_name_gencode}-${__cdist_name_gencode_local}"
#
# This file should generate code on stdout, which will be collected by cdist
# and run on the same machine cdist-deploy-to is executed.
#
# To tell cdist to make use of it, you need to make it executable (chmod +x)
#
#
eof
# Explorer
mkdir -p "$__cdist_my_type_dir/${__cdist_name_explorer}"

View file

@ -26,13 +26,16 @@
# exit on any error
#set -e
version=$(git describe)
# Manpage and HTML
A2XM="a2x -f manpage --no-xmllint"
A2XH="a2x -f xhtml --no-xmllint"
A2XM="a2x -f manpage --no-xmllint -a encoding=UTF-8"
A2XH="a2x -f xhtml --no-xmllint -a encoding=UTF-8"
# Developer webbase
WEBDIR=$HOME/niconetz
WEBBASE=software/cdist
WEBBASE=$WEBDIR/software/cdist
WEBMAN=$WEBBASE/man/$version
WEBPAGE=${WEBBASE}.mdwn
# Documentation
@ -88,29 +91,34 @@ case "$1" in
speeches)
cd "$SPEECHESDIR"
for speech in *tex; do
pdflatex $speech
pdflatex $speech
pdflatex $speech
pdflatex "$speech"
pdflatex "$speech"
pdflatex "$speech"
done
;;
web)
cp README ${WEBDIR}/${WEBPAGE}
rm -rf ${WEBDIR}/${WEBBASE}/man && mkdir ${WEBDIR}/${WEBBASE}/man
rm -rf ${WEBDIR}/${WEBBASE}/speeches && mkdir ${WEBDIR}/${WEBBASE}/speeches
cp README ${WEBPAGE}
rm -rf ${WEBMAN}
mkdir -p ${WEBMAN}/man1 ${WEBMAN}/man7
cp ${MAN1DSTDIR}/*.html ${MAN7DSTDIR}/*.html ${WEBDIR}/${WEBBASE}/man
cp ${SPEECHESDIR}/*.pdf ${WEBDIR}/${WEBBASE}/speeches
# old stuff
# rm -rf ${WEBDIR}/${WEBBASE}/speeches && mkdir ${WEBDIR}/${WEBBASE}/speeches
# cp ${SPEECHESDIR}/*.pdf ${WEBDIR}/${WEBBASE}/speeches
# git describe > ${WEBDIR}/${WEBBASE}/man/VERSION
cp ${MAN1DSTDIR}/*.html ${WEBMAN}/man1
cp ${MAN7DSTDIR}/*.html ${WEBMAN}/man7
git describe > ${WEBDIR}/${WEBBASE}/man/VERSION
cd ${WEBDIR} && git add ${WEBBASE}
cd ${WEBDIR} && git commit -m "cdist update" ${WEBBASE} ${WEBPAGE}
cd ${WEBDIR} && make pub
;;
pub)
p|pu|pub)
git push --mirror
git push --mirror github
git push --mirror sf
;;
clean)
@ -123,14 +131,26 @@ case "$1" in
| xargs rm -f
;;
test)
shift # skip t
export PYTHONPATH=$PYTHONPATH:$(pwd -P)/lib
if [ $# -lt 1 ]; then
python3 -m cdist.test
else
python3 -m unittest "$@"
fi
;;
*)
echo ''
echo 'Welcome to cdist!'
echo ''
echo 'Here are the possible targets:'
echo ''
echo ' man: Build manpages (requires Asciidoc)'
echo ' clean: Remove build stuff'
echo ' man: Build manpages (requires Asciidoc)'
echo ' test: Run tests'
echo ''
echo ''
echo "Unknown target, \"$1\"" >&2

26
conf/explorer/lsb_codename Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
set +e
lsb_release=$(which lsb_release 2>/dev/null)
if [ -x "$lsb_release" ]; then
$lsb_release --short --codename
fi

26
conf/explorer/lsb_description Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
set +e
lsb_release=$(which lsb_release 2>/dev/null)
if [ -x "$lsb_release" ]; then
$lsb_release --short --description
fi

26
conf/explorer/lsb_id Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
set +e
lsb_release=$(which lsb_release 2>/dev/null)
if [ -x "$lsb_release" ]; then
$lsb_release --short --id
fi

26
conf/explorer/lsb_release Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
set +e
lsb_release=$(which lsb_release 2>/dev/null)
if [ -x "$lsb_release" ]; then
$lsb_release --short --release
fi

View file

@ -49,7 +49,7 @@ if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then
exit 0
fi
# CentOS is also based on Redhat, this return before redhat!
# CentOS is also based on Redhat, thus return before redhat!
if grep -q ^CentOS /etc/redhat-release 2>/dev/null; then
echo centos
exit 0
@ -65,6 +65,16 @@ if [ -f /etc/SuSE-release ]; then
exit 0
fi
if [ -f /etc/owl-release ]; then
echo owl
exit 0
fi
if [ -f /etc/cdist-preos ]; then
echo cdist-preos
exit 0
fi
uname_s="$(uname -s)"
# Assume there is no tr on the client -> do lower case ourselves

View file

@ -42,6 +42,9 @@ case "$($__explorer/os)" in
*bsd|solaris)
uname -r
;;
owl)
cat /etc/owl-release
;;
redhat|centos)
cat /etc/redhat-release
;;

View file

@ -1,6 +1,7 @@
#!/bin/sh
#
# 2010-2011 Daniel Roth (dani-cdist@d-roth.li)
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -25,9 +26,18 @@ else
file="/$__object_id"
fi
regex=$(cat "$__object/parameter/line")
if [ -f "$__object/parameter/regex" ]; then
regex=$(cat "$__object/parameter/regex")
else
wrap=$(cat "$__object/parameter/line")
regex="^$wrap\$"
fi
if [ -f "$file" ]; then
grep -q "^$regex\$" "$file"
# sh -e is our environment, we know what we do,
# skip error detection for now
set +e
grep -q "$regex" "$file"
if [ $? -eq 1 ]; then
echo "NOTFOUND"
else

View file

@ -25,7 +25,9 @@ OPTIONAL PARAMETERS
file::
If supplied, use this as the destination file.
Otherwise the object_id is used.
regex::
If supplied, search for this regex.
Otherwise entire line must be matched.
EXAMPLES
--------

View file

@ -1 +1,2 @@
file
regex

View file

@ -27,4 +27,4 @@ require="__package/python-software-properties" \
--source "$__type/files/remove-apt-repository" \
--mode 0755
require="$__self" __apt_update_index
require="$__object_name" __apt_update_index

View file

@ -38,5 +38,5 @@ if [ -f "$__object/parameter/comment" ]; then
fi
echo "$entry" >> "$__object/parameter/entry"
require="$__self" __autofs_master
require="$__object_name" __autofs_master

View file

@ -24,7 +24,7 @@ if [ ! -f "$__object/parameter/header" ]; then
fi
[ -d "$__object/files" ] || mkdir "$__object/files"
require="$__self" __file /etc/auto.master --source "$__object/files/auto.master" \
require="$__object_name" __file /etc/auto.master --source "$__object/files/auto.master" \
--mode 644 \
--owner root \
--group root

View file

@ -0,0 +1,37 @@
#!/bin/sh
#
# Copyright (C) 2011 Daniel Maher (phrawzty+cdist at gmail.com)
#
# This file is part of cdist (https://github.com/telmich/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/>.
#
# The marker file is established in the docs, but it isn't obligatory.
if [ -f "$__object/parameter/destination" ]; then
destination="$(cat "$__object/parameter/destination")"
else
destination='/etc/cdist-configured'
fi
# The basic output of date is usually good enough, but variety is the
# spice of life...
if [ -f "$__object/parameter/format" ]; then
format="$(cat "$__object/parameter/format")"
else
format='-u'
fi
# Dump the timestamp in UTC to the marker
echo "date $format > $destination"

View file

@ -0,0 +1,55 @@
cdist-type__cdistmarker(7)
==========================
Daniel Maher <phrawzty+cdist at gmail.com>
NAME
----
cdist-type__cdistmarker - Add a timestamped cdist marker.
DESCRIPTION
-----------
This type is used to add a common marker file which indicates that a given
machine is being managed by cdist. The contents of this file consist of a
timestamp, which can be used to determine the most recent time at which cdist
was run against the machine in question.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
destination::
The path and filename of the marker.
Default: /etc/cdist-configured
format::
The format of the timestamp. This is passed directly to system 'date'.
Default: -u
EXAMPLES
--------
--------------------------------------------------------------------------------
# Creates the marker as normal.
__cdistmarker
# Creates the marker differently.
__cdistmarker --file /tmp/cdist_marker --format '+%s'
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
COPYING
-------
Copyright \(C) 2011 Daniel Maher. Free use of this software is granted under
the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -0,0 +1,2 @@
destination
format

View file

39
conf/type/__cron/explorer/entry Executable file
View file

@ -0,0 +1,39 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
name="$__object_id"
user="$(cat "$__object/parameter/user")"
prefix="#cdist:__cron/$name"
suffix="#/cdist:__cron/$name"
crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" '
{
if (index($0,prefix)) {
triggered=1
}
if (triggered) {
if (index($0,suffix)) {
triggered=0
}
print
}
}
'

63
conf/type/__cron/gencode-remote Executable file
View file

@ -0,0 +1,63 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
user="$(cat "$__object/parameter/user")"
state_should="$(cat "$__object/parameter/state")"
state_is=$(diff -q "$__object/parameter/entry" "$__object/explorer/entry" \
&& echo present \
|| echo absent
)
if [ "$state_is" != "$state_should" ]; then
case "$state_should" in
present)
cat << DONE
tmp=\$(mktemp)
crontab -u $user -l > \$tmp
cat >> \$tmp << EOC
$(cat "$__object/parameter/entry")"
EOC
crontab -u $user \$tmp
rm \$tmp
DONE
;;
absent)
# defined in type manifest
prefix="$(cat "$__object/parameter/prefix")"
suffix="$(cat "$__object/parameter/suffix")"
cat << DONE
crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" '
{
if (index(\$0,prefix)) {
triggered=1
}
if (triggered) {
if (index(\$0,suffix)) {
triggered=0
}
} else {
print
}
}
' | crontab -u $user -
DONE
;;
esac
fi

61
conf/type/__cron/man.text Normal file
View file

@ -0,0 +1,61 @@
cdist-type__cron(7)
===================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__cron - installs and manages cron jobs
DESCRIPTION
-----------
This cdist type allows you to manage entries in a users crontab.
REQUIRED PARAMETERS
-------------------
user::
The user who's crontab is edited
command::
The command to run.
OPTIONAL PARAMETERS
-------------------
state::
Either present or absent. Defaults to present.
minute::
See crontab(5). Defaults to *
hour::
See crontab(5). Defaults to *
day_of_month::
See crontab(5). Defaults to *
month::
See crontab(5). Defaults to *
day_of_week::
See crontab(5). Defaults to *
EXAMPLES
--------
--------------------------------------------------------------------------------
# add cronjob
__cron some-id --user root --command "/path/to/script"
# remove cronjob
__cron some-id --user root --command "/path/to/script" --state absent
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- crontab(5)
COPYING
-------
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

66
conf/type/__cron/manifest Executable file
View file

@ -0,0 +1,66 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
name="$__object_id"
user="$(cat "$__object/parameter/user")"
command="$(cat "$__object/parameter/command")"
# set defaults
if [ ! -f "$__object/parameter/state" ]; then
echo "present" > "$__object/parameter/state"
fi
if [ -f "$__object/parameter/minute" ]; then
minute="$(cat "$__object/parameter/minute")"
else
minute="*"
echo "$minute" > "$__object/parameter/minute"
fi
if [ -f "$__object/parameter/hour" ]; then
hour="$(cat "$__object/parameter/hour")"
else
hour="*"
echo "$hour" > "$__object/parameter/hour"
fi
if [ -f "$__object/parameter/day_of_month" ]; then
day_of_month="$(cat "$__object/parameter/day_of_month")"
else
day_of_month="*"
echo "$day_of_month" > "$__object/parameter/day_of_month"
fi
if [ -f "$__object/parameter/month" ]; then
month="$(cat "$__object/parameter/month")"
else
month="*"
echo "$month" > "$__object/parameter/month"
fi
if [ -f "$__object/parameter/day_of_week" ]; then
day_of_week="$(cat "$__object/parameter/day_of_week")"
else
day_of_week="*"
echo "$day_of_week" > "$__object/parameter/day_of_week"
fi
# NOTE: if changed, also change in explorers
prefix="#cdist:__cron/$name"
suffix="#/cdist:__cron/$name"
echo "$prefix" | tee "$__object/parameter/prefix" > "$__object/parameter/entry"
echo "$minute $hour $day_of_month $month $day_of_week $command" >> "$__object/parameter/entry"
echo "$suffix" | tee "$__object/parameter/suffix" >> "$__object/parameter/entry"

View file

@ -0,0 +1,6 @@
state
minute
hour
day_of_month
month
day_of_week

View file

@ -0,0 +1,2 @@
user
command

38
conf/type/__mkfs/gencode-remote Executable file
View file

@ -0,0 +1,38 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
device="$(cat "$__object/parameter/device")"
type="$(cat "$__object/parameter/type")"
if [ "$type" = "swap" ]; then
echo "mkswap $device"
else
command="mkfs -t $type -q"
if [ -f "$__object/parameter/options" ]; then
options="$(cat "$__object/parameter/options")"
command="$command $options"
fi
command="$command $device"
if [ -f "$__object/parameter/blocks" ]; then
blocks="$(cat "$__object/parameter/blocks")"
command="$command $blocks"
fi
echo "$command"
fi

0
conf/type/__mkfs/install Normal file
View file

57
conf/type/__mkfs/man.text Normal file
View file

@ -0,0 +1,57 @@
cdist-type__mkfs(7)
===================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__mkfs - build a linux file system
DESCRIPTION
-----------
This cdist type is a wrapper for the mkfs command.
REQUIRED PARAMETERS
-------------------
type::
The filesystem type to use. Same as mkfs -t.
OPTIONAL PARAMETERS
-------------------
device::
defaults to object_id
options::
file system-specific options to be passed to the mkfs command
blocks::
the number of blocks to be used for the file system
EXAMPLES
--------
--------------------------------------------------------------------------------
# reiserfs /dev/sda5
__mkfs /dev/sda5 --type reiserfs
# same thing with explicit device
__mkfs whatever --device /dev/sda5 --type reiserfs
# jfs with journal on /dev/sda2
__mkfs /dev/sda1 --type jfs --options "-j /dev/sda2"
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- mkfs(8)
COPYING
-------
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

31
conf/type/__mkfs/manifest Executable file
View file

@ -0,0 +1,31 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
# set defaults
if [ -f "$__object/parameter/device" ]; then
device="(cat "$__object/parameter/device")"
else
device="/$__object_id"
echo "$device" > "$__object/parameter/device"
fi
type="(cat "$__object/parameter/type")"
options="(cat "$__object/parameter/options")"

View file

@ -0,0 +1,3 @@
device
options
blocks

View file

@ -0,0 +1 @@
type

View file

@ -49,4 +49,4 @@ for property in $(ls .); do
fi
done
require="$__self" __package_$type "$@"
require="$__object_name" __package_$type "$@"

View file

@ -27,13 +27,6 @@ else
name="$__object_id"
fi
# Check for preseeding and add preseed as here document
if [ -f "$__object/parameter/preseed" ]; then
echo "debconf-set-selections << __file-eof"
cat "$(cat "$__object/parameter/preseed")"
echo "__file-eof"
fi
state="$(cat "$__object/parameter/state")"
is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status" || true)"

View file

@ -0,0 +1,31 @@
#!/bin/sh
#
# 2012 SwellPath, Inc.
# Christian G. Warden <cwarden@xerus.org>
#
# 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/>.
#
# Retrieve the status of a rock
#
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="$__object_id"
fi
# Accept luarocks failing if package is not known/installed
luarocks list "$name" | egrep -A1 "^$name$" || exit 0

View file

@ -0,0 +1,52 @@
#!/bin/sh
#
# 2012 SwellPath, Inc.
# Christian G. Warden <cwarden@xerus.org>
#
# 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/>.
#
#
# Manage LuaRocks packages
#
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="$__object_id"
fi
state="$(cat "$__object/parameter/state")"
is_installed="$(grep "(installed)" "$__object/explorer/pkg_status" || true)"
case "$state" in
installed)
# Install only if non-existent
if [ -z "$is_installed" ]; then
echo luarocks install \"$name\"
fi
;;
removed)
# Remove only if existent
if [ -n "$is_installed" ]; then
echo luarocks remove \"$name\"
fi
;;
*)
echo "Unknown state: $state" >&2
exit 1
;;
esac

View file

@ -0,0 +1,49 @@
cdist-type__package_luarocks(7)
==============================
Christian G. Warden <cwarden@xerus.org>
NAME
----
cdist-type__package_luarocks - Manage luarocks packages
DESCRIPTION
-----------
LuaRocks is a deployment and management system for Lua modules.
REQUIRED PARAMETERS
-------------------
state::
Either "installed" or "removed".
OPTIONAL PARAMETERS
-------------------
name::
If supplied, use the name and not the object id as the package name.
EXAMPLES
--------
--------------------------------------------------------------------------------
# Ensure luasocket is installed
__package_luarocks luasocket --state installed
# Remove package
__package_luarocks luasocket --state removed
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- cdist-type__package(7)
COPYING
-------
Copyright \(C) 2012 SwellPath, Inc. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -0,0 +1,23 @@
#!/bin/sh
#
# 2012 SwellPath, Inc.
# Christian G. Warden <cwarden@xerus.org>
#
# 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/>.
#
__package luarocks --state installed
__package make --state installed

View file

@ -0,0 +1 @@
name

View file

@ -0,0 +1 @@
state

View file

@ -0,0 +1,30 @@
#!/bin/sh
#
# 2011 Chase Allen James (nx-cdist@nu-ex.com)
#
# 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/>.
#
# Retrieve the status of a rubygem
#
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="$__object_id"
fi
# Except gem failing, if package is not known / installed
gem list -i "$name" 2>/dev/null || exit 0

View file

@ -0,0 +1,51 @@
#!/bin/sh
#
# 2011 Chase Allen James <nx-cdist@nu-ex.com>
#
# 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/>.
#
#
# Manage Rubygem packages
#
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="$__object_id"
fi
state="$(cat "$__object/parameter/state")"
is_installed="$(grep "true" "$__object/explorer/pkg_status" || true)"
case "$state" in
installed)
# Install only if non-existent
if [ -z "$is_installed" ]; then
echo gem install \"$name\" --no-ri --no-rdoc
fi
;;
removed)
# Remove only if existent
if [ -n "$is_installed" ]; then
echo gem uninstall \"$name\"
fi
;;
*)
echo "Unknown state: $state" >&2
exit 1
;;
esac

View file

@ -0,0 +1,49 @@
cdist-type__package_rubygem(7)
==============================
Chase Allen James <nx-cdist@nu-ex.com>
NAME
----
cdist-type__package_rubygem - Manage rubygem packages
DESCRIPTION
-----------
Rubygems is the default package management system for the Ruby programming language.
REQUIRED PARAMETERS
-------------------
state::
Either "installed" or "removed".
OPTIONAL PARAMETERS
-------------------
name::
If supplied, use the name and not the object id as the package name.
EXAMPLES
--------
--------------------------------------------------------------------------------
# Ensure sinatra is installed
__package_rubygem sinatra --state installed
# Remove package
__package_rubygem rails --state removed
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- cdist-type__package(7)
COPYING
-------
Copyright \(C) 2011 Chase Allen James. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -0,0 +1 @@
name

View file

@ -0,0 +1 @@
state

View file

View file

@ -0,0 +1,62 @@
cdist-type__partition_msdos(7)
==============================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__partition_msdos - creates msdos partitions
DESCRIPTION
-----------
This cdist type allows you to create msdos paritions.
REQUIRED PARAMETERS
-------------------
type::
the partition type used in fdisk (such as 82 or 83) or "extended"
OPTIONAL PARAMETERS
-------------------
partition::
defaults to object_id
bootable::
mark partition as bootable, true or false, defaults to false
size::
the size of the partition (such as 32M or 15G, whole numbers
only), '+' for remaining space, or 'n%' for percentage of remaining
(these should only be used after all specific partition sizes are
specified). Defaults to +.
EXAMPLES
--------
--------------------------------------------------------------------------------
# 128MB, linux, bootable
__partition_msdos /dev/sda1 --type 83 --size 128M --bootable true
# 512MB, swap
__partition_msdos /dev/sda2 --type 82 --size 512M
# 100GB, extended
__partition_msdos /dev/sda3 --type extended --size 100G
# 10GB, linux
__partition_msdos /dev/sda5 --type 83 --size 10G
# 50% of the free space of the extended partition, linux
__partition_msdos /dev/sda6 --type 83 --size 50%
# rest of the extended partition, linux
__partition_msdos /dev/sda7 --type 83 --size +
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
COPYING
-------
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -0,0 +1,41 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
# set defaults
if [ -f "$__object/parameter/partition" ]; then
partition="(cat "$__object/parameter/partition")"
else
partition="/$__object_id"
echo "$partition" > "$__object/parameter/partition"
fi
device="$(echo "$partition" | sed 's/[0-9]//g')"
echo "$device" > "$__object/parameter/device"
minor="$(echo "$partition" | sed 's/[^0-9]//g')"
echo "$minor" > "$__object/parameter/minor"
if [ ! -f "$__object/parameter/bootable" ]; then
echo "false" > "$__object/parameter/bootable"
fi
if [ ! -f "$__object/parameter/size" ]; then
echo "+" > "$__object/parameter/size"
fi
# pull in the type that actually does something with the above parameters
require="$__object_name" __partition_msdos_apply

View file

@ -0,0 +1,3 @@
partition
bootable
size

View file

@ -0,0 +1 @@
type

View file

@ -0,0 +1,3 @@
#!/bin/sh
cat /proc/partitions

View file

@ -0,0 +1,61 @@
die() {
echo "[__partition_msdos_apply] $@" >&2
exit 1
}
debug() {
#echo "[__partition_msdos_apply] $@" >&2
:
}
fdisk_command() {
local device="$1"
local cmd="$2"
debug fdisk_command "running fdisk command '${cmd}' on device ${device}"
printf "${cmd}\nw\n" | fdisk -c -u "$device"
# give disk some time
sleep 1
return $?
}
create_disklabel() {
local device=$1
debug create_disklabel "creating new msdos disklabel"
fdisk_command ${device} "o"
return $?
}
create_partition() {
local device="$1"
local minor="$2"
local size="$3"
local type="$4"
local primary_count="$5"
if [ "$type" = "extended" -o "$type" = "5" ]; then
# Extended partition
primary_extended="e\n"
first_minor="${minor}\n"
[ "${minor}" = "4" ] && first_minor=""
type_minor="${minor}\n"
[ "${minor}" = "1" ] && type_minor=""
type="5"
elif [ "${minor}" -lt "5" ]; then
primary_extended="p\n"
first_minor="${minor}\n"
[ "${minor}" = "4" ] && first_minor=""
type_minor="${minor}\n"
[ "${minor}" = "1" ] && type_minor=""
else
# Logical partitions
first_minor="${minor}\n"
type_minor="${minor}\n"
primary_extended="l\n"
[ "$primary_count" -gt "3" ] && primary_extended=""
fi
[ -n "${size}" ] && size="+${size}M"
fdisk_command ${device} "n\n${primary_extended}${first_minor}\n${size}\nt\n${type_minor}${type}\n"
return $?
}

View file

@ -0,0 +1,138 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
die() {
echo "[__partition_msdos_apply] $@" >&2
exit 1
}
debug() {
#echo "[__partition_msdos_apply] $@" >&2
:
}
# Convert a size specifier 1G 100M or 50% into the corresponding numeric MB.
size_to_mb() {
local size=$1
local available_size="$2"
local number_suffix="$(echo ${size} | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([MmGg%]\)[Bb]\?:\1|\2:')"
local number="$(echo ${number_suffix} | cut -d '|' -f1)"
local suffix="$(echo ${number_suffix} | cut -d '|' -f2)"
case "$suffix" in
M|m)
size="$number"
;;
G|g)
size="$(( $number * 1024 ))"
;;
%)
size="$(( $available_size * $number / 100 ))"
;;
*)
size="-1"
esac
echo "$size"
}
# include function library for use on target
cat "$__type/files/lib.sh"
partitions="$__object/explorer/partitions"
objects=$(find "$__global/object/__partition_msdos" -path "*.cdist")
current_device=""
available_device_size=
available_extended_size=
available_size=
primary_count=0
for object in $objects; do
device="$(cat "$object/parameter/device")"
if [ "$current_device" != "$device" ]; then
echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'"
current_device="$device"
device_name=$(echo ${device} | sed -e 's:^/dev/::;s:/:\\/:g')
available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024))
# make sure we don't go past the end of the drive
available_device_size=$((available_device_size - 2))
available_extended_size=0
primary_count=0
debug "----- $device"
debug "current_device=$current_device"
debug "available_device_size=$available_device_size"
fi
type="$(cat "$object/parameter/type")"
partition="$(cat "$object/parameter/partition")"
minor="$(cat "$object/parameter/minor")"
bootable="$(cat "$object/parameter/bootable")"
size="$(cat "$object/parameter/size")"
if [ "${minor}" -lt "5" ]; then
# Primary partitions
primary_count=$(( $primary_count + 1 ))
available_size=$available_device_size
else
# Logical partitions
available_size=$available_extended_size
fi
if [ "$size" = "+" ]; then
# use rest of device
partition_size=""
available_size=0
else
partition_size=$(size_to_mb "$size" "$available_size")
available_size="$(( $available_size - $partition_size ))"
fi
if [ "${minor}" -lt "5" ]; then
# Primary partitions
available_device_size=$available_size
if [ "$type" = "extended" -o "$type" = "5" ]; then
# Extended partition
available_extended_size=$partition_size
fi
else
# Logical paritions
available_extended_size=$available_size
fi
[ "$partition_size" = "-1" ] && die "could not translate size '$size' to a usable value"
debug "----- $partition"
debug "primary_count=$primary_count"
debug "current_device=$current_device"
debug "device=$device"
debug "type=$type"
debug "partition=$partition"
debug "minor=$minor"
debug "bootable=$bootable"
debug "size=$size"
debug "partition_size=$partition_size"
debug "available_size=$available_size"
debug "available_device_size=$available_device_size"
debug "available_extended_size=$available_extended_size"
debug "----------"
echo "create_partition '$device' '$minor' '$partition_size' '$type' '$primary_count' \
|| die 'Failed to create partition: $partition'"
done

View file

@ -0,0 +1,42 @@
cdist-type__partition_msdos_apply(7)
====================================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__partition_msdos_apply - Apply dos partition settings
DESCRIPTION
-----------
Create the partitions defined with __partition_msdos
REQUIRED PARAMETERS
-------------------
None
OPTIONAL PARAMETERS
-------------------
None.
EXAMPLES
--------
--------------------------------------------------------------------------------
__partition_msdos_apply
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- cdist-type__partition_msdos_apply(7)
COPYING
-------
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -24,7 +24,7 @@
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="/$__object_id"
name="$__object_id"
fi
pgrep -x -f "$name" || true

View file

@ -50,6 +50,10 @@ __process /usr/sbin/sshd --state stopped --stop "/etc/rc.d/sshd stop"
# Ensure cups is running, which runs with -C ...:
__process cups --start "/etc/rc.d/cups start" --state running \
--name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf"
# Ensure rpc.statd is running (which usually runs with -L) using a regexp
__process rpcstatd --state running --start "/etc/init.d/statd start" \
--name "rpc.statd.*"
--------------------------------------------------------------------------------

View file

@ -55,7 +55,7 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")"
if [ "$new_value" != "$current_value" ]; then
set -- "$@" "--$property" \"$new_value\"
set -- "$@" "--$property" \'$new_value\'
fi
done
@ -67,7 +67,7 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
else
for property in $(ls .); do
new_value="$(cat "$property")"
set -- "$@" "--$property" \"$new_value\"
set -- "$@" "--$property" \'$new_value\'
done
echo useradd "$@" "$name"

View file

@ -1,4 +1,44 @@
1.7.1:
2.0.5:
* New Type: __package_luarocks (Christian G. Warden)
* Feature: __addifnosuchline supports matching on
regular expressions (Daniel Maher)
* Documentation: (Re)write of the tutorial
* Cleanup: Explicitly require Python >= 3.2 (do not fail implicitly)
2.0.4: 2011-11-18
* Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C)
* Bugfix core: Accept parameters with - in the name (Steven Armstrong)
* Cleanup: __object_fq variable removed (never used)
* Cleanup: Environment variable __self DEPRECATED, use __object_name instead
* Cleanup: Environment variable __self scheduled for removal in cdist 2.1
* Documentation: Many examples for use of __remote_* (Steven Armstrong)
* Feature: Automatically require all used objects (Steven Armstrong)
* New Type: __cron (Steven Armstrong)
2.0.3: 2011-10-18
* Improved logging, added --verbose, by more quiet by default
* Bugfix __user: Correct quoting (Steven Armstrong)
* Bugfix __addifnosuchline: Falsely exited
* Bugfix requirements: Restore original require="" behaviour
* Feature requirements: Check for broken object_ids and abort
* Massive refactoring and unittesting introduced (Steven Armstrong)
2.0.2: 2011-09-27
* Add support for detection of OpenWall Linux (Matthias Teege)
* Add support for __debug variable in manifests
* Bugfix core: Various issues with type emulator
2.0.1: 2011-09-23
* Bugfix core: Always print source of error in case of exec errors
* Bugfix core: Various smaller bugs in string concatenation
* Feature: Add marker "changed" to changed objects
2.0.0: 2011-09-16
* New Type: __package_rubygem (Chase Allen James)
* __self replaced by __object_fq
* Rewrote cdist in Python
1.7.1: 2011-07-26
* Documentation: Add explorers to reference
* Documentation: Typo cleanup (Derek Brost)
* Type __key_value: Bugfix (Steven Armstrong)

View file

@ -0,0 +1,12 @@
#!/bin/sh
outfile="$1"; shift
(
for host in "$@"; do
hosts="$hosts $host"
cdist config -c ~/p/cdist-nutzung -p $hosts 2>&1
done
) | tee "$outfile"
echo "----------"
grep 'INFO: Total processing time for' "$outfile" | sed 's/.*: //'

7
doc/dev/fancy-ideas Normal file
View file

@ -0,0 +1,7 @@
== types with namespaces ==
- allow types to have namespaces, e.g.
__path/my/type
implemented as a proof of concept at:
https://github.com/asteven/cdist/tree/type-namespaces

24
doc/dev/lastchanges Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# 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/>.
#
#
# Show the lastest changes from this (upcoming) release
#
awk '/^$/ { exit } { print $0 } END { print "-----" }' < "${0%/*}/../changelog"

View file

@ -0,0 +1,2 @@
http://slashdot.org/submission/1533922/cdist-162---usable-configuration-management
http://slashdot.org/submission/1522134/Cdist-Configuration-management-that-makes-fun#

View file

@ -0,0 +1,7 @@
cdist-mass-deploy -p ikq02.ethz.ch; 142
cdist-mass-deploy -p ikq02.ethz.ch ikq03.ethz.ch; 194
cdist-mass-deploy -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch; 271
cdist-mass-deploy -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch ikq05.ethz.ch; 328
cdist-mass-deploy -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch ikq05.ethz.ch ikq06.ethz.ch; 456
cdist-mass-deploy -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch ikq05.ethz.ch ikq06.ethz.ch ikq07.ethz.ch; 568

View file

@ -0,0 +1,56 @@
% x200
data = [ 1 104; 2 129; 6 249 ; 25 1267 ]
% x201, 4.2.2.4 dns, eth
data = [ 1 143; 2 159; 3 198; 4 244; 5 299; 6 350; 7 435; 8 429 ];
% x201, von zuhause aus
data2 = [ 226 242 275 296 306 357 403 400 409 685 617 672 ]
plot(0:size(data)(2)-1, data)
hold off;
plot(data(:,1), data(:,2))
% per host time:
data(:,2)' ./ data(:,1)'
hold on;
plot(data(:,1), data(:,2)' ./ data(:,1)')
Testing on
Intel(R) Core(TM)2 Duo CPU P8400 @ 2.26GHz
4 GiB RAM
Intel Gbit Nic
- 169 objects, all done (i.e. rerun)
- runs are cpu bound
1 host:
core: cdist 1.6.2: Successfully finished run
Run: 104s (1 minutes)
2 hosts:
[13:48] kr:cdist-nutzung% mytime cdist-mass-deploy -p ikq03.ethz.ch ikq04.ethz.ch
Run: 129s (2 minutes)
6 hosts: (7 specified, but ikq01.ethz.ch is dead)
cdist-mass-deploy -p ikq01.ethz.ch ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch ikq05.ethz.ch ikq06.ethz.ch ikq07.ethz.ch
Run: 294s (4 minutes)
25 hosts
[13:58] kr:cdist-nutzung% mytime cdist-mass-deploy -p $(sed 's/^root@//' ~/.dsh/group/ikr)
Run: 723s (12 minutes)
25 hosts without proxy command now:
Run: 1267s (21 minutes)
Run: 1212s (20 minutes)
[14:11] kr:cdist-nutzung% mytime cdist-mass-deploy -p $(sed 's/^root@//' ~/.dsh/group/ikr)

View file

@ -0,0 +1,9 @@
Run: 78s (1 minutes)
[13:25] kr:cdist-nutzung% mytime cdist-deploy-to ikq02.ethz.ch
% mit dash, eth, x201, Mit Apr 27 13:41:49 CEST 2011
data = [ 0 73 77 89 107 130 151 180 197 228 251 260 199 295 335 276 ]
plot(0:size(data2)(2)-1, data2)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,20 @@
- new executable cinst-deploy-to
- types used by cinst are marked as such ('cinst-only')
- cdist-deploy-to and cinst-deploy-to read the same manifest
- cdist ignores types marked as 'cinst-only'
- cinst ignores types not marked as 'cinst-only'
- update $__explorer/os to recognize preos
- cinst types will ONLY BE CALLED if $__explorer/os == 'preos'
--------------------------------------------------------------------------------
cinst types:
__partition_msdos /dev/sda1 --type 83 --size 100M --bootable
__partition_msdos /dev/sda2 --type 82 --size 512M
__fs_jfs /dev/sda1 --args "-c -q"
__fstab_entry /dev/sda1 --type jfs --mountpoint / --options noatime --freq 0 --passno 0
__fstab_entry /dev/sda2 --type swap

View file

@ -0,0 +1,15 @@
client -------------------> trigger via ssh ----------> server
~/.ssh/authorized_keys
-> cdist-deploy-to <da-wo-ich-herkomme>
ssh -R
server -> via cdist-deploy-to -> client
cdist-mass-deploy -p <host a .. host b...>

View file

@ -0,0 +1,4 @@
Debugging cdist:
[0:13] kr:cdist-nutzung% ./local/update-local-core && __cdist_debug=1 __cdist_local_base_dir=/tmp/cdist cdist-deploy-to ikq04.ethz.ch

110
doc/dev/logs/2011-09-12 Normal file
View file

@ -0,0 +1,110 @@
Benchmark from home/X201 (2 cores, 4 threads):
ikq (1): 72.192397
ikq (2): INFO: Total processing time for 2 hosts: 74.1845
ikq* (6): INFO: Total processing time: 117.572312
ikq* + ikr3 (9): INFO: Total processing time: 120.307662
ikq* + ikr (14): INFO: Total processing time: 139.769807
ikq* + ikr (18): INFO: Total processing time: 186.354398
ikq* + ikr (22): INFO: Total processing time: 225.793533
ikq* + ikr (26): INFO: Total processing time: 237.06687
ikq* + ikr (31): INFO: Total processing time: 276.912414
ikr07.ethz.ch ikr09.ethz.ch ikr10.ethz.ch ikr11.ethz.ch
ikr13.ethz.ch ikr14.ethz.ch ikr15.ethz.ch ikr16.ethz.ch
ikr17.ethz.ch ikr19.ethz.ch ikr20.ethz.ch ikr21.ethz.ch
ikr23.ethz.ch ikr24.ethz.ch ikr25.ethz.ch ikr26.ethz.ch
ikr27.ethz.ch ikr28.ethz.ch ikr29.ethz.ch ikr30.ethz.ch
ikr31.ethz.ch
cdist -c ~/p/cdist-nutzung -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch ikq05.ethz.ch ikq06.ethz.ch ikq07.ethz.ch ikr01.ethz.ch ikr02.ethz.ch ikr03.ethz.ch ikr05.ethz.ch ikr07.ethz.ch ikr09.ethz.ch ikr10.ethz.ch ikr11.ethz.ch ikr13.ethz.ch ikr14.ethz.ch ikr15.ethz.ch ikr16.ethz.ch ikr17.ethz.ch ikr19.ethz.ch ikr20.ethz.ch ikr21.ethz.ch
--------------------------------------------------------------------------------
INFO: Total processing time for 1 hosts: 72.166661
INFO: Total processing time for 2 hosts: 76.633228
INFO: Total processing time for 3 host(s): 77.199817
INFO: Total processing time for 4 host(s): 94.045175
INFO: Total processing time for 5 host(s): 103.226354
INFO: Total processing time for 6 host(s): 107.76097
INFO: Total processing time for 7 host(s): 101.571705
INFO: Total processing time for 8 host(s): 107.600093
INFO: Total processing time for 9 host(s): 116.500371
INFO: Total processing time for 10 host(s): 119.445805
INFO: Total processing time for 11 host(s): 123.944385
INFO: Total processing time for 12 host(s): 130.499098
INFO: Total processing time for 13 host(s): 137.250861
INFO: Total processing time for 14 host(s): 154.9841
INFO: Total processing time for 15 host(s): 139.659637
INFO: Total processing time for 16 host(s): 142.70005
INFO: Total processing time for 17 host(s): 148.541452
INFO: Total processing time for 18 host(s): 159.360809
INFO: Total processing time for 19 host(s): 171.907864
INFO: Total processing time for 20 host(s): 178.76695
INFO: Total processing time for 21 host(s): 183.856671
INFO: Total processing time for 22 host(s): 194.504221
INFO: Total processing time for 23 host(s): 207.314842
INFO: Total processing time for 24 host(s): 215.846502
INFO: Total processing time for 25 host(s): 217.223581
INFO: Total processing time for 26 host(s): 238.591705
INFO: Total processing time for 27 host(s): 238.478493
INFO: Total processing time for 28 host(s): 246.058718
INFO: Total processing time for 29 host(s): 264.208372
INFO: Total processing time for 30 host(s): 265.560685
INFO: Total processing time for 31 host(s): 282.264488
--------------------------------------------------------------------------------
Use:
grep "^INFO: Total processing time" doc/dev/logs/2011-09-12 | sed 's/.*: //'
octave
times = [ /* paste here ]
plot(times)
# keep the graph
hold on
# Scale linearly with the single host value
plot((1:31)*times(1))
--------------------------------------------------------------------------------
code:
octave
time = [
72.166661
76.633228
77.199817
94.045175
103.226354
107.76097
101.571705
107.600093
116.500371
119.445805
123.944385
130.499098
137.250861
154.9841
139.659637
142.70005
148.541452
159.360809
171.907864
178.76695
183.856671
194.504221
207.314842
215.846502
217.223581
238.591705
238.478493
246.058718
264.208372
265.560685
282.264488
]
plot(times, "-;cdist;", times(1)*[1:length(times)]', "-;linear;")
title("Configuration duration (cdist-2.0.0-rc4)")
ylabel("Number of hosts")
xlabel("Time in seconds")
print('cdist-2.0.0-rc4.png', '-dpng')

File diff suppressed because it is too large Load diff

3
doc/dev/logs/2011-09-13 Normal file
View file

@ -0,0 +1,3 @@
Name for installer:
installer (flag)
$__installer (variable) - gesetzt oder nicht

View file

@ -0,0 +1,63 @@
48 core
model name : AMD Opteron(tm) Processor 6174
128 GB RAM
Dell PowerEdge R815
root@sgs-r815-01:~/cdist-nutzung# grep "Total processing time for" deploy-all-benchmark-noikr13
INFO: Total processing time for 1 host(s): 257.641541
INFO: Total processing time for 2 host(s): 257.025783
INFO: Total processing time for 3 host(s): 258.933088
INFO: Total processing time for 4 host(s): 259.253074
INFO: Total processing time for 5 host(s): 260.331896
INFO: Total processing time for 6 host(s): 262.051349
INFO: Total processing time for 7 host(s): 323.820878
INFO: Total processing time for 8 host(s): 329.081856
INFO: Total processing time for 9 host(s): 333.346278
INFO: Total processing time for 10 host(s): 334.832419
INFO: Total processing time for 11 host(s): 330.572375
INFO: Total processing time for 12 host(s): 331.726628
INFO: Total processing time for 13 host(s): 331.740591
INFO: Total processing time for 14 host(s): 331.237139
INFO: Total processing time for 15 host(s): 331.718861
INFO: Total processing time for 16 host(s): 332.374645
INFO: Total processing time for 17 host(s): 331.510445
INFO: Total processing time for 18 host(s): 332.030743
INFO: Total processing time for 19 host(s): 332.193198
INFO: Total processing time for 20 host(s): 333.933765
INFO: Total processing time for 21 host(s): 335.292953
INFO: Total processing time for 22 host(s): 337.253608
INFO: Total processing time for 23 host(s): 337.831493
INFO: Total processing time for 24 host(s): 339.024737
INFO: Total processing time for 25 host(s): 343.515044
INFO: Total processing time for 26 host(s): 339.759678
INFO: Total processing time for 27 host(s): 339.378998
INFO: Total processing time for 28 host(s): 339.640378
INFO: Total processing time for 29 host(s): 340.885614
INFO: Total processing time for 30 host(s): 341.836923
INFO: Total processing time for 31 host(s): 343.825758
INFO: Total processing time for 32 host(s): 344.176089
INFO: Total processing time for 33 host(s): 345.408518
INFO: Total processing time for 34 host(s): 347.15322
INFO: Total processing time for 35 host(s): 351.330649
INFO: Total processing time for 36 host(s): 347.640758
INFO: Total processing time for 37 host(s): 347.381126
INFO: Total processing time for 38 host(s): 347.053406
INFO: Total processing time for 39 host(s): 347.453166
INFO: Total processing time for 40 host(s): 347.84804
INFO: Total processing time for 41 host(s): 349.035272
INFO: Total processing time for 42 host(s): 349.41507
INFO: Total processing time for 43 host(s): 351.208072
INFO: Total processing time for 44 host(s): 351.788401
INFO: Total processing time for 45 host(s): 351.730259
INFO: Total processing time for 46 host(s): 515.693497
INFO: Total processing time for 47 host(s): 352.702677
INFO: Total processing time for 48 host(s): 353.418003
INFO: Total processing time for 49 host(s): 355.07111
INFO: Total processing time for 50 host(s): 354.622388
INFO: Total processing time for 51 host(s): 355.192521
INFO: Total processing time for 52 host(s): 355.283238
INFO: Total processing time for 53 host(s): 358.112329
INFO: Total processing time for 54 host(s): 357.717426
INFO: Total processing time for 55 host(s): 357.748707
INFO: Total processing time for 56 host(s): 358.902118
INFO: Total processing time for 57 host(s): 367.817594

File diff suppressed because it is too large Load diff

3
doc/dev/logs/2011-10-04 Normal file
View file

@ -0,0 +1,3 @@
Testing for single tests:
PYTHONPATH=$PYTHONPATH:$(pwd -P)/lib python3 -m unittest cdist.test.test_install.Install.test_explorer_ran

116
doc/dev/logs/2011-10-05 Normal file
View file

@ -0,0 +1,116 @@
Config/Install/Deploy/Run:
target host
remote_cmd_prefix - ssh user@bla sudo foo?????
remote_cp_prefix - cp statt scp oder so
debug -> env für alles += __debug
Storage/Metaobject/Tree? == Path?
base_dir?
nimmt objekte
Sammelt Objekte
Ist prepared hier?
Object
"Infos" / Datenhalde
Base_Dir-Abhängigkeit? - wo
out_dir - wo speichern
nur eigenes verzeichnis interessant?
-> nicht für shell code / aka gencode!
-> __global abhängigkeit
object.gencode()?
hast du type-explorer?
ja?
führe JEDEN remote aus
speichere ausgabe in object
nein:
fertig
hast du gencode-{local,remote}?
ja?
führe local oder remote aus
speichere ausgabe in s/^gen//
nein:
fertig
hast du code-{local,remote}?
ja?
führe local oder remote aus
nein:
fertig
ich habe ...
object_id
type
type.singleton() == False -> require object_id
parameter gegeben
requirements / order
type_explorer := methode zum ausführen?
cdist.object.Object(type, id)
methoden:
gen_code
code
run_manifest
manifest == ort
Type
singleton: ja / nein
install: ja / nein
type_explorer := liste
optional_parameter
required_parameter
TypeExplorer
verwandt oder == explorer
Verwandschaft klären!
sehr abhängig von base_dir!</behauptung :)>
- welche gibt es?
- was für optionen haben sie
cdist.type.Type("/path/to/type")
Tree/Path vieh, das liste von $_ speichert
Einfach iterieren
Explorer
execute(env)
env == __explorer -> nur im explorer
z.B. BaseExplorer oder andersherum GlobalExplorer
Manifest
Exec
wrapper um auszuführen,
error handling,
output redirection (variable, file, beides, socat :-)
--------------------------------------------------------------------------------
- base_dir (conf/, type, ...)
- manifest (initiale)
$methode_mit_inhalt_von_manifest?
run_manifest(code)
ob sinnvoll?
geht auch mit stdin oder datei
stdin -> muss in tmp-datei, für sh -e?
-
--------------------------------------------------------------------------------
save output of shell in buffer instead of displaying?
-> freedom to decide whether to display or not!

30
doc/dev/logs/2011-10-06 Normal file
View file

@ -0,0 +1,30 @@
GlobalExplorer
list_explorers()
list_explorers_names()
base_dir
__init__(name)
out_dir
env
name = id
path
return_code
return_value
--------------------------------------------------------------------------------
Exec:
normal:
scp /from/where $USER@$HOST:REMOTE_BASE/cdist-internal
ssh $USER@$HOST MY_CMD_THAT_NEEDS_TO_RUN_IN_BIN_SH (including ENV)
sudo:
scp $USER@$HOST:REMOTE_BASE/cdist-internal
ssh $USER@$HOST sudo MY_CMD_THAT_NEEDS_TO_RUN_IN_BIN_SH (including ENV)
chroot:
[sudo] cp file /chroot/THE_HOST_BASE/REMOTE_BASE/cdist-internal
[sudo] chroot /chroot MY_CMD_THAT_NEEDS_TO_RUN_IN_BIN_SH (including ENV)

View 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"

View file

@ -0,0 +1,8 @@
Debug:
DEBUG: Namespace(name=None, state='installed')
DEBUG: Object output dir = /home/users/nico/.tmp/tmpsdaonx/out/object/__package_pacman/zsh/.cdist
DEBUG: Object param dir = /home/users/nico/.tmp/tmpsdaonx/out/object/__package_pacman/zsh/.cdist/parameter
DEBUG: /home/users/nico/.tmp/tmpsdaonx/out/object/__package_pacman/zsh/.cdist/parameter/state<-state = installed
DEBUG: zsh:Writing requirements:
DEBUG: Finished __package_pacman/zsh{'state': 'installed', 'name': None}

Some files were not shown because too many files have changed in this diff Show more