From 78be159eb789dfef83421cff5703d0b54f25c904 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jan 2014 14:15:41 +0100 Subject: [PATCH 01/28] update reference: we also do not touch 'files' in the object Signed-off-by: Nico Schottelius --- docs/man/cdist-reference.text.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index a72452eb..5c9f603c 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -131,7 +131,8 @@ confdir/type//explorer:: confdir/type//files:: This directory is reserved for user data and will not be used - by cdist at any time + by cdist at any time. It can be used for storing supplementary + files (like scripts to act as a template or configuration files). out/:: This directory contains output of cdist and is usually located @@ -175,9 +176,16 @@ OBJECTS For object to object communication and tests, the following paths are usable within a object directory: +files:: + This directory is reserved for user data and will not be used + by cdist at any time. It can be used freely by the type + (for instance to store template results). changed:: This empty file exists in an object directory, if the object has code to be excuted (either remote or local) +stdin:: + This file exists and contains data, if data was provided on stdin + when the type was called. ENVIRONMENT VARIABLES From 9049a1421cfd5b5e8f4ee72e79178ab90dce681c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jan 2014 14:17:51 +0100 Subject: [PATCH 02/28] support --file - in __debconf_set_selections Signed-off-by: Nico Schottelius --- .../conf/type/__debconf_set_selections/gencode-remote | 10 ++++++++-- cdist/conf/type/__debconf_set_selections/man.text | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__debconf_set_selections/gencode-remote b/cdist/conf/type/__debconf_set_selections/gencode-remote index 62be6a12..4892ec25 100755 --- a/cdist/conf/type/__debconf_set_selections/gencode-remote +++ b/cdist/conf/type/__debconf_set_selections/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2011-2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -21,6 +21,12 @@ # Setup selections # +filename"$(cat "$__object/parameter/file")" + +if [ "$filename" = "-" ]; then + filename="$__object/stdin" +fi + echo "debconf-set-selections << __file-eof" -cat "$(cat "$__object/parameter/file")" +cat "$(cat "$filename")" echo "__file-eof" diff --git a/cdist/conf/type/__debconf_set_selections/man.text b/cdist/conf/type/__debconf_set_selections/man.text index f1e13a8e..e36ebaa3 100644 --- a/cdist/conf/type/__debconf_set_selections/man.text +++ b/cdist/conf/type/__debconf_set_selections/man.text @@ -18,6 +18,7 @@ REQUIRED PARAMETERS ------------------- file:: Use the given filename as input for debconf-set-selections(1) + If filename is "-", read from stdin. EXAMPLES @@ -29,6 +30,10 @@ __debconf_set_selections nslcd --file /path/to/file # Setup configuration for nslcd from another type __debconf_set_selections nslcd --file "$__type/files/preseed/nslcd" + +__debconf_set_selections nslcd --file - << eof +gitolite gitolite/gituser string git +eof -------------------------------------------------------------------------------- @@ -41,5 +46,5 @@ SEE ALSO COPYING ------- -Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is +Copyright \(C) 2011-2014 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3). From 565e11b16dc53c0d887c4060940c7bffb2e581d5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jan 2014 14:18:56 +0100 Subject: [PATCH 03/28] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog b/docs/changelog index d8af2cf3..d9c2c8b5 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,7 +5,10 @@ Changelog * Exception: No braces means author == Nico Schottelius 3.0.4: + * Documentation: Update reference (files path in object space) * Type __apt_ppa: Install required software (Steven Armstrong) + * Type __debconf_set_selections: Support --file - to read from stdin + 3.0.3: 2014-01-22 * Core: Enhance error message when requirement is missing object id @@ -19,6 +22,7 @@ Changelog * Type __zypper_repo: Use default paremeters (Daniel Heule) * Type __zypper_service: Use default paremeters (Daniel Heule) + 3.0.2: 2014-01-19 * Documentation: Document all messages sent by types (Daniel Heule) * New Type: __block (Steven Armstrong) From 4ef55ef13f9172ab6bb045d5a6bfb7acec982758 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Mon, 27 Jan 2014 16:19:01 +0100 Subject: [PATCH 04/28] allow object overrides with CDIST_ALLOW_OVERRIDE=true --- cdist/core/cdist_object.py | 6 ++++-- cdist/emulator.py | 5 ++++- docs/man/man7/cdist-manifest.text | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 45b5e3ff..9ead71c7 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -2,6 +2,7 @@ # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -215,9 +216,10 @@ class CdistObject(object): """Create this cdist object on the filesystem. """ try: - os.makedirs(self.absolute_path, exist_ok=False) + cdexist_ok = True if os.environ.get('CDIST_ALLOW_OVERRIDE',"false") == 'true' else False + os.makedirs(self.absolute_path, exist_ok=cdexist_ok) absolute_parameter_path = os.path.join(self.base_path, self.parameter_path) - os.makedirs(absolute_parameter_path, exist_ok=False) + os.makedirs(absolute_parameter_path, exist_ok=cdexist_ok) except EnvironmentError as error: raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error)) diff --git a/cdist/emulator.py b/cdist/emulator.py index 63d3bbbc..0693eb35 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -2,6 +2,7 @@ # # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -144,12 +145,14 @@ class Emulator(object): if value is not None: self.parameters[key] = value - if self.cdist_object.exists: + if self.cdist_object.exists and os.environ.get('CDIST_ALLOW_OVERRIDE',"false") != 'true': if self.cdist_object.parameters != self.parameters: raise cdist.Error("Object %s already exists with conflicting parameters:\n%s: %s\n%s: %s" % (self.cdist_object.name, " ".join(self.cdist_object.source), self.cdist_object.parameters, self.object_source, self.parameters) ) else: + if self.cdist_object.exists: + self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE=true',self.cdist_object.name) self.cdist_object.create() self.cdist_object.parameters = self.parameters diff --git a/docs/man/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text index 92d0b897..84dc36ae 100644 --- a/docs/man/man7/cdist-manifest.text +++ b/docs/man/man7/cdist-manifest.text @@ -161,6 +161,30 @@ __package lighttpd --state present require="__package/lighttpd" __package munin --state present -------------------------------------------------------------------------------- +OVERRIDES +--------- +In some special cases, you would like to create an allready defined object +with different parameters. In normal situations this leads to an error in cdist. +If you whish, you can mark this second definition of an object with +CDIST_ALLOW_OVERRIDE=true to tell cdist, that this object override is +wanted and should be accepted. + +-------------------------------------------------------------------------------- +# for example in the inial manifest + +# reate user account foobar with some hash for password +__user foobar --password 'some_fancy_hash' + +# ... many statements and includes in the manifest later ... +# somewhere in a conditionaly sourced manifest +# (e.g. for example only sourced if a special application is on the target host) + +# this leads to an error ... +__user foobar --password 'some_other_hash' + +# this tells cdist, that you know that this is an override and should be accepted +CDIST_ALLOW_OVERRIDE=true __user foobar --password 'some_other_hash' +-------------------------------------------------------------------------------- SEE ALSO From 723be34bca37e97cb7cf3d94367d5e224ec7b325 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Mon, 27 Jan 2014 13:22:03 -0500 Subject: [PATCH 05/28] Fixed typo Was assigning jaildir=$object/parameter/name, fixed to $object/parameter/jaildir --- cdist/conf/type/__jail/gencode-local | 2 +- cdist/conf/type/__jail/gencode-remote | 2 +- cdist/conf/type/__jail/manifest | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__jail/gencode-local b/cdist/conf/type/__jail/gencode-local index 075a6ef1..d6384156 100755 --- a/cdist/conf/type/__jail/gencode-local +++ b/cdist/conf/type/__jail/gencode-local @@ -23,7 +23,7 @@ # if [ -f "$__object/parameter/jaildir" ]; then - jaildir="$(cat "$__object/parameter/name")" + jaildir="$(cat "$__object/parameter/jaildir")" else jaildir="/usr/jail" fi diff --git a/cdist/conf/type/__jail/gencode-remote b/cdist/conf/type/__jail/gencode-remote index b044e4b0..afbb81a5 100755 --- a/cdist/conf/type/__jail/gencode-remote +++ b/cdist/conf/type/__jail/gencode-remote @@ -85,7 +85,7 @@ if [ -f "$__object/parameter/onboot" ]; then fi if [ -f "$__object/parameter/jaildir" ]; then - jaildir="$(cat "$__object/parameter/name")" + jaildir="$(cat "$__object/parameter/jaildir")" else jaildir="/usr/jail" fi diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest index 0570d62d..cf5b7938 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -34,7 +34,7 @@ if [ ! "$os" = "freebsd" ]; then fi if [ -f "$__object/parameter/jaildir" ]; then - jaildir="$(cat "$__object/parameter/name")" + jaildir="$(cat "$__object/parameter/jaildir")" else jaildir="/usr/jail" fi From e52a059adfbb2152d33f0cb9e7c1516db9e00188 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jan 2014 19:38:26 +0100 Subject: [PATCH 06/28] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index d9c2c8b5..34e44913 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ Changelog * Documentation: Update reference (files path in object space) * Type __apt_ppa: Install required software (Steven Armstrong) * Type __debconf_set_selections: Support --file - to read from stdin + * Type __jail: Fix jaildir parameter handling (Jake Guffey) 3.0.3: 2014-01-22 From aa3e92f07b9ff91b298064ba8b6173ad0a1dcea6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jan 2014 21:08:22 +0100 Subject: [PATCH 07/28] use directory files/, not templates Signed-off-by: Nico Schottelius --- docs/man/man7/cdist-best-practice.text | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/man/man7/cdist-best-practice.text b/docs/man/man7/cdist-best-practice.text index e6685cad..a818be60 100644 --- a/docs/man/man7/cdist-best-practice.text +++ b/docs/man/man7/cdist-best-practice.text @@ -164,8 +164,8 @@ For more details consult sudoers(5) TEMPLATING ---------- -* create directory templates/ in your type (convention) -* create the template as an executable file like templates/basic.conf.sh, it will output text using shell variables for the values +* create directory files/ in your type (convention) +* create the template as an executable file like files/basic.conf.sh, it will output text using shell variables for the values -------------------------------------------------------------------------------- #!/bin/sh @@ -191,7 +191,7 @@ EOF export ROOT='/var/www/test' # render the template mkdir -p "$__object/files" - "$__type/templates/basic.conf.sh" > "$__object/files/basic.conf" + "$__type/files/basic.conf.sh" > "$__object/files/basic.conf" # send the rendered template __file /etc/nginx/sites-available/test.conf \ --state present From 16d51b3cf11b445b24189bf225d2c9b37013a4a5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jan 2014 22:40:59 +0100 Subject: [PATCH 08/28] backport ignoring install types in config mode from install_integration branch Signed-off-by: Nico Schottelius --- cdist/config.py | 6 +++++- cdist/core/cdist_type.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cdist/config.py b/cdist/config.py index 3f8a7fc6..73ba4710 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -163,7 +163,11 @@ class Config(object): """Short name for object list retrieval""" for cdist_object in core.CdistObject.list_objects(self.local.object_path, self.local.type_path): - yield cdist_object + if cdist_object.cdist_type.is_install: + self.log.debug("Running in config mode, ignoring install object: {0}".format(cdist_object)) + else: + yield cdist_object + def iterate_once(self): """ diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index 46e126f9..ff1ebaec 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -101,6 +101,11 @@ class CdistType(object): """Check whether a type is a singleton.""" return os.path.isfile(os.path.join(self.absolute_path, "singleton")) + @property + def is_install(self): + """Check whether a type is used for installation (if not: for configuration)""" + return os.path.isfile(os.path.join(self.absolute_path, "install")) + @property def explorers(self): """Return a list of available explorers""" From 228ed4dbd2608fc39a9dd878b44faed3b8cb5b58 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jan 2014 23:19:07 +0100 Subject: [PATCH 09/28] fix typos in __debconf_set_selections Signed-off-by: Nico Schottelius --- cdist/conf/type/__debconf_set_selections/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__debconf_set_selections/gencode-remote b/cdist/conf/type/__debconf_set_selections/gencode-remote index 4892ec25..bb719c46 100755 --- a/cdist/conf/type/__debconf_set_selections/gencode-remote +++ b/cdist/conf/type/__debconf_set_selections/gencode-remote @@ -21,12 +21,12 @@ # Setup selections # -filename"$(cat "$__object/parameter/file")" +filename="$(cat "$__object/parameter/file")" if [ "$filename" = "-" ]; then filename="$__object/stdin" fi echo "debconf-set-selections << __file-eof" -cat "$(cat "$filename")" +cat "$filename" echo "__file-eof" From d5f04b26c8e2f8f9a64a0a362695f3685a4c9b4d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jan 2014 23:19:18 +0100 Subject: [PATCH 10/28] ++changes(3.0.4) Signed-off-by: Nico Schottelius --- docs/changelog | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 34e44913..32b4e42e 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,8 +4,10 @@ Changelog * Changes are always commented with their author in (braces) * Exception: No braces means author == Nico Schottelius -3.0.4: +3.0.4: 2014-01-29 + * Core: Ignore install types in config mode * Documentation: Update reference (files path in object space) + * Documentation: Update best practise: Replaces templates/ with files/ * Type __apt_ppa: Install required software (Steven Armstrong) * Type __debconf_set_selections: Support --file - to read from stdin * Type __jail: Fix jaildir parameter handling (Jake Guffey) From 197fabf40ac3c84f8bed89e3576b82672496bb61 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Fri, 31 Jan 2014 17:56:55 +0100 Subject: [PATCH 11/28] added some ideas from asteven and a bit more description about the order in the manpage --- cdist/core/cdist_object.py | 7 +++---- cdist/emulator.py | 4 +++- docs/man/man7/cdist-manifest.text | 5 ++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 9ead71c7..b17bd339 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -212,14 +212,13 @@ class CdistObject(object): """Checks wether this cdist object exists on the file systems.""" return os.path.exists(self.absolute_path) - def create(self): + def create(self, allow_overwrite=False): """Create this cdist object on the filesystem. """ try: - cdexist_ok = True if os.environ.get('CDIST_ALLOW_OVERRIDE',"false") == 'true' else False - os.makedirs(self.absolute_path, exist_ok=cdexist_ok) + os.makedirs(self.absolute_path, exist_ok=allow_overwrite) absolute_parameter_path = os.path.join(self.base_path, self.parameter_path) - os.makedirs(absolute_parameter_path, exist_ok=cdexist_ok) + os.makedirs(absolute_parameter_path, exist_ok=allow_overwrite) except EnvironmentError as error: raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error)) diff --git a/cdist/emulator.py b/cdist/emulator.py index 0693eb35..e32f12e0 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -153,7 +153,9 @@ class Emulator(object): else: if self.cdist_object.exists: self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE=true',self.cdist_object.name) - self.cdist_object.create() + self.cdist_object.create(True) + else + self.cdist_object.create() self.cdist_object.parameters = self.parameters # Record / Append source diff --git a/docs/man/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text index 84dc36ae..d9bcb893 100644 --- a/docs/man/man7/cdist-manifest.text +++ b/docs/man/man7/cdist-manifest.text @@ -163,11 +163,14 @@ require="__package/lighttpd" __package munin --state present OVERRIDES --------- -In some special cases, you would like to create an allready defined object +In some special cases, you would like to create an already defined object with different parameters. In normal situations this leads to an error in cdist. If you whish, you can mark this second definition of an object with CDIST_ALLOW_OVERRIDE=true to tell cdist, that this object override is wanted and should be accepted. +ATTENTION: Only use this feature if you are 100% sure in which order +cdist encounter the affected objects, otherwhise this results +into an undefined situation. -------------------------------------------------------------------------------- # for example in the inial manifest From 5fbac8d0baa85197216ed1e3cb3fa7262415fb40 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Fri, 31 Jan 2014 17:59:56 +0100 Subject: [PATCH 12/28] forgot the : after the else ... --- cdist/emulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index e32f12e0..ed846e6d 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -154,7 +154,7 @@ class Emulator(object): if self.cdist_object.exists: self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE=true',self.cdist_object.name) self.cdist_object.create(True) - else + else: self.cdist_object.create() self.cdist_object.parameters = self.parameters From 99dedc493349f25dbc6ca191c78d395472a779c8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 31 Jan 2014 21:48:09 +0100 Subject: [PATCH 13/28] examples are always the last section Signed-off-by: Nico Schottelius --- docs/man/man7/cdist-manifest.text | 58 +++++++++++++++---------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/man/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text index d9bcb893..af86b7ee 100644 --- a/docs/man/man7/cdist-manifest.text +++ b/docs/man/man7/cdist-manifest.text @@ -129,6 +129,35 @@ from the type that is calling them. This is called "autorequirement" in cdist jargon. +OVERRIDES +--------- +In some special cases, you would like to create an already defined object +with different parameters. In normal situations this leads to an error in cdist. +If you whish, you can mark this second definition of an object with +CDIST_ALLOW_OVERRIDE=true to tell cdist, that this object override is +wanted and should be accepted. +ATTENTION: Only use this feature if you are 100% sure in which order +cdist encounter the affected objects, otherwhise this results +into an undefined situation. + +-------------------------------------------------------------------------------- +# for example in the inial manifest + +# reate user account foobar with some hash for password +__user foobar --password 'some_fancy_hash' + +# ... many statements and includes in the manifest later ... +# somewhere in a conditionaly sourced manifest +# (e.g. for example only sourced if a special application is on the target host) + +# this leads to an error ... +__user foobar --password 'some_other_hash' + +# this tells cdist, that you know that this is an override and should be accepted +CDIST_ALLOW_OVERRIDE=true __user foobar --password 'some_other_hash' +-------------------------------------------------------------------------------- + + EXAMPLES -------- The initial manifest may for instance contain the following code: @@ -161,35 +190,6 @@ __package lighttpd --state present require="__package/lighttpd" __package munin --state present -------------------------------------------------------------------------------- -OVERRIDES ---------- -In some special cases, you would like to create an already defined object -with different parameters. In normal situations this leads to an error in cdist. -If you whish, you can mark this second definition of an object with -CDIST_ALLOW_OVERRIDE=true to tell cdist, that this object override is -wanted and should be accepted. -ATTENTION: Only use this feature if you are 100% sure in which order -cdist encounter the affected objects, otherwhise this results -into an undefined situation. - --------------------------------------------------------------------------------- -# for example in the inial manifest - -# reate user account foobar with some hash for password -__user foobar --password 'some_fancy_hash' - -# ... many statements and includes in the manifest later ... -# somewhere in a conditionaly sourced manifest -# (e.g. for example only sourced if a special application is on the target host) - -# this leads to an error ... -__user foobar --password 'some_other_hash' - -# this tells cdist, that you know that this is an override and should be accepted -CDIST_ALLOW_OVERRIDE=true __user foobar --password 'some_other_hash' --------------------------------------------------------------------------------- - - SEE ALSO -------- - cdist-tutorial(7) From dc1a5dfd6dff5fbaeb544680e511246d653a792d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 31 Jan 2014 21:50:32 +0100 Subject: [PATCH 14/28] update override documentation Signed-off-by: Nico Schottelius --- docs/man/man7/cdist-manifest.text | 38 +++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/docs/man/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text index af86b7ee..7292a64f 100644 --- a/docs/man/man7/cdist-manifest.text +++ b/docs/man/man7/cdist-manifest.text @@ -140,23 +140,7 @@ ATTENTION: Only use this feature if you are 100% sure in which order cdist encounter the affected objects, otherwhise this results into an undefined situation. --------------------------------------------------------------------------------- -# for example in the inial manifest - -# reate user account foobar with some hash for password -__user foobar --password 'some_fancy_hash' - -# ... many statements and includes in the manifest later ... -# somewhere in a conditionaly sourced manifest -# (e.g. for example only sourced if a special application is on the target host) - -# this leads to an error ... -__user foobar --password 'some_other_hash' - -# this tells cdist, that you know that this is an override and should be accepted -CDIST_ALLOW_OVERRIDE=true __user foobar --password 'some_other_hash' --------------------------------------------------------------------------------- - +THIS IS A BETA FEATURE AND MAY BE REMOVED AT ANY TIME. EXAMPLES -------- @@ -190,6 +174,26 @@ __package lighttpd --state present require="__package/lighttpd" __package munin --state present -------------------------------------------------------------------------------- +How to override objects: + +-------------------------------------------------------------------------------- +# for example in the inital manifest + +# reate user account foobar with some hash for password +__user foobar --password 'some_fancy_hash' + +# ... many statements and includes in the manifest later ... +# somewhere in a conditionaly sourced manifest +# (e.g. for example only sourced if a special application is on the target host) + +# this leads to an error ... +__user foobar --password 'some_other_hash' + +# this tells cdist, that you know that this is an override and should be accepted +CDIST_ALLOW_OVERRIDE=true __user foobar --password 'some_other_hash' +-------------------------------------------------------------------------------- + + SEE ALSO -------- - cdist-tutorial(7) From ab3b15191884428689b6dd7379bea4278dd13ccd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 31 Jan 2014 21:52:43 +0100 Subject: [PATCH 15/28] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog b/docs/changelog index 32b4e42e..bd52bd78 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,10 @@ Changelog * Changes are always commented with their author in (braces) * Exception: No braces means author == Nico Schottelius +3.0.5: + * Core: Introduce override concept (Daniel Heule) + + 3.0.4: 2014-01-29 * Core: Ignore install types in config mode * Documentation: Update reference (files path in object space) From 3a57367e7e895d3d4fe9fd761f0264df80aed0e3 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 1 Feb 2014 22:46:36 +0100 Subject: [PATCH 16/28] bugfix: make type actually work with --state absent Signed-off-by: Steven Armstrong --- cdist/conf/type/__process/gencode-remote | 17 +++++++---------- .../conf/type/__process/parameter/default/state | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 cdist/conf/type/__process/parameter/default/state diff --git a/cdist/conf/type/__process/gencode-remote b/cdist/conf/type/__process/gencode-remote index 41bc5381..639940d9 100755 --- a/cdist/conf/type/__process/gencode-remote +++ b/cdist/conf/type/__process/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh # # 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -17,7 +18,6 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # -# if [ -f "$__object/parameter/name" ]; then name="$(cat "$__object/parameter/name")" @@ -25,21 +25,18 @@ else name="$__object_id" fi -parameter_state="$__object/parameter/state" -if [ -f "$_parameter_state" ]; then - state_should=$(cat "$__object/parameter/state") -else - state_should="present" -fi +state_should="$(cat "$__object/parameter/state")" -runs="$(cat "$__object/explorer/runs")" -if [ "$runs" ]; then +if [ -s "$__object/explorer/runs" ]; then state_is="present" else state_is="absent" fi -[ "$state_is" = "$state_should" ] && exit 0 +if [ "$state_is" = "$state_should" ]; then + # nothing to do + exit 0 +fi case "$state_should" in present) diff --git a/cdist/conf/type/__process/parameter/default/state b/cdist/conf/type/__process/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__process/parameter/default/state @@ -0,0 +1 @@ +present From 1b455e810b449aa2dc3771595f90cfcd298ac501 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Sun, 2 Feb 2014 20:29:41 +0100 Subject: [PATCH 17/28] clarify in the example that override don't touch parameter witch are not present in the 2nd call --- docs/man/man7/cdist-manifest.text | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/man/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text index 7292a64f..aa146267 100644 --- a/docs/man/man7/cdist-manifest.text +++ b/docs/man/man7/cdist-manifest.text @@ -180,7 +180,7 @@ How to override objects: # for example in the inital manifest # reate user account foobar with some hash for password -__user foobar --password 'some_fancy_hash' +__user foobar --password 'some_fancy_hash' --home /home/foobarexample # ... many statements and includes in the manifest later ... # somewhere in a conditionaly sourced manifest @@ -191,6 +191,8 @@ __user foobar --password 'some_other_hash' # this tells cdist, that you know that this is an override and should be accepted CDIST_ALLOW_OVERRIDE=true __user foobar --password 'some_other_hash' +# its only an override, means the parameter --home is not touched +# and stay at the original value of /home/foobarexample -------------------------------------------------------------------------------- From 03ce5a28286eaf1c7bb876b0a11b51280ad6357c Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 4 Feb 2014 12:24:10 +0100 Subject: [PATCH 18/28] import __apt_* types from private repo Signed-off-by: Steven Armstrong --- cdist/conf/type/__apt_key/explorer/state | 32 +++++++++ cdist/conf/type/__apt_key/gencode-remote | 42 +++++++++++ cdist/conf/type/__apt_key/man.text | 60 ++++++++++++++++ .../__apt_key/parameter/default/keyserver | 1 + .../type/__apt_key/parameter/default/state | 1 + cdist/conf/type/__apt_key/parameter/optional | 3 + cdist/conf/type/__apt_key_uri/explorer/state | 32 +++++++++ cdist/conf/type/__apt_key_uri/gencode-remote | 45 ++++++++++++ cdist/conf/type/__apt_key_uri/man.text | 51 ++++++++++++++ cdist/conf/type/__apt_key_uri/manifest | 21 ++++++ .../__apt_key_uri/parameter/default/state | 1 + .../type/__apt_key_uri/parameter/optional | 2 + .../type/__apt_key_uri/parameter/required | 1 + cdist/conf/type/__apt_norecommends/man.text | 42 +++++++++++ cdist/conf/type/__apt_norecommends/manifest | 40 +++++++++++ cdist/conf/type/__apt_norecommends/singleton | 0 .../__apt_source/files/source.list.template | 15 ++++ cdist/conf/type/__apt_source/man.text | 69 +++++++++++++++++++ cdist/conf/type/__apt_source/manifest | 58 ++++++++++++++++ .../conf/type/__apt_source/parameter/boolean | 1 + .../type/__apt_source/parameter/default/state | 1 + .../conf/type/__apt_source/parameter/optional | 4 ++ .../conf/type/__apt_source/parameter/required | 1 + 23 files changed, 523 insertions(+) create mode 100755 cdist/conf/type/__apt_key/explorer/state create mode 100755 cdist/conf/type/__apt_key/gencode-remote create mode 100644 cdist/conf/type/__apt_key/man.text create mode 100644 cdist/conf/type/__apt_key/parameter/default/keyserver create mode 100644 cdist/conf/type/__apt_key/parameter/default/state create mode 100644 cdist/conf/type/__apt_key/parameter/optional create mode 100755 cdist/conf/type/__apt_key_uri/explorer/state create mode 100755 cdist/conf/type/__apt_key_uri/gencode-remote create mode 100644 cdist/conf/type/__apt_key_uri/man.text create mode 100755 cdist/conf/type/__apt_key_uri/manifest create mode 100644 cdist/conf/type/__apt_key_uri/parameter/default/state create mode 100644 cdist/conf/type/__apt_key_uri/parameter/optional create mode 100644 cdist/conf/type/__apt_key_uri/parameter/required create mode 100644 cdist/conf/type/__apt_norecommends/man.text create mode 100755 cdist/conf/type/__apt_norecommends/manifest create mode 100644 cdist/conf/type/__apt_norecommends/singleton create mode 100755 cdist/conf/type/__apt_source/files/source.list.template create mode 100644 cdist/conf/type/__apt_source/man.text create mode 100755 cdist/conf/type/__apt_source/manifest create mode 100644 cdist/conf/type/__apt_source/parameter/boolean create mode 100644 cdist/conf/type/__apt_source/parameter/default/state create mode 100644 cdist/conf/type/__apt_source/parameter/optional create mode 100644 cdist/conf/type/__apt_source/parameter/required diff --git a/cdist/conf/type/__apt_key/explorer/state b/cdist/conf/type/__apt_key/explorer/state new file mode 100755 index 00000000..f7940741 --- /dev/null +++ b/cdist/conf/type/__apt_key/explorer/state @@ -0,0 +1,32 @@ +#!/bin/sh +# +# 2011-2014 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 . +# +# +# Get the current state of the apt key. +# + +if [ -f "$__object/parameter/keyid" ]; then + keyid="$(cat "$__object/parameter/keyid")" +else + keyid="$__object_id" +fi + +apt-key export "$keyid" | head -n 1 | grep -Fqe "BEGIN PGP PUBLIC KEY BLOCK" \ + && echo present \ + || echo absent diff --git a/cdist/conf/type/__apt_key/gencode-remote b/cdist/conf/type/__apt_key/gencode-remote new file mode 100755 index 00000000..c6ead91c --- /dev/null +++ b/cdist/conf/type/__apt_key/gencode-remote @@ -0,0 +1,42 @@ +#!/bin/sh +# +# 2011-2014 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 . +# + +if [ -f "$__object/parameter/keyid" ]; then + keyid="$(cat "$__object/parameter/keyid")" +else + keyid="$__object_id" +fi +state_should="$(cat "$__object/parameter/state")" +state_is="$(cat "$__object/explorer/state")" + +if [ "$state_should" = "$state_is" ]; then + # nothing to do + exit 0 +fi + +case "$state_should" in + present) + keyserver="$(cat "$__object/parameter/keyserver")" + echo "apt-key adv --keyserver \"$keyserver\" --recv-keys \"$keyid\"" + ;; + absent) + echo "apt-key del \"$keyid\"" + ;; +esac diff --git a/cdist/conf/type/__apt_key/man.text b/cdist/conf/type/__apt_key/man.text new file mode 100644 index 00000000..d571a633 --- /dev/null +++ b/cdist/conf/type/__apt_key/man.text @@ -0,0 +1,60 @@ +cdist-type__apt_key(7) +====================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_key - manage the list of keys used by apt + + +DESCRIPTION +----------- +Manages the list of keys used by apt to authenticate packages. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent'. Defaults to 'present' + +keyid:: + the id of the key to add. Defaults to __object_id + +keyserver:: + the keyserver from which to fetch the key. If omitted a sane default is used. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Add Ubuntu Archive Automatic Signing Key +__apt_key 437D05B5 +# Same thing +__apt_key 437D05B5 --state present +# Get rid of it +__apt_key 437D05B5 --state absent + +# same thing with human readable name and explicit keyid +__apt_key UbuntuArchiveKey --keyid 437D05B5 + +# same thing with other keyserver +__apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_key/parameter/default/keyserver b/cdist/conf/type/__apt_key/parameter/default/keyserver new file mode 100644 index 00000000..f851282c --- /dev/null +++ b/cdist/conf/type/__apt_key/parameter/default/keyserver @@ -0,0 +1 @@ +subkeys.pgp.net diff --git a/cdist/conf/type/__apt_key/parameter/default/state b/cdist/conf/type/__apt_key/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__apt_key/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__apt_key/parameter/optional b/cdist/conf/type/__apt_key/parameter/optional new file mode 100644 index 00000000..18cf2586 --- /dev/null +++ b/cdist/conf/type/__apt_key/parameter/optional @@ -0,0 +1,3 @@ +state +keyid +keyserver diff --git a/cdist/conf/type/__apt_key_uri/explorer/state b/cdist/conf/type/__apt_key_uri/explorer/state new file mode 100755 index 00000000..15d6e653 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/explorer/state @@ -0,0 +1,32 @@ +#!/bin/sh +# +# 2011-2014 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 . +# +# +# Get the current state of the apt key. +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +apt-key list | grep -Fqe "$name" \ + && echo present \ + || echo absent diff --git a/cdist/conf/type/__apt_key_uri/gencode-remote b/cdist/conf/type/__apt_key_uri/gencode-remote new file mode 100755 index 00000000..07af92ac --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/gencode-remote @@ -0,0 +1,45 @@ +#!/bin/sh +# +# 2011-2014 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 . +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi +state_should="$(cat "$__object/parameter/state")" +state_is="$(cat "$__object/explorer/state")" + +if [ "$state_should" = "$state_is" ]; then + # nothing to do + exit 0 +fi + +case "$state_should" in + present) + uri="$(cat "$__object/parameter/uri")" + echo "wget -q \"$uri\" -O - | apt-key add -" + ;; + absent) + cat << DONE +keyid=\$(apt-key list | grep -B1 "$name" | awk '/pub/ { print \$2 }' | cut -d'/' -f 2) +apt-key del \$keyid +DONE + ;; +esac diff --git a/cdist/conf/type/__apt_key_uri/man.text b/cdist/conf/type/__apt_key_uri/man.text new file mode 100644 index 00000000..fe9c3a25 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/man.text @@ -0,0 +1,51 @@ +cdist-type__apt_key_uri(7) +========================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_key_uri - add apt key from uri + + +DESCRIPTION +----------- +Download a key from an uri and add it to the apt keyring. + + +REQUIRED PARAMETERS +------------------- +uri:: + the uri from which to download the key + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + +name:: + a name for this key, used when testing if it is already installed. + Defaults to __object_id + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_key_uri rabbitmq \ + --name 'RabbitMQ Release Signing Key ' \ + --uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc \ + --state present +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_key_uri/manifest b/cdist/conf/type/__apt_key_uri/manifest new file mode 100755 index 00000000..5dae37a7 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/manifest @@ -0,0 +1,21 @@ +#!/bin/sh +# +# 2013-2014 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 . +# + +__package wget diff --git a/cdist/conf/type/__apt_key_uri/parameter/default/state b/cdist/conf/type/__apt_key_uri/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__apt_key_uri/parameter/optional b/cdist/conf/type/__apt_key_uri/parameter/optional new file mode 100644 index 00000000..72c84b88 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/parameter/optional @@ -0,0 +1,2 @@ +state +name diff --git a/cdist/conf/type/__apt_key_uri/parameter/required b/cdist/conf/type/__apt_key_uri/parameter/required new file mode 100644 index 00000000..c7954952 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/parameter/required @@ -0,0 +1 @@ +uri diff --git a/cdist/conf/type/__apt_norecommends/man.text b/cdist/conf/type/__apt_norecommends/man.text new file mode 100644 index 00000000..3b65e72f --- /dev/null +++ b/cdist/conf/type/__apt_norecommends/man.text @@ -0,0 +1,42 @@ +cdist-type__apt_norecommends(7) +=============================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_norecommends - configure apt to not install recommended packages + + +DESCRIPTION +----------- +Configure apt to not install any recommended or suggested packages. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_norecommends +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_norecommends/manifest b/cdist/conf/type/__apt_norecommends/manifest new file mode 100755 index 00000000..8058d52e --- /dev/null +++ b/cdist/conf/type/__apt_norecommends/manifest @@ -0,0 +1,40 @@ +#!/bin/sh +# +# 2014 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 . +# + + +os=$(cat "$__global/explorer/os") + +case "$os" in + ubuntu|debian) + # No stinking recommends thank you very much. + # If I want something installed I will do so myself. + __file /etc/apt/apt.conf.d/99-no-recommends \ + --owner root --group root --mode 644 \ + --source - << DONE +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; +DONE + ;; + *) + echo "This type (${__type##*/}) makes no sense on your operating system ($os)." >&2 + echo "If you think otherwise please submit a patch." >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__apt_norecommends/singleton b/cdist/conf/type/__apt_norecommends/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__apt_source/files/source.list.template b/cdist/conf/type/__apt_source/files/source.list.template new file mode 100755 index 00000000..d4420e96 --- /dev/null +++ b/cdist/conf/type/__apt_source/files/source.list.template @@ -0,0 +1,15 @@ +#!/bin/sh +set -u + +entry="$uri $distribution $component" +cat << DONE +# Created by cdist ${__type##*/} +# Do not change. Changes will be overwritten. +# + +# $name +deb ${forcedarch} $entry +DONE +if [ -f "$__object/parameter/include-src" ]; then + echo "deb-src $entry" +fi diff --git a/cdist/conf/type/__apt_source/man.text b/cdist/conf/type/__apt_source/man.text new file mode 100644 index 00000000..fe40a91e --- /dev/null +++ b/cdist/conf/type/__apt_source/man.text @@ -0,0 +1,69 @@ +cdist-type__apt_source(7) +========================= +Steven Armstrong + + +NAME +---- +cdist-type__apt_source - manage apt sources + + +DESCRIPTION +----------- +This cdist type allows you to manage apt sources. + + +REQUIRED PARAMETERS +------------------- +uri:: + the uri to the apt repository + + +OPTIONAL PARAMETERS +------------------- +arch:: + set this if you need to force and specific arch (ubuntu specific) + +state:: + 'present' or 'absent', defaults to 'present' + +distribution:: + the distribution codename to use. Defaults to DISTRIB_CODENAME from + the targets /etc/lsb-release + +component:: + space delimited list of components to enable. Defaults to 'main'. + + +BOOLEAN PARAMETERS +------------------ +include-src:: + include deb-src entries + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_source rabbitmq \ + --uri http://www.rabbitmq.com/debian/ \ + --distribution testing \ + --component main \ + --include-src \ + --state present + +__apt_source canonical_partner \ + --uri http://archive.canonical.com/ \ + --component partner --state present +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_source/manifest b/cdist/conf/type/__apt_source/manifest new file mode 100755 index 00000000..b4d72a71 --- /dev/null +++ b/cdist/conf/type/__apt_source/manifest @@ -0,0 +1,58 @@ +#!/bin/sh +# +# 2011-2013 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 . +# + +name="$__object_id" +state="$(cat "$__object/parameter/state")" +uri="$(cat "$__object/parameter/uri")" + +if [ -f "$__object/parameter/distribution" ]; then + distribution="$(cat "$__object/parameter/distribution")" +else + distribution="$(cat "$__global/explorer/lsb_codename")" +fi +if [ -f "$__object/parameter/component" ]; then + component="$(cat "$__object/parameter/component")" +else + # FIXME: nead to omit this for http://stat.ethz.ch/CRAN//bin/linux/ubuntu, investigate side-effects + #component="main" + component="" +fi +if [ -f "$__object/parameter/arch" ]; then + forcedarch="[arch=$(cat "$__object/parameter/arch")]" +else + forcedarch="" +fi + +# export variables for use in template +export name +export uri +export distribution +export component +export forcedarch + +# generate file from template +mkdir "$__object/files" +"$__type/files/source.list.template" > "$__object/files/source.list" +__file "/etc/apt/sources.list.d/${name}.list" \ + --source "$__object/files/source.list" \ + --owner root --group root --mode 0644 \ + --state "$state" + +require="$__object_name" __apt_update_index diff --git a/cdist/conf/type/__apt_source/parameter/boolean b/cdist/conf/type/__apt_source/parameter/boolean new file mode 100644 index 00000000..8fa49177 --- /dev/null +++ b/cdist/conf/type/__apt_source/parameter/boolean @@ -0,0 +1 @@ +include-src diff --git a/cdist/conf/type/__apt_source/parameter/default/state b/cdist/conf/type/__apt_source/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__apt_source/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__apt_source/parameter/optional b/cdist/conf/type/__apt_source/parameter/optional new file mode 100644 index 00000000..87537335 --- /dev/null +++ b/cdist/conf/type/__apt_source/parameter/optional @@ -0,0 +1,4 @@ +state +distribution +component +arch \ No newline at end of file diff --git a/cdist/conf/type/__apt_source/parameter/required b/cdist/conf/type/__apt_source/parameter/required new file mode 100644 index 00000000..c7954952 --- /dev/null +++ b/cdist/conf/type/__apt_source/parameter/required @@ -0,0 +1 @@ +uri From 2363cdda47289fbefbcb9647af549829ddbc28d0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Feb 2014 20:50:23 +0100 Subject: [PATCH 19/28] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index bd52bd78..f638f2a5 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ Changelog 3.0.5: * Core: Introduce override concept (Daniel Heule) + * Type __process: Make --state absent work (Steven Armstrong) 3.0.4: 2014-01-29 From d1cc8a69999cafbce9dc91cbb81399c0f324abf5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Feb 2014 20:50:59 +0100 Subject: [PATCH 20/28] document environment variables that influence cdist Signed-off-by: Nico Schottelius --- docs/man/cdist-reference.text.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index 5c9f603c..4b1906b4 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -188,8 +188,10 @@ stdin:: when the type was called. -ENVIRONMENT VARIABLES ---------------------- +ENVIRONMENT VARIABLES (FOR READING) +----------------------------------- +The following environment variables are exported by cdist: + __explorer:: Directory that contains all global explorers. Available for: initial manifest, explorer, type explorer, shell @@ -227,6 +229,12 @@ __type_explorer:: Directory that contains the type explorers. Available for: type explorer +ENVIRONMENT VARIABLES (FOR WRITING) +----------------------------------- +The following environment variables influence the behaviour of cdist: + +CDIST_ALLOW_OVERRIDE:: + Allow overwriting type parameters (see cdist-manifest(7)) SEE ALSO -------- From 65b3f6c75ab7c28c725c741c403682cfb15e86f1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Feb 2014 20:52:35 +0100 Subject: [PATCH 21/28] also document require variable Signed-off-by: Nico Schottelius --- docs/man/cdist-reference.text.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index 4b1906b4..5de59eab 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -233,6 +233,9 @@ ENVIRONMENT VARIABLES (FOR WRITING) ----------------------------------- The following environment variables influence the behaviour of cdist: +require:: + Setup dependencies between objects (see cdist-manifest(7)) + CDIST_ALLOW_OVERRIDE:: Allow overwriting type parameters (see cdist-manifest(7)) From f928072f746ed12125b20acd87251852e4366d86 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 5 Feb 2014 21:07:33 +0100 Subject: [PATCH 22/28] let the user decide what is sane and what not Signed-off-by: Steven Armstrong --- cdist/conf/type/__apt_key/man.text | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__apt_key/man.text b/cdist/conf/type/__apt_key/man.text index d571a633..1a33e732 100644 --- a/cdist/conf/type/__apt_key/man.text +++ b/cdist/conf/type/__apt_key/man.text @@ -27,7 +27,8 @@ keyid:: the id of the key to add. Defaults to __object_id keyserver:: - the keyserver from which to fetch the key. If omitted a sane default is used. + the keyserver from which to fetch the key. If omitted the default set in + ./parameter/default/keyserver is used. EXAMPLES From 34f2f7f0389b32c1c46763eda556bd7c98abcbff Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Feb 2014 21:09:24 +0100 Subject: [PATCH 23/28] setting up CDIST_ALLOW_OVERRIDE to any value is ok - do not depend on true/yes/ja Signed-off-by: Nico Schottelius --- cdist/emulator.py | 4 ++-- docs/changelog | 1 + docs/man/man7/cdist-manifest.text | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index ed846e6d..4f91cd8e 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -145,14 +145,14 @@ class Emulator(object): if value is not None: self.parameters[key] = value - if self.cdist_object.exists and os.environ.get('CDIST_ALLOW_OVERRIDE',"false") != 'true': + if self.cdist_object.exists and not 'CDIST_ALLOW_OVERRIDE' in os.environ: if self.cdist_object.parameters != self.parameters: raise cdist.Error("Object %s already exists with conflicting parameters:\n%s: %s\n%s: %s" % (self.cdist_object.name, " ".join(self.cdist_object.source), self.cdist_object.parameters, self.object_source, self.parameters) ) else: if self.cdist_object.exists: - self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE=true',self.cdist_object.name) + self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE',self.cdist_object.name) self.cdist_object.create(True) else: self.cdist_object.create() diff --git a/docs/changelog b/docs/changelog index f638f2a5..14e34b3d 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ Changelog 3.0.5: * Core: Introduce override concept (Daniel Heule) * Type __process: Make --state absent work (Steven Armstrong) + * Documentation: Add documentation for influencing variables 3.0.4: 2014-01-29 diff --git a/docs/man/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text index aa146267..7f1b95dc 100644 --- a/docs/man/man7/cdist-manifest.text +++ b/docs/man/man7/cdist-manifest.text @@ -133,8 +133,8 @@ OVERRIDES --------- In some special cases, you would like to create an already defined object with different parameters. In normal situations this leads to an error in cdist. -If you whish, you can mark this second definition of an object with -CDIST_ALLOW_OVERRIDE=true to tell cdist, that this object override is +If you whish, you can setup the environment variable CDIST_ALLOW_OVERRIDE +(any value or even empty is ok) to tell cdist, that this object override is wanted and should be accepted. ATTENTION: Only use this feature if you are 100% sure in which order cdist encounter the affected objects, otherwhise this results @@ -190,7 +190,7 @@ __user foobar --password 'some_fancy_hash' --home /home/foobarexample __user foobar --password 'some_other_hash' # this tells cdist, that you know that this is an override and should be accepted -CDIST_ALLOW_OVERRIDE=true __user foobar --password 'some_other_hash' +CDIST_ALLOW_OVERRIDE=yes __user foobar --password 'some_other_hash' # its only an override, means the parameter --home is not touched # and stay at the original value of /home/foobarexample -------------------------------------------------------------------------------- From 14a112fcce283d38a43cd9a94575f61e68aa195a Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 5 Feb 2014 21:12:22 +0100 Subject: [PATCH 24/28] /wget/curl/ Signed-off-by: Steven Armstrong --- cdist/conf/type/__apt_key_uri/gencode-remote | 2 +- cdist/conf/type/__apt_key_uri/manifest | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__apt_key_uri/gencode-remote b/cdist/conf/type/__apt_key_uri/gencode-remote index 07af92ac..078b8695 100755 --- a/cdist/conf/type/__apt_key_uri/gencode-remote +++ b/cdist/conf/type/__apt_key_uri/gencode-remote @@ -34,7 +34,7 @@ fi case "$state_should" in present) uri="$(cat "$__object/parameter/uri")" - echo "wget -q \"$uri\" -O - | apt-key add -" + printf 'curl -s -L "%s" | apt-key add -\n' "$uri" ;; absent) cat << DONE diff --git a/cdist/conf/type/__apt_key_uri/manifest b/cdist/conf/type/__apt_key_uri/manifest index 5dae37a7..8dddde56 100755 --- a/cdist/conf/type/__apt_key_uri/manifest +++ b/cdist/conf/type/__apt_key_uri/manifest @@ -18,4 +18,4 @@ # along with cdist. If not, see . # -__package wget +__package curl From 7686a5ac5e14f4368b81a7d00b7dc5b46f21ae10 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 5 Feb 2014 21:17:15 +0100 Subject: [PATCH 25/28] be nice to them users Signed-off-by: Steven Armstrong --- cdist/conf/type/__apt_norecommends/manifest | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__apt_norecommends/manifest b/cdist/conf/type/__apt_norecommends/manifest index 8058d52e..881c2427 100755 --- a/cdist/conf/type/__apt_norecommends/manifest +++ b/cdist/conf/type/__apt_norecommends/manifest @@ -33,8 +33,10 @@ APT::Install-Suggests "0"; DONE ;; *) - echo "This type (${__type##*/}) makes no sense on your operating system ($os)." >&2 - echo "If you think otherwise please submit a patch." >&2 + cat >&2 << DONE +The developer of this type (${__type##*/}) did not think your operating system +($os) would have any use for it. If you think otherwise please submit a patch. +DONE exit 1 ;; esac From 6f0459f3c57607bb4b37ca6ae579f54ffd83c419 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 5 Feb 2014 21:18:47 +0100 Subject: [PATCH 26/28] remove legacy FIXME Signed-off-by: Steven Armstrong --- cdist/conf/type/__apt_source/man.text | 2 +- cdist/conf/type/__apt_source/manifest | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cdist/conf/type/__apt_source/man.text b/cdist/conf/type/__apt_source/man.text index fe40a91e..03b2b311 100644 --- a/cdist/conf/type/__apt_source/man.text +++ b/cdist/conf/type/__apt_source/man.text @@ -32,7 +32,7 @@ distribution:: the targets /etc/lsb-release component:: - space delimited list of components to enable. Defaults to 'main'. + space delimited list of components to enable. Defaults to an empty string. BOOLEAN PARAMETERS diff --git a/cdist/conf/type/__apt_source/manifest b/cdist/conf/type/__apt_source/manifest index b4d72a71..0e782716 100755 --- a/cdist/conf/type/__apt_source/manifest +++ b/cdist/conf/type/__apt_source/manifest @@ -30,8 +30,6 @@ fi if [ -f "$__object/parameter/component" ]; then component="$(cat "$__object/parameter/component")" else - # FIXME: nead to omit this for http://stat.ethz.ch/CRAN//bin/linux/ubuntu, investigate side-effects - #component="main" component="" fi if [ -f "$__object/parameter/arch" ]; then From c663d87ba6e8db478b86478193b48364dc349428 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Feb 2014 22:53:45 +0100 Subject: [PATCH 27/28] release 3.0.5 Signed-off-by: Nico Schottelius --- docs/changelog | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changelog b/docs/changelog index 14e34b3d..5ce2e288 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,10 +4,11 @@ Changelog * Changes are always commented with their author in (braces) * Exception: No braces means author == Nico Schottelius -3.0.5: + +3.0.5: 2014-02-05 * Core: Introduce override concept (Daniel Heule) * Type __process: Make --state absent work (Steven Armstrong) - * Documentation: Add documentation for influencing variables + * Documentation: Update documentation for environment variables 3.0.4: 2014-01-29 From 2e6a8275130a1cb7657c0ed21b8651776e1006b6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Feb 2014 23:15:56 +0100 Subject: [PATCH 28/28] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/changelog b/docs/changelog index 5ce2e288..9c222384 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,13 @@ Changelog * Exception: No braces means author == Nico Schottelius +3.0.6: + * New Type: __apt_key (Steven Armstrong) + * New Type: __apt_key_uri (Steven Armstrong) + * New Type: __apt_norecommends (Steven Armstrong) + * New Type: __apt_source (Steven Armstrong) + + 3.0.5: 2014-02-05 * Core: Introduce override concept (Daniel Heule) * Type __process: Make --state absent work (Steven Armstrong)