From 423001b7026ab183fb204181c58ef5fb6a7901f0 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Sat, 8 Feb 2014 21:48:51 +0100 Subject: [PATCH 01/10] Make state parameter optional for all types, fixes #131 --- cdist/conf/type/__pf_ruleset/man.text | 2 +- cdist/conf/type/__pf_ruleset/parameter/default/state | 1 + cdist/conf/type/__pf_ruleset/parameter/optional | 1 + cdist/conf/type/__postgres_database/gencode-remote | 3 +-- cdist/conf/type/__postgres_database/man.text | 2 +- cdist/conf/type/__postgres_database/parameter/default/state | 1 + cdist/conf/type/__postgres_role/gencode-remote | 3 +-- cdist/conf/type/__postgres_role/parameter/default/state | 1 + cdist/conf/type/__rvm/man.text | 2 +- cdist/conf/type/__rvm/parameter/default/state | 1 + .../parameter/required => __rvm/parameter/optional} | 0 cdist/conf/type/__rvm_gemset/man.text | 2 +- cdist/conf/type/__rvm_gemset/parameter/default/state | 1 + .../parameter/required => __rvm_gemset/parameter/optional} | 0 cdist/conf/type/__rvm_gemset/parameter/required | 1 - cdist/conf/type/__rvm_ruby/man.text | 2 +- cdist/conf/type/__rvm_ruby/parameter/default/state | 1 + cdist/conf/type/__rvm_ruby/parameter/optional | 1 + cdist/conf/type/__rvm_ruby/parameter/required | 1 - 19 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 cdist/conf/type/__pf_ruleset/parameter/default/state create mode 100644 cdist/conf/type/__postgres_database/parameter/default/state create mode 100644 cdist/conf/type/__postgres_role/parameter/default/state create mode 100644 cdist/conf/type/__rvm/parameter/default/state rename cdist/conf/type/{__pf_ruleset/parameter/required => __rvm/parameter/optional} (100%) create mode 100644 cdist/conf/type/__rvm_gemset/parameter/default/state rename cdist/conf/type/{__rvm/parameter/required => __rvm_gemset/parameter/optional} (100%) create mode 100644 cdist/conf/type/__rvm_ruby/parameter/default/state create mode 100644 cdist/conf/type/__rvm_ruby/parameter/optional diff --git a/cdist/conf/type/__pf_ruleset/man.text b/cdist/conf/type/__pf_ruleset/man.text index 0dc07f71..29efe065 100644 --- a/cdist/conf/type/__pf_ruleset/man.text +++ b/cdist/conf/type/__pf_ruleset/man.text @@ -16,7 +16,7 @@ This type is used on *BSD systems to manage the pf firewall's ruleset. REQUIRED PARAMETERS ------------------- state:: - Either "absent" (no ruleset at all) or "present" + Either "absent" (no ruleset at all) or "present", defaults to "present". OPTIONAL PARAMETERS diff --git a/cdist/conf/type/__pf_ruleset/parameter/default/state b/cdist/conf/type/__pf_ruleset/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__pf_ruleset/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__pf_ruleset/parameter/optional b/cdist/conf/type/__pf_ruleset/parameter/optional index 5a18cd2f..d77f3048 100644 --- a/cdist/conf/type/__pf_ruleset/parameter/optional +++ b/cdist/conf/type/__pf_ruleset/parameter/optional @@ -1 +1,2 @@ source +state diff --git a/cdist/conf/type/__postgres_database/gencode-remote b/cdist/conf/type/__postgres_database/gencode-remote index 0ffc842a..c097efce 100755 --- a/cdist/conf/type/__postgres_database/gencode-remote +++ b/cdist/conf/type/__postgres_database/gencode-remote @@ -19,8 +19,7 @@ # name="$__object_id" -state_should="present" -[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")" +state_should="$(cat "$__object/parameter/state")" state_is="$(cat "$__object/explorer/state")" if [ "$state_should" != "$state_is" ]; then diff --git a/cdist/conf/type/__postgres_database/man.text b/cdist/conf/type/__postgres_database/man.text index 88259b6f..c7c0d3cd 100644 --- a/cdist/conf/type/__postgres_database/man.text +++ b/cdist/conf/type/__postgres_database/man.text @@ -16,7 +16,7 @@ This cdist type allows you to create or drop postgres databases. OPTIONAL PARAMETERS ------------------- state:: - either 'present' or 'absent' + either 'present' or 'absent', defaults to 'present'. owner:: the role owning this database diff --git a/cdist/conf/type/__postgres_database/parameter/default/state b/cdist/conf/type/__postgres_database/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__postgres_database/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index 65a9d588..0230e48e 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -20,8 +20,7 @@ name="$__object_id" state_is="$(cat "$__object/explorer/state")" -state_should="present" -[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")" +state_should="$(cat "$__object/parameter/state")" [ "$state_is" = "$state_should" ] && exit 0 diff --git a/cdist/conf/type/__postgres_role/parameter/default/state b/cdist/conf/type/__postgres_role/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__postgres_role/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__rvm/man.text b/cdist/conf/type/__rvm/man.text index c1f83e60..0408d125 100644 --- a/cdist/conf/type/__rvm/man.text +++ b/cdist/conf/type/__rvm/man.text @@ -16,7 +16,7 @@ RVM is the Ruby enVironment Manager for the Ruby programming language. REQUIRED PARAMETERS ------------------- state:: - Either "present" or "absent". + Either "present" or "absent", defaults to "present". EXAMPLES diff --git a/cdist/conf/type/__rvm/parameter/default/state b/cdist/conf/type/__rvm/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__rvm/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__pf_ruleset/parameter/required b/cdist/conf/type/__rvm/parameter/optional similarity index 100% rename from cdist/conf/type/__pf_ruleset/parameter/required rename to cdist/conf/type/__rvm/parameter/optional diff --git a/cdist/conf/type/__rvm_gemset/man.text b/cdist/conf/type/__rvm_gemset/man.text index 44c0c555..e85425f3 100644 --- a/cdist/conf/type/__rvm_gemset/man.text +++ b/cdist/conf/type/__rvm_gemset/man.text @@ -18,7 +18,7 @@ REQUIRED PARAMETERS user:: The remote user account to use state:: - Either "present" or "absent". + Either "present" or "absent", defaults to "present". BOOLEAN PARAMETERS ------------------- diff --git a/cdist/conf/type/__rvm_gemset/parameter/default/state b/cdist/conf/type/__rvm_gemset/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__rvm_gemset/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__rvm/parameter/required b/cdist/conf/type/__rvm_gemset/parameter/optional similarity index 100% rename from cdist/conf/type/__rvm/parameter/required rename to cdist/conf/type/__rvm_gemset/parameter/optional diff --git a/cdist/conf/type/__rvm_gemset/parameter/required b/cdist/conf/type/__rvm_gemset/parameter/required index 5aea6f1e..4eb8387f 100644 --- a/cdist/conf/type/__rvm_gemset/parameter/required +++ b/cdist/conf/type/__rvm_gemset/parameter/required @@ -1,2 +1 @@ -state user diff --git a/cdist/conf/type/__rvm_ruby/man.text b/cdist/conf/type/__rvm_ruby/man.text index dbbab85e..6419a4d4 100644 --- a/cdist/conf/type/__rvm_ruby/man.text +++ b/cdist/conf/type/__rvm_ruby/man.text @@ -18,7 +18,7 @@ REQUIRED PARAMETERS user:: The remote user account to use state:: - Either "present" or "absent". + Either "present" or "absent", defaults to "present". BOOLEAN PARAMETERS ------------------ diff --git a/cdist/conf/type/__rvm_ruby/parameter/default/state b/cdist/conf/type/__rvm_ruby/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__rvm_ruby/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__rvm_ruby/parameter/optional b/cdist/conf/type/__rvm_ruby/parameter/optional new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/cdist/conf/type/__rvm_ruby/parameter/optional @@ -0,0 +1 @@ +state diff --git a/cdist/conf/type/__rvm_ruby/parameter/required b/cdist/conf/type/__rvm_ruby/parameter/required index 5aea6f1e..4eb8387f 100644 --- a/cdist/conf/type/__rvm_ruby/parameter/required +++ b/cdist/conf/type/__rvm_ruby/parameter/required @@ -1,2 +1 @@ -state user From f3172fda957557174fe8d123a28ef50d0076658e Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Sat, 8 Feb 2014 22:06:27 +0100 Subject: [PATCH 02/10] 2 more types for issue 131 --- cdist/conf/type/__jail/man.text | 2 +- cdist/conf/type/__jail/parameter/default/state | 1 + cdist/conf/type/__jail/parameter/optional | 1 + cdist/conf/type/__jail/parameter/required | 1 - cdist/conf/type/__rvm_gem/man.text | 2 +- cdist/conf/type/__rvm_gem/parameter/default/state | 1 + cdist/conf/type/__rvm_gem/parameter/optional | 1 + cdist/conf/type/__rvm_gem/parameter/required | 1 - 8 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 cdist/conf/type/__jail/parameter/default/state delete mode 100644 cdist/conf/type/__jail/parameter/required create mode 100644 cdist/conf/type/__rvm_gem/parameter/default/state diff --git a/cdist/conf/type/__jail/man.text b/cdist/conf/type/__jail/man.text index b439e0f5..9c968d84 100644 --- a/cdist/conf/type/__jail/man.text +++ b/cdist/conf/type/__jail/man.text @@ -16,7 +16,7 @@ This type is used on FreeBSD to manage jails. REQUIRED PARAMETERS ------------------- state:: - Either "present" or "absent." + Either "present" or "absent", defaults to "present". jailbase:: The location of the .tgz archive containing the base fs for your jails. diff --git a/cdist/conf/type/__jail/parameter/default/state b/cdist/conf/type/__jail/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__jail/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__jail/parameter/optional b/cdist/conf/type/__jail/parameter/optional index 08ecd469..b36f0fa5 100644 --- a/cdist/conf/type/__jail/parameter/optional +++ b/cdist/conf/type/__jail/parameter/optional @@ -5,3 +5,4 @@ interface devfs-ruleset jaildir jailbase +state diff --git a/cdist/conf/type/__jail/parameter/required b/cdist/conf/type/__jail/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/cdist/conf/type/__jail/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/cdist/conf/type/__rvm_gem/man.text b/cdist/conf/type/__rvm_gem/man.text index 2b72e7ae..d7eff3be 100644 --- a/cdist/conf/type/__rvm_gem/man.text +++ b/cdist/conf/type/__rvm_gem/man.text @@ -20,7 +20,7 @@ user:: gemset:: The gemset to use state:: - Either "present" or "absent" + Either "present" or "absent", defaults to "present". OPTIONAL PARAMETERS ------------------- diff --git a/cdist/conf/type/__rvm_gem/parameter/default/state b/cdist/conf/type/__rvm_gem/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__rvm_gem/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__rvm_gem/parameter/optional b/cdist/conf/type/__rvm_gem/parameter/optional index 4ad96d51..96983811 100644 --- a/cdist/conf/type/__rvm_gem/parameter/optional +++ b/cdist/conf/type/__rvm_gem/parameter/optional @@ -1 +1,2 @@ default +state diff --git a/cdist/conf/type/__rvm_gem/parameter/required b/cdist/conf/type/__rvm_gem/parameter/required index 75f60bb8..58243a95 100644 --- a/cdist/conf/type/__rvm_gem/parameter/required +++ b/cdist/conf/type/__rvm_gem/parameter/required @@ -1,3 +1,2 @@ -state gemset user From cfbc68aa113ddf74fa0d7fe4c78da5a251491ff8 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Wed, 12 Feb 2014 10:31:46 +0100 Subject: [PATCH 03/10] bugfix if both override and order is specified --- cdist/emulator.py | 3 ++- docs/man/cdist-reference.text.sh | 2 +- docs/man/man7/cdist-manifest.text | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index c910531c..41834fbf 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -189,7 +189,8 @@ class Emulator(object): def record_requirements(self): """record requirements""" - if "CDIST_ORDER_DEPENDENCY" in self.env: + # Inject the predecessor, but not if its an override (this would leed to an circular dependency) + if "CDIST_ORDER_DEPENDENCY" in self.env and not 'CDIST_OVERRIDE' in self.env: # load object name created bevor this one from typeorder file ... with open(self.typeorder_path, 'r') as typecreationfile: typecreationorder = typecreationfile.readlines() diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index 88a002df..62614c55 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -236,7 +236,7 @@ The following environment variables influence the behaviour of cdist: require:: Setup dependencies between objects (see cdist-manifest(7)) -CDIST_ALLOW_OVERRIDE:: +CDIST_OVERRIDE:: Allow overwriting type parameters (see cdist-manifest(7)) CDIST_ORDER_DEPENDENCY:: diff --git a/docs/man/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text index 25637242..057905ea 100644 --- a/docs/man/man7/cdist-manifest.text +++ b/docs/man/man7/cdist-manifest.text @@ -152,6 +152,10 @@ 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. +If CDIST_OVERRIDE and CDIST_ORDER_DEPENDENCY is set for an object, +CDIST_ORDER_DEPENDENCY will be ignored, because adding a dependency in case of +overrides would result in circular dependencies, which is an error. + THIS IS A BETA FEATURE AND MAY BE REMOVED OR CHANGED AT ANY TIME. From a4376b4d744f118b148c3875c08e2704e4449021 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 12 Feb 2014 16:57:29 +0100 Subject: [PATCH 04/10] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 2ebd08e8..dabb1da3 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ Changelog 3.0.9: * Type __locale: Error out in case of unsupported OS + * Core: Ignore order dependencies if override is set (Daniel Heule) 3.0.8: 2014-02-11 * Core: Enhance object id verification (Daniel Heule) From 2afa0ad2fc717730630789349e1b1ac6451b2acc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 12 Feb 2014 17:07:07 +0100 Subject: [PATCH 05/10] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index dabb1da3..4b3a01e1 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,8 +6,17 @@ Changelog 3.0.9: - * Type __locale: Error out in case of unsupported OS * Core: Ignore order dependencies if override is set (Daniel Heule) + * Type __locale: Error out in case of unsupported OS + * Type __jail: Use default parameters for state (Daniel Heule) + * Type __pf_ruleset: Use default parameters for state (Daniel Heule) + * Type __postgres_database: Use default parameters for state (Daniel Heule) + * Type __postgres_role: Use default parameters for state (Daniel Heule) + * Type __rvm: Use default parameters for state (Daniel Heule) + * Type __rvm_gem: Use default parameters for state (Daniel Heule) + * Type __rvm_gemset: Use default parameters for state (Daniel Heule) + * Type __rvm_ruby: Use default parameters for state (Daniel Heule) + 3.0.8: 2014-02-11 * Core: Enhance object id verification (Daniel Heule) From a2c2cc139aade56886d8c474fa3c159a0c29222b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 13 Feb 2014 10:33:24 +0100 Subject: [PATCH 06/10] adjust default branch hint Signed-off-by: Nico Schottelius --- cdist/conf/type/__git/man.text | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/conf/type/__git/man.text b/cdist/conf/type/__git/man.text index 7c6b83cd..5f74108b 100644 --- a/cdist/conf/type/__git/man.text +++ b/cdist/conf/type/__git/man.text @@ -26,6 +26,7 @@ state:: branch:: Create this branch by checking out the remote branch of this name + Default branch is "master" group:: Group to chgrp to. From 46459053f463789f01a4afc159d1ab02a1940a11 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 13 Feb 2014 21:02:18 +0100 Subject: [PATCH 07/10] use posix -L in favour of longopts Signed-off-by: Steven Armstrong --- cdist/test/fixtures/remote/copy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/test/fixtures/remote/copy b/cdist/test/fixtures/remote/copy index a4627716..05f43eb1 100755 --- a/cdist/test/fixtures/remote/copy +++ b/cdist/test/fixtures/remote/copy @@ -1,7 +1,7 @@ #!/bin/sh # # 2012-2013 Nico Schottelius (nico-cdist schottelius.org) -# 2013 Steven Armstrong (steven-cdist armstrong.cc) +# 2013-2014 Steven Armstrong (steven-cdist armstrong.cc) # # This file is part of cdist. # @@ -20,4 +20,4 @@ # code="$(echo "$@" | sed "s|\([[:space:]]\)$__target_host:|\1|g")" -cp --dereference $code +cp -L $code From f82a6224f228cf9bb52b44302e8371cfd5a125c6 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 13 Feb 2014 21:05:37 +0100 Subject: [PATCH 08/10] use positional arguments in favour of keyword arguments for backwards compatibility with older python Signed-off-by: Steven Armstrong --- cdist/test/cdist_object/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/test/cdist_object/__init__.py b/cdist/test/cdist_object/__init__.py index 28f2455b..3c25a959 100644 --- a/cdist/test/cdist_object/__init__.py +++ b/cdist/test/cdist_object/__init__.py @@ -49,7 +49,7 @@ class ObjectClassTestCase(test.CdistTestCase): self.expected_objects = [] for cdist_object_name in self.expected_object_names: - cdist_type, cdist_object_id = cdist_object_name.split("/", maxsplit=1) + cdist_type, cdist_object_id = cdist_object_name.split("/", 1) cdist_object = core.CdistObject(core.CdistType(type_base_path, cdist_type), object_base_path, cdist_object_id) self.expected_objects.append(cdist_object) From a765fe5c07117c8abfe33207952d0ad3cac24aa7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Feb 2014 01:48:33 +0100 Subject: [PATCH 09/10] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 4b3a01e1..0930f01d 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ Changelog 3.0.9: * Core: Ignore order dependencies if override is set (Daniel Heule) + * Core: Improve unit tests for Mac OS X (Steven Armstrong) * Type __locale: Error out in case of unsupported OS * Type __jail: Use default parameters for state (Daniel Heule) * Type __pf_ruleset: Use default parameters for state (Daniel Heule) From d55763ad6d0c7da333be297c6770225a1c094e28 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Feb 2014 09:59:56 +0100 Subject: [PATCH 10/10] ++release Signed-off-by: Nico Schottelius --- docs/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog b/docs/changelog index 0930f01d..e8f98c01 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,9 +5,9 @@ Changelog * Exception: No braces means author == Nico Schottelius -3.0.9: +3.0.9: 2014-02-14 * Core: Ignore order dependencies if override is set (Daniel Heule) - * Core: Improve unit tests for Mac OS X (Steven Armstrong) + * Core: Improve Mac OS X support for unit tests (Steven Armstrong) * Type __locale: Error out in case of unsupported OS * Type __jail: Use default parameters for state (Daniel Heule) * Type __pf_ruleset: Use default parameters for state (Daniel Heule)