diff --git a/bin/cdist b/bin/cdist index 14cff65a..0f37db2e 100755 --- a/bin/cdist +++ b/bin/cdist @@ -20,26 +20,10 @@ # # -import argparse -import logging -import multiprocessing -import os -import re -import sys -import time - -log = logging.getLogger("cdist") - -# 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'))) - -import cdist - -TYPE_PREFIX = "__" - def commandline(): """Parse command line""" + import argparse + import cdist.banner import cdist.config import cdist.install @@ -117,6 +101,9 @@ def install(args): def configinstall(args, mode): """Configure or install remote system""" + import multiprocessing + import time + try: process = {} failed_hosts = [] @@ -203,9 +190,22 @@ def emulator(): if __name__ == "__main__": try: + import logging + import os + import re + import sys + + import cdist + + log = logging.getLogger("cdist") + + # 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'))) + logging.basicConfig(format='%(levelname)s: %(message)s') - if re.match(TYPE_PREFIX, os.path.basename(sys.argv[0])): + if re.match("__", os.path.basename(sys.argv[0])): emulator() else: commandline() diff --git a/build b/build index 9e9fbf21..38fdac07 100755 --- a/build +++ b/build @@ -144,8 +144,9 @@ case "$1" in 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 diff --git a/conf/type/__package_apt/gencode-remote b/conf/type/__package_apt/gencode-remote index df8fd823..a5384ee3 100755 --- a/conf/type/__package_apt/gencode-remote +++ b/conf/type/__package_apt/gencode-remote @@ -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)" diff --git a/doc/changelog b/doc/changelog index aae0e04a..7403b466 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,3 +1,6 @@ +2.0.4: + * Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C) + 2.0.3: 2011-10-18 * Improved logging, added --verbose, by more quiet by default * Bugfix __user: Correct quoting (Steven Armstrong) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 8f5c6e4f..cb5b9158 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -2,60 +2,6 @@ - sanity checks: implement tests - stage_run() - - ensure that for every object in - cdist.core.Object.list_objects() is passed into - self.object_run() - - instantiate + overwrite + test - - object_prepare(): - - calls (in this order): - self.run_type_explorer(cdist_object) - self.run_type_manifest(cdist_object) - cdist_object.prepared = True - - object is prepared after function call - - - stage_prepare(): - - calls (in this order): - self.link_emulator() - self.run_global_explorers() - self.run_initial_manifest() - - - ensure that all objects are created :-) - - as defined in inital manifest + type manifests - - deploy_to() - - ensure self.stage_prepare() and self.stage_run() are - run. [ORDER] - - instantiate + overwrite + test - - deploy_and_cleanup() - - ensure self.deploy_to() + self.cleanup() are are run - run. [ORDER] - - instantiate + overwrite + test - - transfer_object_parameter() - - check that object parameters are transferred - - paths are setup correctly - - test via mock of remote_mkdir and transfer_path - - ensure self.remote_mkdir, self.transfer_path are run. [ORDER] - - instantiate + overwrite + test - - transfer_global_explorers() - - paths are setup correctly - - test via mock of self.remote_mkdir() and self.transfer_path() - - ensure self.remote_mkdir, self.transfer_path are run. [ORDER] - - instantiate + overwrite + test - - transfer_type_explorers(): - - Explorers are not transferred twice - - paths are setup correctly - - test via mock of self.remote_mkdir() and self.transfer_path() - - Explorers are transferred - - test via mock of self.remote_mkdir() and self.transfer_path() - - -------------------------------------------------------------------------------- - insert prefix into logger to distinguish between modules diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index 57dbde4a..257ca36e 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -133,7 +133,6 @@ out/object//explorers:: tmp_dir:: A tempdir and a tempfile is used by cdist internally, which will be removed when the scripts end automatically. - See cdist-config(1). TYPES ----- @@ -166,11 +165,6 @@ changed:: ENVIRONMENT VARIABLES --------------------- -__debug:: - If this variable is setup, cdist runs in debug mode. - You can use this information, to only output stuff in debug - mode as well. - Available for: initial manifest, type manifest, gencode, code __explorer:: Directory that contains all global explorers. Available for: explorer @@ -186,6 +180,7 @@ __object:: __object_id:: The type unique object id. Available for: type manifest, type explorer, type gencode +__self:: __object_fq:: The full qualified name of the current object. Available for: type manifest, type explorer, type gencode diff --git a/doc/man/man7/cdist-tutorial.text b/doc/man/man7/cdist-tutorial.text index 80135da9..71bf18c0 100644 --- a/doc/man/man7/cdist-tutorial.text +++ b/doc/man/man7/cdist-tutorial.text @@ -6,6 +6,101 @@ Nico Schottelius NAME ---- cdist-tutorial - a guided introduction into cdist + + + +YOUR FIRST CONFIGURATION +------------------------ + + +DEFINE STATE IN THE INITAL MANIFEST +----------------------------------- + +The initial manifest is used to map +configurations to a host. + +USING SOME BASIC TYPES +---------------------- +what is a type, how to use it, + + +CREATING YOUR FIRST OWN TYPE +---------------------------- + + + +USE A TYPE TO BUNDLE FUNCTIONALITY +---------------------------------- + + +USING EXPLORERS +--------------- +global, type explorer + + +DEBUGGING YOUR TYPES +-------------------- +__debug:: + If this variable is setup, cdist runs in debug mode. + You can use this information, to only output stuff in debug + mode as well. + Available for: initial manifest, type manifest, gencode, code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INTRODUCTION diff --git a/other/examples/types/__nico_sudo/README b/other/examples/types/__nico_sudo/README new file mode 100644 index 00000000..5e4cf0d3 --- /dev/null +++ b/other/examples/types/__nico_sudo/README @@ -0,0 +1,2 @@ +Configure sudoers file to be included. Different types may do so, +this one simply uses the "nico" file to store the configuration. diff --git a/other/examples/types/__nico_sudo/files/sudo-nico b/other/examples/types/__nico_sudo/files/sudo-nico new file mode 100644 index 00000000..d904c319 --- /dev/null +++ b/other/examples/types/__nico_sudo/files/sudo-nico @@ -0,0 +1,13 @@ +# +# Cdist managed file +# + +# Personal one: nico, shared one: lyni +User_Alias NICO = nico, lyni + +Defaults timestamp_timeout=5 +Defaults !tty_tickets + +# Give out permissions +NICO ALL=(ALL) ALL +NICO ALL=(ALL) NOPASSWD: /usr/sbin/pm-suspend diff --git a/other/examples/types/__nico_sudo/manifest b/other/examples/types/__nico_sudo/manifest new file mode 100755 index 00000000..5de33973 --- /dev/null +++ b/other/examples/types/__nico_sudo/manifest @@ -0,0 +1,30 @@ +#!/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 . +# +# + +destination=/etc/sudoers.d/nico +source="$__type/files/sudo-nico" + +__package sudo --state installed +__directory /etc/sudoers.d --parents yes + +require="__directory/etc/sudoers.d" \ + __file "$destination" --source "$source" --mode 0440 + diff --git a/other/examples/types/__nico_sudo/parameter/gencode b/other/examples/types/__nico_sudo/parameter/gencode new file mode 100644 index 00000000..74792abf --- /dev/null +++ b/other/examples/types/__nico_sudo/parameter/gencode @@ -0,0 +1,31 @@ +#!/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 . +# +# +# USEFUL DESCRIPTION +# + +# +# 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) +# +# + diff --git a/other/examples/types/__nico_sudo/parameter/manifest b/other/examples/types/__nico_sudo/parameter/manifest new file mode 100644 index 00000000..c696eda6 --- /dev/null +++ b/other/examples/types/__nico_sudo/parameter/manifest @@ -0,0 +1,31 @@ +#!/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 . +# +# +# USEFUL DESCRIPTION +# + +# +# 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) +# +# + diff --git a/other/examples/types/__nico_sudo/parameter/optional b/other/examples/types/__nico_sudo/parameter/optional new file mode 100644 index 00000000..e69de29b diff --git a/other/examples/types/__nico_sudo/parameter/required b/other/examples/types/__nico_sudo/parameter/required new file mode 100644 index 00000000..e69de29b diff --git a/other/examples/types/__nico_sudo/singleton b/other/examples/types/__nico_sudo/singleton new file mode 100644 index 00000000..e69de29b