From 837489ce8546806ae765fcc96eca0795a016a0bb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 15:54:08 +0200 Subject: [PATCH 01/11] remove obsolete preseed code from __package_apt Signed-off-by: Nico Schottelius --- conf/type/__package_apt/gencode-remote | 7 ------- 1 file changed, 7 deletions(-) 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)" From 27fd9cd61be398d9cabe14ee09ee66a73d89a381 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 16:05:47 +0200 Subject: [PATCH 02/11] add sudo example Signed-off-by: Nico Schottelius --- other/examples/types/__nico_sudo/README | 2 ++ .../types/__nico_sudo/files/sudo-nico | 13 ++++++++ other/examples/types/__nico_sudo/manifest | 30 ++++++++++++++++++ .../types/__nico_sudo/parameter/gencode | 31 +++++++++++++++++++ .../types/__nico_sudo/parameter/manifest | 31 +++++++++++++++++++ .../types/__nico_sudo/parameter/optional | 0 .../types/__nico_sudo/parameter/required | 0 other/examples/types/__nico_sudo/singleton | 0 8 files changed, 107 insertions(+) create mode 100644 other/examples/types/__nico_sudo/README create mode 100644 other/examples/types/__nico_sudo/files/sudo-nico create mode 100755 other/examples/types/__nico_sudo/manifest create mode 100644 other/examples/types/__nico_sudo/parameter/gencode create mode 100644 other/examples/types/__nico_sudo/parameter/manifest create mode 100644 other/examples/types/__nico_sudo/parameter/optional create mode 100644 other/examples/types/__nico_sudo/parameter/required create mode 100644 other/examples/types/__nico_sudo/singleton 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 From e3f3c48b220180fcfe61af953abe4c6610675444 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 20:34:35 +0200 Subject: [PATCH 03/11] wrap the whole program in the try...except KeyboardInterrupt block Signed-off-by: Nico Schottelius --- bin/cdist | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/bin/cdist b/bin/cdist index 14cff65a..78893b60 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 @@ -203,6 +187,23 @@ def emulator(): if __name__ == "__main__": try: + 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 = "__" + logging.basicConfig(format='%(levelname)s: %(message)s') if re.match(TYPE_PREFIX, os.path.basename(sys.argv[0])): @@ -214,3 +215,5 @@ if __name__ == "__main__": sys.exit(0) sys.exit(0) + + From 0344796d31f4cfdf5305b09b3e85d0aa162f3cfb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 20:36:35 +0200 Subject: [PATCH 04/11] restructure imports Signed-off-by: Nico Schottelius --- bin/cdist | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/cdist b/bin/cdist index 78893b60..0705f5bd 100755 --- a/bin/cdist +++ b/bin/cdist @@ -101,6 +101,9 @@ def install(args): def configinstall(args, mode): """Configure or install remote system""" + import multiprocessing + import time + try: process = {} failed_hosts = [] @@ -188,11 +191,9 @@ def emulator(): if __name__ == "__main__": try: import logging - import multiprocessing import os import re import sys - import time log = logging.getLogger("cdist") From 8b9e6780b8ec8de7781da3024fbb4eb18c16cbd8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 20:42:09 +0200 Subject: [PATCH 05/11] no need for a constant that's used two lines below Signed-off-by: Nico Schottelius --- bin/cdist | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/cdist b/bin/cdist index 0705f5bd..6a7a2d6d 100755 --- a/bin/cdist +++ b/bin/cdist @@ -195,19 +195,17 @@ if __name__ == "__main__": 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'))) - import cdist - - TYPE_PREFIX = "__" - 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() From 68d87c3023f280b5d017d5082c0c17939afefde8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 22:34:51 +0200 Subject: [PATCH 06/11] reference new and old variable, remove reference to cdist-config Signed-off-by: Nico Schottelius --- doc/man/cdist-reference.text.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index 57dbde4a..a80a6ce3 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 ----- @@ -186,6 +185,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 From 7d749540d83d4fb1417fc4798bb5b31322e403cf Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 22:40:17 +0200 Subject: [PATCH 07/11] changes for 2.0.4 Signed-off-by: Nico Schottelius --- doc/changelog | 3 +++ 1 file changed, 3 insertions(+) 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) From b7fdfb12e6952d6a047307b159999252339cd89b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 22:40:29 +0200 Subject: [PATCH 08/11] cleanups Signed-off-by: Nico Schottelius --- bin/cdist | 2 -- build | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/cdist b/bin/cdist index 6a7a2d6d..0f37db2e 100755 --- a/bin/cdist +++ b/bin/cdist @@ -214,5 +214,3 @@ if __name__ == "__main__": sys.exit(0) sys.exit(0) - - 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 From 3814dcd7287eaffdfdf6241c46d517dcffea8cf7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Oct 2011 23:12:35 +0200 Subject: [PATCH 09/11] remove old test ideas from todo Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 54 ------------------------------------------- 1 file changed, 54 deletions(-) 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 From c621af1e9f354e24b4dd1c00d60a3a29c796a7fc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 19 Oct 2011 14:55:16 +0200 Subject: [PATCH 10/11] begin tutorial sections Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-tutorial.text | 91 ++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/doc/man/man7/cdist-tutorial.text b/doc/man/man7/cdist-tutorial.text index 80135da9..c547b3e5 100644 --- a/doc/man/man7/cdist-tutorial.text +++ b/doc/man/man7/cdist-tutorial.text @@ -6,6 +6,97 @@ 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 +-------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INTRODUCTION From 07ef08938b25f0fd1f3af2de2fa6fc666df9ff67 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 19 Oct 2011 15:01:55 +0200 Subject: [PATCH 11/11] remove __debug, should not be setup by cdist Signed-off-by: Nico Schottelius --- doc/man/cdist-reference.text.sh | 5 ----- doc/man/man7/cdist-tutorial.text | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index a80a6ce3..257ca36e 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -165,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 diff --git a/doc/man/man7/cdist-tutorial.text b/doc/man/man7/cdist-tutorial.text index c547b3e5..71bf18c0 100644 --- a/doc/man/man7/cdist-tutorial.text +++ b/doc/man/man7/cdist-tutorial.text @@ -40,7 +40,11 @@ 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