From 6e7ebf6de1c221446ec5dbe1cc569230792c7e29 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 2 Nov 2011 17:54:03 +0100 Subject: [PATCH 01/45] todo++ Signed-off-by: Steven Armstrong --- doc/dev/todo/steven | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index f8e13a45..2aacaa42 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -1,3 +1,10 @@ +autorequire: + - objects defined in type manifests should be automatically prerequisites of the current object + - __foo/some-id + __other other-id --state present + => require="__other/other-id" __foo/some-id + + metaparameters: - steal the metaparameters from puppet: From 0d05e61b85cb6a82ea9f15a068b4deb4d763e70a Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 2 Nov 2011 23:57:13 +0100 Subject: [PATCH 02/45] tests and fixtures for emulator autorequire Signed-off-by: Steven Armstrong --- lib/cdist/test/emulator/__init__.py | 31 ++++++++++++++++++- .../test/emulator/fixtures/conf/manifest/init | 3 ++ .../fixtures/conf/type/__moon/manifest | 8 +++++ .../conf/type/__moon/parameter/optional | 1 + .../conf/type/__moon/parameter/required | 1 + .../fixtures/conf/type/__planet/manifest | 8 +++++ .../conf/type/__planet/parameter/optional | 1 + .../fixtures/conf/type/__saturn/manifest | 4 +++ .../fixtures/conf/type/__saturn/singleton | 0 9 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 lib/cdist/test/emulator/fixtures/conf/manifest/init create mode 100755 lib/cdist/test/emulator/fixtures/conf/type/__moon/manifest create mode 100644 lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/optional create mode 100644 lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/required create mode 100755 lib/cdist/test/emulator/fixtures/conf/type/__planet/manifest create mode 100644 lib/cdist/test/emulator/fixtures/conf/type/__planet/parameter/optional create mode 100755 lib/cdist/test/emulator/fixtures/conf/type/__saturn/manifest create mode 100644 lib/cdist/test/emulator/fixtures/conf/type/__saturn/singleton diff --git a/lib/cdist/test/emulator/__init__.py b/lib/cdist/test/emulator/__init__.py index 91150334..7b30fba1 100644 --- a/lib/cdist/test/emulator/__init__.py +++ b/lib/cdist/test/emulator/__init__.py @@ -22,6 +22,7 @@ import os import shutil +import cdist from cdist import test from cdist.exec import local from cdist import emulator @@ -29,7 +30,6 @@ from cdist import core local_base_path = test.cdist_base_path - class EmulatorTestCase(test.CdistTestCase): def setUp(self): @@ -73,3 +73,32 @@ class EmulatorTestCase(test.CdistTestCase): os.environ['require'] = '__file/bad/id/with/.cdist/inside' emu = emulator.Emulator(argv) self.assertRaises(core.IllegalObjectIdError, emu.run) + + +import os.path as op +my_dir = op.abspath(op.dirname(__file__)) +fixtures = op.join(my_dir, 'fixtures') + +class AutoRequireEmulatorTestCase(test.CdistTestCase): + + def setUp(self): + self.temp_dir = self.mkdtemp() + self.target_host = 'localhost' + out_path = self.temp_dir + _local_base_path = fixtures + self.local = local.Local(self.target_host, _local_base_path, out_path) + self.local.create_directories() + self.local.link_emulator(cdist.test.cdist_exec_path) + self.manifest = core.Manifest(self.target_host, self.local) + + def tearDown(self): + shutil.rmtree(self.temp_dir) + + def test_autorequire(self): + initial_manifest = os.path.join(self.local.manifest_path, "init") + self.manifest.run_initial_manifest(initial_manifest) + cdist_type = core.Type(self.local.type_path, '__saturn') + cdist_object = core.Object(cdist_type, self.local.object_path, 'singleton') + self.manifest.run_type_manifest(cdist_object) + expected = ['__planet/Saturn', '__moon/Prometheus'] + self.assertEqual(sorted(cdist_object.requirements), sorted(expected)) diff --git a/lib/cdist/test/emulator/fixtures/conf/manifest/init b/lib/cdist/test/emulator/fixtures/conf/manifest/init new file mode 100755 index 00000000..9fa1aa53 --- /dev/null +++ b/lib/cdist/test/emulator/fixtures/conf/manifest/init @@ -0,0 +1,3 @@ +#!/bin/sh + +__saturn diff --git a/lib/cdist/test/emulator/fixtures/conf/type/__moon/manifest b/lib/cdist/test/emulator/fixtures/conf/type/__moon/manifest new file mode 100755 index 00000000..362be5a1 --- /dev/null +++ b/lib/cdist/test/emulator/fixtures/conf/type/__moon/manifest @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ -f "$__object/parameter/name" ]; then + name="(cat "$__object/parameter/name")" +else + name="$__object_id" + echo "$name" > "$__object/parameter/name" +fi diff --git a/lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/optional b/lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/optional new file mode 100644 index 00000000..f121bdbf --- /dev/null +++ b/lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/optional @@ -0,0 +1 @@ +name diff --git a/lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/required b/lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/required new file mode 100644 index 00000000..729a5167 --- /dev/null +++ b/lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/required @@ -0,0 +1 @@ +planet diff --git a/lib/cdist/test/emulator/fixtures/conf/type/__planet/manifest b/lib/cdist/test/emulator/fixtures/conf/type/__planet/manifest new file mode 100755 index 00000000..362be5a1 --- /dev/null +++ b/lib/cdist/test/emulator/fixtures/conf/type/__planet/manifest @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ -f "$__object/parameter/name" ]; then + name="(cat "$__object/parameter/name")" +else + name="$__object_id" + echo "$name" > "$__object/parameter/name" +fi diff --git a/lib/cdist/test/emulator/fixtures/conf/type/__planet/parameter/optional b/lib/cdist/test/emulator/fixtures/conf/type/__planet/parameter/optional new file mode 100644 index 00000000..f121bdbf --- /dev/null +++ b/lib/cdist/test/emulator/fixtures/conf/type/__planet/parameter/optional @@ -0,0 +1 @@ +name diff --git a/lib/cdist/test/emulator/fixtures/conf/type/__saturn/manifest b/lib/cdist/test/emulator/fixtures/conf/type/__saturn/manifest new file mode 100755 index 00000000..38b8cbf3 --- /dev/null +++ b/lib/cdist/test/emulator/fixtures/conf/type/__saturn/manifest @@ -0,0 +1,4 @@ +#!/bin/sh + +__planet Saturn +require="__planet/Saturn" __moon Prometheus --planet Saturn diff --git a/lib/cdist/test/emulator/fixtures/conf/type/__saturn/singleton b/lib/cdist/test/emulator/fixtures/conf/type/__saturn/singleton new file mode 100644 index 00000000..e69de29b From 7d0238682b1f9eac6ad8ce3b4d0e636433f93eae Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 2 Nov 2011 23:58:18 +0100 Subject: [PATCH 03/45] implement autorequire in emulator Signed-off-by: Steven Armstrong --- lib/cdist/emulator.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index 4880c6e6..5b842a91 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -75,6 +75,7 @@ class Emulator(object): self.commandline() self.setup_object() self.record_requirements() + self.record_auto_requirements() self.log.debug("Finished %s %s" % (self.cdist_object.path, self.parameters)) def __init_log(self): @@ -178,3 +179,12 @@ class Emulator(object): # Record / Append source self.cdist_object.source.append(self.object_source) + + def record_auto_requirements(self): + """An object shall automatically depend on all objects that it defined in it's type manifest. + """ + # __object_name is the name of the object whose type manifest is currenlty executed + __object_name = os.environ.get('__object_name', None) + if __object_name: + _object = self.cdist_object.object_from_name(__object_name) + _object.requirements.append(self.cdist_object.name) From c58ec7e4efbf700309c60277baf8a3c91c408a09 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 3 Nov 2011 00:25:06 +0100 Subject: [PATCH 04/45] prevent circular dependencies Signed-off-by: Steven Armstrong --- lib/cdist/emulator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index 5b842a91..481e734a 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -187,4 +187,6 @@ class Emulator(object): __object_name = os.environ.get('__object_name', None) if __object_name: _object = self.cdist_object.object_from_name(__object_name) - _object.requirements.append(self.cdist_object.name) + # prevent circular dependencies + if not _object.name in self.cdist_object.requirements: + _object.requirements.append(self.cdist_object.name) From b9301c8194e5a2fcf153ac5e27d04047773ac64e Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 14 Nov 2011 23:05:13 +0100 Subject: [PATCH 05/45] bugfix: process names dont start with slash Signed-off-by: Steven Armstrong --- conf/type/__process/explorer/runs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 2bfa8f84..240ebef9 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -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 From d7623fcf217e5872ab60794b567c97068566b6df Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 14 Nov 2011 23:18:44 +0100 Subject: [PATCH 06/45] pgrep -x -f is to restrictive -> impossible to guess/match Signed-off-by: Steven Armstrong --- conf/type/__process/explorer/runs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 240ebef9..3ac9ce2f 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -27,4 +27,4 @@ else name="$__object_id" fi -pgrep -x -f "$name" || true +pgrep -x "$name" || true From 98ff723b2406f8cef902d5fab87c794092e42904 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 15 Nov 2011 09:20:27 +0100 Subject: [PATCH 07/45] add another example for __process Signed-off-by: Nico Schottelius --- conf/type/__process/man.text | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf/type/__process/man.text b/conf/type/__process/man.text index fd3bcf49..065beeef 100644 --- a/conf/type/__process/man.text +++ b/conf/type/__process/man.text @@ -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.*" -------------------------------------------------------------------------------- From 7d10560a6145f2e6fe8baf2330fd941a92e1689a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 15 Nov 2011 09:21:07 +0100 Subject: [PATCH 08/45] Revert "pgrep -x -f is to restrictive -> impossible to guess/match" It's not, regexp are your friends :-) This reverts commit d7623fcf217e5872ab60794b567c97068566b6df. --- conf/type/__process/explorer/runs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 3ac9ce2f..240ebef9 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -27,4 +27,4 @@ else name="$__object_id" fi -pgrep -x "$name" || true +pgrep -x -f "$name" || true From d706e8ef03eb45cc13f3161598ecf227290718b7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 16 Nov 2011 08:07:19 +0100 Subject: [PATCH 09/45] more changes for 2.0.4 Signed-off-by: Nico Schottelius --- doc/changelog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/changelog b/doc/changelog index 7217a6f2..87fad8c0 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,9 +1,10 @@ -2.0.4: +2.0.4: 2011-11-16 * Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C) * 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 * New Type: __cron (Steven Armstrong) + * Documentation: Many examples for use of __remote_* (Steven Armstrong) 2.0.3: 2011-10-18 * Improved logging, added --verbose, by more quiet by default From ff5fb5dbdb60f76db62e48ae94e3eb279311d326 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 16 Nov 2011 08:10:50 +0100 Subject: [PATCH 10/45] remove obsolete cdist video link (to be replaced with new video) Signed-off-by: Nico Schottelius --- README | 2 -- build | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README b/README index 1c2139cc..c3105e26 100644 --- a/README +++ b/README @@ -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 diff --git a/build b/build index 38fdac07..919360ae 100755 --- a/build +++ b/build @@ -26,13 +26,16 @@ # exit on any error #set -e +version=$(git describe) + # Manpage and HTML 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 +WEBDOCBASE=$WEBBASE/$version WEBPAGE=${WEBBASE}.mdwn # Documentation From 56d783f612e03bc4bc570112fc9711953c5c2ffa Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 17 Nov 2011 13:03:56 +0100 Subject: [PATCH 11/45] tests and fixtures for type parameters with dashes Signed-off-by: Steven Armstrong --- lib/cdist/test/emulator/__init__.py | 39 +++++++++++++++++++ .../parameter/required | 1 + 2 files changed, 40 insertions(+) create mode 100644 lib/cdist/test/emulator/fixtures/conf/type/__arguments_with_dashes/parameter/required diff --git a/lib/cdist/test/emulator/__init__.py b/lib/cdist/test/emulator/__init__.py index 8f1b9776..5c920770 100644 --- a/lib/cdist/test/emulator/__init__.py +++ b/lib/cdist/test/emulator/__init__.py @@ -88,3 +88,42 @@ class EmulatorTestCase(test.CdistTestCase): emu = emulator.Emulator(argv) emu.run() # if we get here all is fine + + +import os.path as op +my_dir = op.abspath(op.dirname(__file__)) +fixtures = op.join(my_dir, 'fixtures') + +class ArgumentsWithDashesTestCase(test.CdistTestCase): + + def setUp(self): + self.temp_dir = self.mkdtemp() + self.target_host = 'localhost' + out_path = self.temp_dir + handle, self.script = self.mkstemp(dir=self.temp_dir) + os.close(handle) + _local_base_path = fixtures + self.local = local.Local(self.target_host, _local_base_path, out_path) + self.local.create_directories() + self.local.link_emulator(test.cdist_exec_path) + self.env = { + 'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']), + '__target_host': self.target_host, + '__global': self.local.out_path, + '__cdist_type_base_path': self.local.type_path, # for use in type emulator + '__manifest': self.local.manifest_path, + '__cdist_manifest': self.script, + } + + def tearDown(self): + shutil.rmtree(self.temp_dir) + + def test_arguments_with_dashes(self): + argv = ['__arguments_with_dashes', 'some-id', '--with-dash', 'some value'] + os.environ.update(self.env) + emu = emulator.Emulator(argv) + emu.run() + + cdist_type = core.Type(self.local.type_path, '__arguments_with_dashes') + cdist_object = core.Object(cdist_type, self.local.object_path, 'some-id') + self.assertTrue('with-dash' in cdist_object.parameters) diff --git a/lib/cdist/test/emulator/fixtures/conf/type/__arguments_with_dashes/parameter/required b/lib/cdist/test/emulator/fixtures/conf/type/__arguments_with_dashes/parameter/required new file mode 100644 index 00000000..02fabce1 --- /dev/null +++ b/lib/cdist/test/emulator/fixtures/conf/type/__arguments_with_dashes/parameter/required @@ -0,0 +1 @@ +with-dash From 68f66af21a2ed23f36d926dde0e7d24e54bc7346 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 17 Nov 2011 13:04:39 +0100 Subject: [PATCH 12/45] implement: accept parameters with dashes Signed-off-by: Steven Armstrong --- lib/cdist/emulator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index 7ae89294..8fd03d4d 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -97,10 +97,10 @@ class Emulator(object): for parameter in self.cdist_type.optional_parameters: argument = "--" + parameter - parser.add_argument(argument, action='store', required=False) + parser.add_argument(argument, dest=parameter, action='store', required=False) for parameter in self.cdist_type.required_parameters: argument = "--" + parameter - parser.add_argument(argument, action='store', required=True) + parser.add_argument(argument, dest=parameter, action='store', required=True) # If not singleton support one positional parameter if not self.cdist_type.is_singleton: From 79c1f4cb4d018a5c72ef566f2743dea0fdee9af3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 17 Nov 2011 13:25:47 +0100 Subject: [PATCH 13/45] document - support Signed-off-by: Nico Schottelius --- build | 8 ++++---- doc/changelog | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build b/build index 919360ae..085bcdf1 100755 --- a/build +++ b/build @@ -35,7 +35,7 @@ A2XH="a2x -f xhtml --no-xmllint -a encoding=UTF-8" # Developer webbase WEBDIR=$HOME/niconetz WEBBASE=$WEBDIR/software/cdist -WEBDOCBASE=$WEBBASE/$version +WEBMAN=$WEBBASE/man/$version WEBPAGE=${WEBBASE}.mdwn # Documentation @@ -98,9 +98,9 @@ case "$1" in ;; web) - cp README ${WEBDIR}/${WEBPAGE} - rm -rf ${WEBDIR}/${WEBBASE}/man - mkdir -p ${WEBDIR}/${WEBBASE}/man/man1 ${WEBDIR}/${WEBBASE}/man/man7 + cp README ${WEBPAGE} + rm -rf ${WEBMAN} + mkdir -p ${WEBMAN}/man1 ${WEBMAN}/man7 rm -rf ${WEBDIR}/${WEBBASE}/speeches && mkdir ${WEBDIR}/${WEBBASE}/speeches diff --git a/doc/changelog b/doc/changelog index 87fad8c0..e0841f67 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,10 +1,11 @@ -2.0.4: 2011-11-16 +2.0.4: * 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 - * New Type: __cron (Steven Armstrong) * Documentation: Many examples for use of __remote_* (Steven Armstrong) + * New Type: __cron (Steven Armstrong) 2.0.3: 2011-10-18 * Improved logging, added --verbose, by more quiet by default From e380cdf7de5b981b3fa0c80df05be2775652d68e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 17 Nov 2011 15:30:21 +0100 Subject: [PATCH 14/45] build.sh is old Signed-off-by: Nico Schottelius --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index c3105e26..ff1293e8 100644 --- a/README +++ b/README @@ -131,7 +131,7 @@ To install cdist, execute the following commands: export PATH=$PATH:$(pwd -P)/bin # If you want the manpages - ./build.sh man + ./build man export MANPATH=$MANPATH:$(pwd -P)/doc/man @@ -178,7 +178,7 @@ 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. From cbfcd01d4fff773e1e2824cc526869e682915d85 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 17 Nov 2011 21:51:50 +0100 Subject: [PATCH 15/45] ++bugfix Signed-off-by: Steven Armstrong --- other/examples/remote/schroot-uri | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/other/examples/remote/schroot-uri b/other/examples/remote/schroot-uri index 06dce369..a23277ec 100755 --- a/other/examples/remote/schroot-uri +++ b/other/examples/remote/schroot-uri @@ -49,7 +49,7 @@ my_name="${0##*/}" mode="$1"; shift log() { - #echo "$@" | logger -t "cdist-$my_name-$mode" + echo "$@" | logger -t "cdist-$my_name-$mode" : } @@ -112,7 +112,9 @@ fi case "$mode" in exec) - code="$exec_prefix schroot -c $schroot_name -- $@" + # In exec mode the first argument is the __target_host which we already got from env. Get rid of it. + shift + code="$exec_prefix schroot -c $schroot_name -- sh -c '$@'" ;; copy) # get directory for given chroot_name From c59b2839cd2be04b7c7ebb4873a3e3a390ec597a Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 08:56:29 +0100 Subject: [PATCH 16/45] Export target_host so remote_copy script has access to it Signed-off-by: Steven Armstrong --- conf/type/__file/gencode-local | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/type/__file/gencode-local b/conf/type/__file/gencode-local index 0c6c249d..ae8625b5 100755 --- a/conf/type/__file/gencode-local +++ b/conf/type/__file/gencode-local @@ -31,6 +31,8 @@ if [ -f "$__object/parameter/source" ]; then remote_cksum="$(cat "$__object/explorer/cksum")" if [ "$local_cksum" != "$remote_cksum" ]; then + # Export target_host so remote_copy script has access to it + echo "export __target_host=\"$__target_host\"" echo "$__remote_copy" "$source" "${__target_host}:${destination}" fi else From d76d013b3c280d9641697bffe28441a30b14b107 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 10:39:21 +0100 Subject: [PATCH 17/45] check env [TODO] Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index f424a81d..14a643ea 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -13,6 +13,8 @@ TESTS - multiple defines of object: - fail if different parameters - succeed if same parameters +- verify that all env variables in doc/man/cdist-reference.text.sh + exist in the right stages USER INTERFACE -------------- From df258cf330cb015ac233a09fda0c863190582942 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 11:10:32 +0100 Subject: [PATCH 18/45] +__target_user comment Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 14a643ea..de043a07 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -16,6 +16,8 @@ TESTS - verify that all env variables in doc/man/cdist-reference.text.sh exist in the right stages + __target_user - unneeded? + USER INTERFACE -------------- - add support $__tmp? From 7c8f9e8b9873f5324eff0cbe8d8b00b80136c018 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 14:05:26 +0100 Subject: [PATCH 19/45] remove reference to __target_user - has never been used and is not implemented anymore Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 2 -- doc/man/cdist-reference.text.sh | 3 --- 2 files changed, 5 deletions(-) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index de043a07..14a643ea 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -16,8 +16,6 @@ TESTS - verify that all env variables in doc/man/cdist-reference.text.sh exist in the right stages - __target_user - unneeded? - USER INTERFACE -------------- - add support $__tmp? diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index 9127096c..0a7b551e 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -188,9 +188,6 @@ __object_name:: __target_host:: The host we are deploying to. Available for: initial manifest, type manifest, type gencode -__target_user:: - User to use for authentication on remote host. - Currently static in core. __type:: Path to the current type. Available for: type manifest, type gencode From 31403722ce240e9a42518639987eaa80b4afdf25 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 14:36:51 +0100 Subject: [PATCH 20/45] todo++ Signed-off-by: Steven Armstrong --- doc/dev/todo/TAKEME | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 14a643ea..be76b040 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -15,6 +15,8 @@ TESTS - succeed if same parameters - verify that all env variables in doc/man/cdist-reference.text.sh exist in the right stages +- test DependencyResolver + USER INTERFACE -------------- From 654e19f28bf1d78b84d30bf3b616c4e75c2b258d Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 14:40:25 +0100 Subject: [PATCH 21/45] mark _run_command as private Signed-off-by: Steven Armstrong --- conf/type/__file/gencode-local | 2 -- lib/cdist/exec/remote.py | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/conf/type/__file/gencode-local b/conf/type/__file/gencode-local index ae8625b5..0c6c249d 100755 --- a/conf/type/__file/gencode-local +++ b/conf/type/__file/gencode-local @@ -31,8 +31,6 @@ if [ -f "$__object/parameter/source" ]; then remote_cksum="$(cat "$__object/explorer/cksum")" if [ "$local_cksum" != "$remote_cksum" ]; then - # Export target_host so remote_copy script has access to it - echo "export __target_host=\"$__target_host\"" echo "$__remote_copy" "$source" "${__target_host}:${destination}" fi else diff --git a/lib/cdist/exec/remote.py b/lib/cdist/exec/remote.py index 433f4cbc..87db7273 100644 --- a/lib/cdist/exec/remote.py +++ b/lib/cdist/exec/remote.py @@ -91,7 +91,7 @@ class Remote(object): self.rmdir(destination) command = self._copy.split() command.extend(["-r", source, self.target_host + ":" + destination]) - self.run_command(command) + self._run_command(command) def run(self, command, env=None, return_output=False): """Run the given command with the given environment on the remote side. @@ -102,9 +102,9 @@ class Remote(object): cmd = self._exec.split() cmd.append(self.target_host) cmd.extend(command) - return self.run_command(cmd, env=env, return_output=return_output) + return self._run_command(cmd, env=env, return_output=return_output) - def run_command(self, command, env=None, return_output=False): + def _run_command(self, command, env=None, return_output=False): """Run the given command with the given environment. Return the output as a string. From 98dec302a603c599a9300f0259166854e96d32d1 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 14:44:32 +0100 Subject: [PATCH 22/45] export __target_host for use in __remote_{copy,exec} scripts Signed-off-by: Steven Armstrong --- lib/cdist/exec/local.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/cdist/exec/local.py b/lib/cdist/exec/local.py index 41094faa..0b67c747 100644 --- a/lib/cdist/exec/local.py +++ b/lib/cdist/exec/local.py @@ -95,6 +95,12 @@ class Local(object): """ assert isinstance(command, (list, tuple)), "list or tuple argument expected, got: %s" % command self.log.debug("Local run: %s", command) + + if env is None: + env = {} + # Export __target_host for use in __remote_{copy,exec} scripts + env['__target_host'] = self.target_host + try: if return_output: return subprocess.check_output(command, env=env).decode() @@ -114,8 +120,13 @@ class Local(object): command.append(script) self.log.debug("Local run script: %s", command) - if env: - self.log.debug("Local run script env: %s", env) + + if env is None: + env = {} + # Export __target_host for use in __remote_{copy,exec} scripts + env['__target_host'] = self.target_host + + self.log.debug("Local run script env: %s", env) try: if return_output: From bf133253039a409479463902cb2c9fb74ceb59e0 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 14:56:59 +0100 Subject: [PATCH 23/45] if env is not given, os.environ is used -> need to also do that Signed-off-by: Steven Armstrong --- lib/cdist/exec/local.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cdist/exec/local.py b/lib/cdist/exec/local.py index 0b67c747..613f5cf2 100644 --- a/lib/cdist/exec/local.py +++ b/lib/cdist/exec/local.py @@ -97,7 +97,7 @@ class Local(object): self.log.debug("Local run: %s", command) if env is None: - env = {} + env = os.environ.copy() # Export __target_host for use in __remote_{copy,exec} scripts env['__target_host'] = self.target_host @@ -122,7 +122,7 @@ class Local(object): self.log.debug("Local run script: %s", command) if env is None: - env = {} + env = os.environ.copy() # Export __target_host for use in __remote_{copy,exec} scripts env['__target_host'] = self.target_host From be29ce0f2e8453621ab339dc04b477c04695692e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 15:26:10 +0100 Subject: [PATCH 24/45] 2.0.4 has autorequire enabled Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index e0841f67..91b21259 100644 --- a/doc/changelog +++ b/doc/changelog @@ -5,6 +5,7 @@ * 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 From 3c823c9192e00fddf908b6505640f32e05775502 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 15:36:31 +0100 Subject: [PATCH 25/45] setup release date Signed-off-by: Nico Schottelius --- doc/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog b/doc/changelog index 91b21259..7e17a75c 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,4 +1,4 @@ -2.0.4: +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) From 092a9aa5b89ad072cdb3f3bbecd7de999f53ef24 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 15:37:53 +0100 Subject: [PATCH 26/45] update version in lib/ Signed-off-by: Nico Schottelius --- lib/cdist/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cdist/__init__.py b/lib/cdist/__init__.py index abdadf62..85892fec 100644 --- a/lib/cdist/__init__.py +++ b/lib/cdist/__init__.py @@ -34,7 +34,7 @@ BANNER = """ "P' "" "" """ DOT_CDIST = ".cdist" -VERSION = "2.0.3" +VERSION = "2.0.4" import os From 6b0935c2074cd4b4a3f8901735499901de87e381 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 15:43:06 +0100 Subject: [PATCH 27/45] /__self/__object_name/ Signed-off-by: Steven Armstrong --- conf/type/__apt_ppa/manifest | 2 +- conf/type/__autofs_map/manifest | 2 +- conf/type/__autofs_master/manifest | 2 +- conf/type/__package/manifest | 2 +- conf/type/__partition_msdos/manifest | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/type/__apt_ppa/manifest b/conf/type/__apt_ppa/manifest index 5aa84931..04c66ce0 100755 --- a/conf/type/__apt_ppa/manifest +++ b/conf/type/__apt_ppa/manifest @@ -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 diff --git a/conf/type/__autofs_map/manifest b/conf/type/__autofs_map/manifest index 74672e46..d86ea799 100755 --- a/conf/type/__autofs_map/manifest +++ b/conf/type/__autofs_map/manifest @@ -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 diff --git a/conf/type/__autofs_master/manifest b/conf/type/__autofs_master/manifest index e37a5d34..e429842e 100755 --- a/conf/type/__autofs_master/manifest +++ b/conf/type/__autofs_master/manifest @@ -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 diff --git a/conf/type/__package/manifest b/conf/type/__package/manifest index b331d32d..765ece36 100755 --- a/conf/type/__package/manifest +++ b/conf/type/__package/manifest @@ -49,4 +49,4 @@ for property in $(ls .); do fi done -require="$__self" __package_$type "$@" +require="$__object_name" __package_$type "$@" diff --git a/conf/type/__partition_msdos/manifest b/conf/type/__partition_msdos/manifest index 0d73c405..21e43856 100755 --- a/conf/type/__partition_msdos/manifest +++ b/conf/type/__partition_msdos/manifest @@ -38,4 +38,4 @@ if [ ! -f "$__object/parameter/size" ]; then fi # pull in the type that actually does something with the above parameters -require="$__self" __partition_msdos_apply +require="$__object_name" __partition_msdos_apply From 32fa32bd52520cfad49d1887066ef5a1f8593df8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 15:45:59 +0100 Subject: [PATCH 28/45] improve release script Signed-off-by: Nico Schottelius --- doc/dev/releasechecklist | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/doc/dev/releasechecklist b/doc/dev/releasechecklist index fef1f53b..6bc0a77c 100755 --- a/doc/dev/releasechecklist +++ b/doc/dev/releasechecklist @@ -1,25 +1,32 @@ -#!/bin/sh -e +#!/bin/sh +# Nico Schottelius -files="bin/cdist-config doc/changelog" +files="doc/changelog lib/cdist/__init__.py" # Stuff to take care of when doing a release echo "Preparing next release" # Ensure documentation builds cleanly -./build.sh clean && ./build.sh man +echo "Testing documentation..." +./build clean && ./build man || exit 1 + +echo "Ensure you fixed/prepared version files: $files" +read wait # get version -version=$(awk -F'=' '/^__cdist_version/ { print $2 }' bin/cdist-config | sed 's/"//g') +lib_version=$(grep ^VERSION lib/cdist/__init__.py | sed -e 's/.*= //' -e 's/"//g') +changelog_version=$(head -n1 doc/changelog | sed 's/:.*//') +git_version=$(git describe) + +if [ "$lib_version" != "$changelog_version -o "$changelog_version" != "$git_version" ]; then + echo "Messed up versions, not releasing" + exit 1 +fi +version=$git_version # get target branch branch=${version%.?} -# adjust version and release date -vi $files - -# Commit stuff -git commit $files - # add tag printf "Enter description for %s>" "$version" read tagmessage @@ -31,5 +38,5 @@ git merge master git checkout master # Publish manpages and sourcecode -./build.sh web -./build.sh pub +./build web +./build pub From 6495bc872f27f4ba2b59cceafd12041b6447aa2f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 15:48:36 +0100 Subject: [PATCH 29/45] ++todo Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 2f9bb844..f8c2d6da 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,6 +1,10 @@ +- check speech publishing + - and speeches, which may be outdated as well + +- write tutorial + - Fix / rewrite cdist-quickstart -- write tutorial!!!!!!!!! - like ccollect! - include ssh control master! - add local/ hint (and add to git) From ee7f30c052ebb46ab90a3f2ecca4233071942025 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 15:51:18 +0100 Subject: [PATCH 30/45] more version support for documentation Signed-off-by: Nico Schottelius --- build | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build b/build index 085bcdf1..e3a6e7f9 100755 --- a/build +++ b/build @@ -102,13 +102,14 @@ case "$1" in rm -rf ${WEBMAN} mkdir -p ${WEBMAN}/man1 ${WEBMAN}/man7 - rm -rf ${WEBDIR}/${WEBBASE}/speeches && mkdir ${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 ${WEBDIR}/${WEBBASE}/man/man1 - cp ${MAN7DSTDIR}/*.html ${WEBDIR}/${WEBBASE}/man/man7 - cp ${SPEECHESDIR}/*.pdf ${WEBDIR}/${WEBBASE}/speeches + 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 From e33000289986cff3e04dce0ad14f189a3ba49664 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 15:58:26 +0100 Subject: [PATCH 31/45] more verbose, add git tag during release, check lib and changelog Signed-off-by: Nico Schottelius --- doc/dev/releasechecklist | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/doc/dev/releasechecklist b/doc/dev/releasechecklist index 6bc0a77c..cf7d2df8 100755 --- a/doc/dev/releasechecklist +++ b/doc/dev/releasechecklist @@ -10,33 +10,38 @@ echo "Preparing next release" echo "Testing documentation..." ./build clean && ./build man || exit 1 +# get version +changelog_version=$(head -n1 doc/changelog | sed 's/:.*//') +#git_version=$(git describe) +lib_version=$(grep ^VERSION lib/cdist/__init__.py | sed -e 's/.*= //' -e 's/"//g') + echo "Ensure you fixed/prepared version files: $files" +echo "changelog: $changelog_version" +#echo "git: $git_version" +echo "lib: $lib_version" read wait -# get version -lib_version=$(grep ^VERSION lib/cdist/__init__.py | sed -e 's/.*= //' -e 's/"//g') -changelog_version=$(head -n1 doc/changelog | sed 's/:.*//') -git_version=$(git describe) - -if [ "$lib_version" != "$changelog_version -o "$changelog_version" != "$git_version" ]; then +if [ "$lib_version" != "$changelog_version ]; then echo "Messed up versions, not releasing" exit 1 fi -version=$git_version +version=$lib_version # get target branch branch=${version%.?} # add tag -printf "Enter description for %s>" "$version" +printf "Enter tag description for %s>" "$version" read tagmessage git tag "$version" -m "$tagmessage" # Import into current version branch +echo "git merge into $branch" git checkout $branch git merge master git checkout master # Publish manpages and sourcecode +echo "publising doc/ and code/" ./build web ./build pub From 3605e478e613be1e7e45e619b55a83bdd2ee4234 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 15:59:36 +0100 Subject: [PATCH 32/45] -typo Signed-off-by: Nico Schottelius --- doc/dev/releasechecklist | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/dev/releasechecklist b/doc/dev/releasechecklist index cf7d2df8..188ce474 100755 --- a/doc/dev/releasechecklist +++ b/doc/dev/releasechecklist @@ -19,12 +19,13 @@ echo "Ensure you fixed/prepared version files: $files" echo "changelog: $changelog_version" #echo "git: $git_version" echo "lib: $lib_version" -read wait -if [ "$lib_version" != "$changelog_version ]; then +if [ "$lib_version" != "$changelog_version" ]; then echo "Messed up versions, not releasing" exit 1 fi +echo "Press enter to continue" +read wait version=$lib_version # get target branch From 55ec36b562d40cfbb4163fe1d4cfcad0a0d922d7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 16:04:19 +0100 Subject: [PATCH 33/45] beautify release script Signed-off-by: Nico Schottelius --- doc/dev/releasechecklist | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/dev/releasechecklist b/doc/dev/releasechecklist index 188ce474..1ef36703 100755 --- a/doc/dev/releasechecklist +++ b/doc/dev/releasechecklist @@ -23,6 +23,8 @@ echo "lib: $lib_version" if [ "$lib_version" != "$changelog_version" ]; then echo "Messed up versions, not releasing" exit 1 +else + echo "Version are sane, continuing" fi echo "Press enter to continue" read wait @@ -32,7 +34,7 @@ version=$lib_version branch=${version%.?} # add tag -printf "Enter tag description for %s>" "$version" +printf "Enter tag description for %s> " "$version" read tagmessage git tag "$version" -m "$tagmessage" From dd588016a0ba5805474dd4fc190775605b96d9c9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 16:11:51 +0100 Subject: [PATCH 34/45] plural... Signed-off-by: Nico Schottelius --- doc/dev/releasechecklist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dev/releasechecklist b/doc/dev/releasechecklist index 1ef36703..55d6221b 100755 --- a/doc/dev/releasechecklist +++ b/doc/dev/releasechecklist @@ -24,7 +24,7 @@ if [ "$lib_version" != "$changelog_version" ]; then echo "Messed up versions, not releasing" exit 1 else - echo "Version are sane, continuing" + echo "Versions are sane, continuing" fi echo "Press enter to continue" read wait From b0e25e8784e2cb528140dc4ffe3d5d070d30721c Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Wed, 4 Jan 2012 07:58:51 -0800 Subject: [PATCH 35/45] fix typo --- conf/explorer/os | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/explorer/os b/conf/explorer/os index e59301e7..1aafb468 100755 --- a/conf/explorer/os +++ b/conf/explorer/os @@ -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 From bdafb4ffef39b38721e8c27ff1f1735f6fde396f Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Wed, 4 Jan 2012 10:08:45 -0800 Subject: [PATCH 36/45] A new type for managing luarocks packages The __package_luarocks type manages the installation of Lua modules distribued using LuaRocks. It is based on __package_rubygem. --- .../__package_luarocks/explorer/pkg_status | 31 +++++++++++ conf/type/__package_luarocks/gencode-remote | 52 +++++++++++++++++++ conf/type/__package_luarocks/man.text | 49 +++++++++++++++++ conf/type/__package_luarocks/manifest | 23 ++++++++ .../__package_luarocks/parameter/optional | 1 + .../__package_luarocks/parameter/required | 1 + 6 files changed, 157 insertions(+) create mode 100755 conf/type/__package_luarocks/explorer/pkg_status create mode 100755 conf/type/__package_luarocks/gencode-remote create mode 100644 conf/type/__package_luarocks/man.text create mode 100644 conf/type/__package_luarocks/manifest create mode 100644 conf/type/__package_luarocks/parameter/optional create mode 100644 conf/type/__package_luarocks/parameter/required diff --git a/conf/type/__package_luarocks/explorer/pkg_status b/conf/type/__package_luarocks/explorer/pkg_status new file mode 100755 index 00000000..3eb73298 --- /dev/null +++ b/conf/type/__package_luarocks/explorer/pkg_status @@ -0,0 +1,31 @@ +#!/bin/sh +# +# 2012 SwellPath, Inc. +# Christian G. Warden +# +# 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 . +# +# 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 diff --git a/conf/type/__package_luarocks/gencode-remote b/conf/type/__package_luarocks/gencode-remote new file mode 100755 index 00000000..179022b1 --- /dev/null +++ b/conf/type/__package_luarocks/gencode-remote @@ -0,0 +1,52 @@ +#!/bin/sh +# +# 2012 SwellPath, Inc. +# Christian G. Warden +# +# 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 . +# +# +# 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 diff --git a/conf/type/__package_luarocks/man.text b/conf/type/__package_luarocks/man.text new file mode 100644 index 00000000..6c1e6734 --- /dev/null +++ b/conf/type/__package_luarocks/man.text @@ -0,0 +1,49 @@ +cdist-type__package_luarocks(7) +============================== +Christian G. Warden + + +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). diff --git a/conf/type/__package_luarocks/manifest b/conf/type/__package_luarocks/manifest new file mode 100644 index 00000000..8e626714 --- /dev/null +++ b/conf/type/__package_luarocks/manifest @@ -0,0 +1,23 @@ +#!/bin/sh +# +# 2012 SwellPath, Inc. +# Christian G. Warden +# +# 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 . +# + +__package luarocks --state installed +__package make --state installed diff --git a/conf/type/__package_luarocks/parameter/optional b/conf/type/__package_luarocks/parameter/optional new file mode 100644 index 00000000..f121bdbf --- /dev/null +++ b/conf/type/__package_luarocks/parameter/optional @@ -0,0 +1 @@ +name diff --git a/conf/type/__package_luarocks/parameter/required b/conf/type/__package_luarocks/parameter/required new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/conf/type/__package_luarocks/parameter/required @@ -0,0 +1 @@ +state From 745cf47e43837478026a141a321d4f3307f2c16b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 4 Jan 2012 20:40:53 +0100 Subject: [PATCH 37/45] changes: +type __package_luarocks (thanks Christian) Signed-off-by: Nico Schottelius --- doc/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/changelog b/doc/changelog index 7e17a75c..81d78662 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,3 +1,6 @@ +2.0.5: + * New Type: __package_luarocks (Christian G. Warden) + 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) From 6d55d7ae82fde29c943cde649cc8b9c767ceea14 Mon Sep 17 00:00:00 2001 From: "phrawzty (dan)" Date: Thu, 5 Jan 2012 11:08:16 +0100 Subject: [PATCH 38/45] --regex to make __addifnosuchline more flexible --- conf/type/__addifnosuchline/explorer/findline | 10 ++++++++-- conf/type/__addifnosuchline/parameter/optional | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/conf/type/__addifnosuchline/explorer/findline b/conf/type/__addifnosuchline/explorer/findline index ac69a827..b45bd6ea 100755 --- a/conf/type/__addifnosuchline/explorer/findline +++ b/conf/type/__addifnosuchline/explorer/findline @@ -26,12 +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 # sh -e is our environment, we know what we do, # skip error detection for now set +e - grep -q "^$regex\$" "$file" + grep -q "$regex" "$file" if [ $? -eq 1 ]; then echo "NOTFOUND" else diff --git a/conf/type/__addifnosuchline/parameter/optional b/conf/type/__addifnosuchline/parameter/optional index f73f3093..7ecfcde9 100644 --- a/conf/type/__addifnosuchline/parameter/optional +++ b/conf/type/__addifnosuchline/parameter/optional @@ -1 +1,2 @@ file +regex From 7cbc49430188836c706d0cca2970b67c701d86a1 Mon Sep 17 00:00:00 2001 From: "phrawzty (dan)" Date: Thu, 5 Jan 2012 11:13:30 +0100 Subject: [PATCH 39/45] Add --regex to manual --- conf/type/__addifnosuchline/man.text | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conf/type/__addifnosuchline/man.text b/conf/type/__addifnosuchline/man.text index 722a3080..3051ff36 100644 --- a/conf/type/__addifnosuchline/man.text +++ b/conf/type/__addifnosuchline/man.text @@ -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 -------- From 0f768040c2c19209ef5ce3c9bca5185a34aed5b4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 5 Jan 2012 11:59:15 +0100 Subject: [PATCH 40/45] document --regexp in changes Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index 81d78662..1f192304 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,5 +1,6 @@ 2.0.5: * New Type: __package_luarocks (Christian G. Warden) + * Feature: __addifnosuchline supports matching on regular expressions (dan) 2.0.4: 2011-11-18 * Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C) From 99099162577dce88429d04bbb2829f20403add4d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 5 Jan 2012 13:41:32 +0100 Subject: [PATCH 41/45] add real life template example Signed-off-by: Nico Schottelius --- other/examples/types/__ethz_dinfk_ldap/README | 2 + .../files/nslcd.conf.template | 46 +++++++++++++++++++ .../__ethz_dinfk_ldap/files/nsswitch.conf | 22 +++++++++ .../examples/types/__ethz_dinfk_ldap/manifest | 39 ++++++++++++++++ .../__ethz_dinfk_ldap/parameter/required | 1 + .../types/__ethz_dinfk_ldap/singleton | 0 6 files changed, 110 insertions(+) create mode 100644 other/examples/types/__ethz_dinfk_ldap/README create mode 100755 other/examples/types/__ethz_dinfk_ldap/files/nslcd.conf.template create mode 100644 other/examples/types/__ethz_dinfk_ldap/files/nsswitch.conf create mode 100755 other/examples/types/__ethz_dinfk_ldap/manifest create mode 100644 other/examples/types/__ethz_dinfk_ldap/parameter/required create mode 100644 other/examples/types/__ethz_dinfk_ldap/singleton diff --git a/other/examples/types/__ethz_dinfk_ldap/README b/other/examples/types/__ethz_dinfk_ldap/README new file mode 100644 index 00000000..18c1574b --- /dev/null +++ b/other/examples/types/__ethz_dinfk_ldap/README @@ -0,0 +1,2 @@ +This type is used in production in the ETH and utilises a template to generate +the config file. diff --git a/other/examples/types/__ethz_dinfk_ldap/files/nslcd.conf.template b/other/examples/types/__ethz_dinfk_ldap/files/nslcd.conf.template new file mode 100755 index 00000000..d5b41c24 --- /dev/null +++ b/other/examples/types/__ethz_dinfk_ldap/files/nslcd.conf.template @@ -0,0 +1,46 @@ +#!/bin/sh +cat << DONE +# +# D-INFK SANS MANAGED FILE +# ======================== +# +# Do not change this file. Changes will be overwritten. +# + +# /etc/nslcd.conf +# nslcd configuration file. See nslcd.conf(5) +# for details. + +# The user and group nslcd should run as. +uid nslcd +gid nslcd + +# The location at which the LDAP server(s) should be reachable. +uri ldaps://ldaps01.ethz.ch +uri ldaps://ldaps02.ethz.ch +uri ldaps://ldaps03.ethz.ch + + +# The search base +base ou=${ou},ou=inf,ou=auth,o=ethz,c=ch +base passwd ou=users,ou=${ou},ou=inf,ou=auth,o=ethz,c=ch +base group ou=Group,ou=inf,ou=auth,o=ethz,c=ch +base netgroup ou=netgroup,ou=inf,ou=auth,o=ethz,c=ch + +binddn cn=REPLACE,ou=ME,ou=WITH,ou=YOUR,o=DETAILS,c=ch +bindpw VERYSECRETPASSWORD + +# The LDAP protocol version to use. +#ldap_version 3 + +# The DN to bind with for normal lookups. +#binddn cn=annonymous,dc=example,dc=net +#bindpw secret + +# SSL options +ssl on +tls_reqcert never + +# The search scope. +#scope sub +DONE diff --git a/other/examples/types/__ethz_dinfk_ldap/files/nsswitch.conf b/other/examples/types/__ethz_dinfk_ldap/files/nsswitch.conf new file mode 100644 index 00000000..f4185a86 --- /dev/null +++ b/other/examples/types/__ethz_dinfk_ldap/files/nsswitch.conf @@ -0,0 +1,22 @@ +# +# D-INFK SANS MANAGED FILE +# ======================== +# +# Do not change this file. Changes will be overwritten. +# +# /etc/nsswitch.conf +# + +passwd: files ldap +group: files ldap +shadow: files ldap + +hosts: files dns +networks: files + +services: db files +protocols: db files +rpc: db files +ethers: db files + +netgroup: files ldap diff --git a/other/examples/types/__ethz_dinfk_ldap/manifest b/other/examples/types/__ethz_dinfk_ldap/manifest new file mode 100755 index 00000000..c31d765d --- /dev/null +++ b/other/examples/types/__ethz_dinfk_ldap/manifest @@ -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 . +# +# +# Configure nss_ldap for a machine at DINFK. +# + +ou="$(cat "$__object/parameter/ou")" + +ldap_config="/etc/nslcd.conf" +ldap_package="libnss-ldapd" + +# Install required packages +__package "$ldap_package" --state installed + +# Generate nss-ldap config file from template +mkdir "$__object/files" +. "$__type/files/nslcd.conf.template" > "$__object/files/nslcd.conf" +__file "$ldap_config" --source "$__object/files/nslcd.conf" + +# Configure nsswitch to use ldap +require="__package/$ldap_package __file/$ldap_config" \ + __file /etc/nsswitch.conf --source "$__type/files/nsswitch.conf" diff --git a/other/examples/types/__ethz_dinfk_ldap/parameter/required b/other/examples/types/__ethz_dinfk_ldap/parameter/required new file mode 100644 index 00000000..d96c19d8 --- /dev/null +++ b/other/examples/types/__ethz_dinfk_ldap/parameter/required @@ -0,0 +1 @@ +ou diff --git a/other/examples/types/__ethz_dinfk_ldap/singleton b/other/examples/types/__ethz_dinfk_ldap/singleton new file mode 100644 index 00000000..e69de29b From 2df42ebd910158bc772b18e5c8e8bd453f0156ff Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 5 Jan 2012 14:43:35 +0100 Subject: [PATCH 42/45] rewrite/rephrase/check quick start section in tutorial Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-tutorial.text | 161 +++++++++++++++++-------------- 1 file changed, 91 insertions(+), 70 deletions(-) diff --git a/doc/man/man7/cdist-tutorial.text b/doc/man/man7/cdist-tutorial.text index 65f3811c..24e665b5 100644 --- a/doc/man/man7/cdist-tutorial.text +++ b/doc/man/man7/cdist-tutorial.text @@ -8,9 +8,100 @@ NAME cdist-tutorial - a guided introduction into cdist +INTRODUCTION +------------ +This tutorial is aimed at people learning cdist and shows +typical approaches as well as gives an easy start into +the world of configuration management. + +This tutorial assumes you are configuring **localhost**, because +it is always available. Just replace **localhost** with your target +host for real life usage. + + + +QUICK START - GET YOUR HANDS DIRTY NOW +-------------------------------------- +For those who just want to configure a system with the +cdist configuration management and do not need (or want) +to understand everything. + +Cdist uses **ssh** for communication and transportation +and usually logs into the **target host** as the +**root** user. So you need to configure the **ssh server** +of the target host to allow root logins: Edit +the file **/etc/ssh/sshd_config** and add one of the following +lines: + +-------------------------------------------------------------------------------- +# Allow login only via public key +PermitRootLogin without-password + +# Allow login via password and public key +PermitRootLogin yes +-------------------------------------------------------------------------------- + +As cdist uses ssh intensively, it is recommended to setup authentication +with public keys: + +-------------------------------------------------------------------------------- +# Generate pubkey pair as a normal user +ssh-keygen + +# Copy pubkey over to target host +ssh-copy-id root@localhost +-------------------------------------------------------------------------------- + +Have a look at ssh-agent(1) and ssh-add(1) on how to cache the password for +your public key. Usually it looks like this: + +-------------------------------------------------------------------------------- +# Start agent and export variables +eval `ssh-agent` + +# Add keys (requires password for every identity file) +ssh-add +-------------------------------------------------------------------------------- + +At this point you should be able to ***ssh root@localhost*** without +re-entering the password. If something failed until here, ensure that +all steps went successfully and you have read and understood the +documentation. + +As soon as you are able to login without passwort to the target host, +we can use cdist to configure it. You can copy and paste the following +code into your shell to get started and configure localhost: + +-------------------------------------------------------------------------------- +# Get cdist +git clone git://git.schottelius.org/cdist + +# Create manifest (maps configuration to host(s) +cd cdist +echo '__file /etc/cdist-configured' > conf/manifest/init + +# Configure localhost in verbose mode +./bin/cdist config -v localhost + +# Find out that cdist created /etc/cdist-configured +ls -l /etc/cdist-configured +-------------------------------------------------------------------------------- + +That's it, you've successfully used cdist to configure your first host! +Continue reading the next sections, to understand what you did and how +to create a more sophisticated configuration. + +The file 'conf/manifest/init' is usually the entry point for cdist, +to find out what to configure on which host. All manifests are +essentially shell scripts. Every manifest can use the types known to +cdist, which are usually underline prefixed (__). + + + PREPARING YOUR MACHINE / SETUP ------------------------------ +Before you actually - ensure sshd is running on the target host: @@ -123,76 +214,6 @@ __debug:: - - -INTRODUCTION ------------- -This tutorial is aimed at people learning cdist and shows -typical approaches as well as gives an easy start into -the world of configuration management. - -This tutorial assumes you are configuring **localhost**, because -it is always available. Just repace **localhost** with your target -host for real life usage. - - - -QUICK START ------------ -For those who just want to configure a system with the -cdist configuration management and do not need (or want) -to understand everything. - -Cdist uses **ssh** for communication and transportation -and usually logs into the **target host** as the -**root** user. So you need to configure the **ssh server** -of the target host to allow root logins: Edit -the file **/etc/ssh/sshd_config** and add one of the following -lines: - --------------------------------------------------------------------------------- -# Allow login only via public key -PermitRootLogin without-password - -# Allow login via password and public key -PermitRootLogin yes --------------------------------------------------------------------------------- - -As cdist uses ssh intensively, it is recommended to setup authentication -with public keys: - --------------------------------------------------------------------------------- -# Generate pubkey pair as a normal user -ssh-keygen - -# Copy pubkey over to target host -ssh-copy-id root@localhost --------------------------------------------------------------------------------- - -As soon as you are able to login without passwort to the target host, -we can use cdist, to configure it. You can copy and paste the following -code into your shell to get started and configure localhost: - --------------------------------------------------------------------------------- -# Get cdist -git clone git://git.schottelius.org/cdist - -# Create manifest (maps configuration to host(s) -cd cdist -echo '__file /etc/cdist-configured' > conf/manifest/init -chmod 0700 conf/manifest/init - -# Configure localhost -./bin/cdist config localhost - -# Find out that cdist created /etc/cdist-configured -ls -l /etc/cdist-configured --------------------------------------------------------------------------------- - -The file 'conf/manifest/init' is usually the entry point for cdist, -to find out what to configure on which host. All manifests are -essentially shell scripts. Every manifest can use the types known to -cdist, which are usually underline prefixed (__). SEE ALSO From 46b23c507b22ce33869de36a7ca5b12af2089446 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 5 Jan 2012 14:44:12 +0100 Subject: [PATCH 43/45] tutorial will be included in the next release Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index 1f192304..7164e939 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,6 +1,7 @@ 2.0.5: * New Type: __package_luarocks (Christian G. Warden) * Feature: __addifnosuchline supports matching on regular expressions (dan) + * Documentation: (Re)write of the tutorial 2.0.4: 2011-11-18 * Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C) From f9d6ce349dacd5b2eb54ff038caa620c55a4500b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 5 Jan 2012 17:50:50 +0100 Subject: [PATCH 44/45] begin section about the initial manifest Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-tutorial.text | 94 +++++--------------------------- 1 file changed, 15 insertions(+), 79 deletions(-) diff --git a/doc/man/man7/cdist-tutorial.text b/doc/man/man7/cdist-tutorial.text index 24e665b5..91b5fdee 100644 --- a/doc/man/man7/cdist-tutorial.text +++ b/doc/man/man7/cdist-tutorial.text @@ -98,40 +98,20 @@ cdist, which are usually underline prefixed (__). +DEFINE STATE IN THE INITIAL MANIFEST +------------------------------------ +The **initial manifest** is the entry point for cdist to find out, which +**objects** to configure on the selected host. Objects are instances of +**types**, like in object orientated programming. An object is represented +by the type + slash + object name: ***__file/etc/cdist-configured*** is an +object of the type ***__file*** with the name ***etc/cdist-configured***. -PREPARING YOUR MACHINE / SETUP ------------------------------- -Before you actually - -- ensure sshd is running on the target host: - -ssh target_host - -- ensure you can login as root - -ssh root@target host - -- ensure login as root works without keys -(see ssh... manpage) - -cdist will do a lot of requests to the target -host, thus you'll have to enter your password -many times, if you don't do this :-) - -- speedup processing with ControlMaster option of -ssh +Cdist searches for the initial manifest at **conf/manifest/init** and +executes it as a shell script using **/bin/sh -e**. -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, @@ -162,58 +142,14 @@ __debug:: +BRANCHES IN HERE? +------------ +TUNING CDIST +------------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- speedup processing with ControlMaster option of +ssh SEE ALSO From 33763b72dd76be9c45acc97321f12c604ac77cc4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 5 Jan 2012 18:13:25 +0100 Subject: [PATCH 45/45] more description on the initial manifest Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-tutorial.text | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/man/man7/cdist-tutorial.text b/doc/man/man7/cdist-tutorial.text index 91b5fdee..577d633a 100644 --- a/doc/man/man7/cdist-tutorial.text +++ b/doc/man/man7/cdist-tutorial.text @@ -109,7 +109,35 @@ object of the type ***__file*** with the name ***etc/cdist-configured***. Cdist searches for the initial manifest at **conf/manifest/init** and executes it as a shell script using **/bin/sh -e**. +Within this initial manifest, you define, which objects should be +created on which host. To distinguish between hosts, you can use the +environment variable **__target_host**. Let's have a look at a simple +example: +-------------------------------------------------------------------------------- +__file /etc/cdist-configured + +case "$__target_host" in + localhost) + __directory /home/services/kvm-vm --parents yes + ;; +esac +-------------------------------------------------------------------------------- + +This manifest says: Independent of the host, always create the (empty) file +***/etc/cdist-configured***, but create the directory ***/home/services/kvm-vm***, +including all parent directories, only on the host ***localhost***. + +As you can see, there is no magic involved, the manifest is simple shell code that +utilises cdist types. + + +PARTS BELOW HERE ARE TO-BE-DONE + + +MORE ABOUT TYPES AND OBJECTS +---------------------------- +All available types in cdist can be called like normal executables. USING SOME BASIC TYPES