From 0e11583b1e563a8afa53fae185942efaaf14d2af Mon Sep 17 00:00:00 2001 From: pestaa Date: Thu, 5 Apr 2012 23:21:11 +0200 Subject: [PATCH 1/8] Fix sed argumenting on FreeBSD. While specifying -i flag is optional on GNU sed, it is mandatory on non-GNU variants. In order to keep behavior backward-compatible, the backup file is always removed. --- conf/type/__key_value/gencode-remote | 6 ++++-- conf/type/__rvm/gencode-remote | 3 ++- conf/type/__start_on_boot/gencode-remote | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/conf/type/__key_value/gencode-remote b/conf/type/__key_value/gencode-remote index 0846dca1..0b02adf2 100755 --- a/conf/type/__key_value/gencode-remote +++ b/conf/type/__key_value/gencode-remote @@ -34,7 +34,8 @@ fi case "$state_should" in absent) # remove lines starting with key - echo "sed -i '/^$key\($delimiter\+\)/d' \"$file\"" + echo "sed -i cdist-backup '/^$key\($delimiter\+\)/d' \"$file\"" + echo "rm -f \"$file.cdist-backup\"" ;; present) case "$state_is" in @@ -44,7 +45,8 @@ case "$state_should" in ;; wrongvalue) # change exisiting value - echo "sed -i \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\"" + echo "sed -i cdist-backup \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\"" + echo "rm -f \"$file.cdist-backup\"" ;; *) echo "Unknown explorer state: $state_is" >&2 diff --git a/conf/type/__rvm/gencode-remote b/conf/type/__rvm/gencode-remote index f306979a..ec39acac 100755 --- a/conf/type/__rvm/gencode-remote +++ b/conf/type/__rvm/gencode-remote @@ -32,7 +32,8 @@ DONE removed) cat << DONE su - $user -c "rm -Rf \"\\\$HOME/.rvm\"; -sed -i '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\"" +sed -i cdist-backup '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\"" +rm -f \"\\\$HOME/.bashrc.cdist-backup\"" DONE ;; esac diff --git a/conf/type/__start_on_boot/gencode-remote b/conf/type/__start_on_boot/gencode-remote index a64c1096..a6ecf032 100755 --- a/conf/type/__start_on_boot/gencode-remote +++ b/conf/type/__start_on_boot/gencode-remote @@ -32,7 +32,8 @@ case "$state_should" in present) case "$os" in archlinux) - echo "sed -i 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf" + echo "sed -i cdist-backup 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf" + echo "rm -f /etc/rc.conf.cdist-backup" ;; debian|ubuntu) echo "update-rc.d \"$name\" defaults >/dev/null" @@ -66,7 +67,8 @@ case "$state_should" in archlinux) # Replace a) at the beginning b) in the middle c) end d) only # Support @name as well...makes it more ugly, but well... - echo "sed -i /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/'" + echo "sed -i cdist-backup /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/'" + echo "rm -f /etc/rc.conf.cdist-backup" ;; debian|ubuntu) echo update-rc.d -f \"$name\" remove From cb47a7d56f2e89e5433ea3f4b1ad1009445fed88 Mon Sep 17 00:00:00 2001 From: Istvan Beregszaszi Date: Fri, 6 Apr 2012 00:29:14 +0300 Subject: [PATCH 2/8] Fix indenting. --- conf/type/__start_on_boot/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/type/__start_on_boot/gencode-remote b/conf/type/__start_on_boot/gencode-remote index a6ecf032..ffd30f7f 100755 --- a/conf/type/__start_on_boot/gencode-remote +++ b/conf/type/__start_on_boot/gencode-remote @@ -33,7 +33,7 @@ case "$state_should" in case "$os" in archlinux) echo "sed -i cdist-backup 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf" - echo "rm -f /etc/rc.conf.cdist-backup" + echo "rm -f /etc/rc.conf.cdist-backup" ;; debian|ubuntu) echo "update-rc.d \"$name\" defaults >/dev/null" @@ -68,7 +68,7 @@ case "$state_should" in # Replace a) at the beginning b) in the middle c) end d) only # Support @name as well...makes it more ugly, but well... echo "sed -i cdist-backup /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/'" - echo "rm -f /etc/rc.conf.cdist-backup" + echo "rm -f /etc/rc.conf.cdist-backup" ;; debian|ubuntu) echo update-rc.d -f \"$name\" remove From f9c945cc86fcf96b048313f8ea239f36f2629d16 Mon Sep 17 00:00:00 2001 From: pestaa Date: Fri, 6 Apr 2012 11:15:06 +0200 Subject: [PATCH 3/8] Changed tactics. Sed's -i flag is not cross-platform. --- conf/type/__key_value/gencode-remote | 6 ++---- conf/type/__rvm/gencode-remote | 3 +-- conf/type/__start_on_boot/gencode-remote | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/conf/type/__key_value/gencode-remote b/conf/type/__key_value/gencode-remote index 0b02adf2..84ea6430 100755 --- a/conf/type/__key_value/gencode-remote +++ b/conf/type/__key_value/gencode-remote @@ -34,8 +34,7 @@ fi case "$state_should" in absent) # remove lines starting with key - echo "sed -i cdist-backup '/^$key\($delimiter\+\)/d' \"$file\"" - echo "rm -f \"$file.cdist-backup\"" + echo "sed '/^$key\($delimiter\+\)/d' \"$file\" | tee \"$file\" > /dev/null" ;; present) case "$state_is" in @@ -45,8 +44,7 @@ case "$state_should" in ;; wrongvalue) # change exisiting value - echo "sed -i cdist-backup \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\"" - echo "rm -f \"$file.cdist-backup\"" + echo "sed \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\" | tee \"$file\" > /dev/null" ;; *) echo "Unknown explorer state: $state_is" >&2 diff --git a/conf/type/__rvm/gencode-remote b/conf/type/__rvm/gencode-remote index ec39acac..cc527678 100755 --- a/conf/type/__rvm/gencode-remote +++ b/conf/type/__rvm/gencode-remote @@ -32,8 +32,7 @@ DONE removed) cat << DONE su - $user -c "rm -Rf \"\\\$HOME/.rvm\"; -sed -i cdist-backup '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\"" -rm -f \"\\\$HOME/.bashrc.cdist-backup\"" +sed '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\" | tee \"\\\$HOME/.bashrc\" > /dev/null" DONE ;; esac diff --git a/conf/type/__start_on_boot/gencode-remote b/conf/type/__start_on_boot/gencode-remote index a6ecf032..f6036dc1 100755 --- a/conf/type/__start_on_boot/gencode-remote +++ b/conf/type/__start_on_boot/gencode-remote @@ -32,8 +32,7 @@ case "$state_should" in present) case "$os" in archlinux) - echo "sed -i cdist-backup 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf" - echo "rm -f /etc/rc.conf.cdist-backup" + echo "sed 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf | tee /etc/rc.conf > /dev/null" ;; debian|ubuntu) echo "update-rc.d \"$name\" defaults >/dev/null" @@ -67,8 +66,7 @@ case "$state_should" in archlinux) # Replace a) at the beginning b) in the middle c) end d) only # Support @name as well...makes it more ugly, but well... - echo "sed -i cdist-backup /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/'" - echo "rm -f /etc/rc.conf.cdist-backup" + echo "sed /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/' | tee /etc/rc.conf > /dev/null" ;; debian|ubuntu) echo update-rc.d -f \"$name\" remove From deafcc60e8ffaec0338e306062c24749a3d72049 Mon Sep 17 00:00:00 2001 From: pestaa Date: Fri, 6 Apr 2012 18:55:35 +0200 Subject: [PATCH 4/8] Workound lack of pipeline's integrity guarantee. --- conf/type/__key_value/gencode-remote | 6 ++++-- conf/type/__rvm/gencode-remote | 4 +++- conf/type/__start_on_boot/gencode-remote | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/conf/type/__key_value/gencode-remote b/conf/type/__key_value/gencode-remote index 84ea6430..b3ffeb46 100755 --- a/conf/type/__key_value/gencode-remote +++ b/conf/type/__key_value/gencode-remote @@ -34,7 +34,8 @@ fi case "$state_should" in absent) # remove lines starting with key - echo "sed '/^$key\($delimiter\+\)/d' \"$file\" | tee \"$file\" > /dev/null" + echo "sed '/^$key\($delimiter\+\)/d' \"$file\" > \"$file.cdist-tmp\"" + echo "mv \"$file.cdist-tmp\" \"$file\"" ;; present) case "$state_is" in @@ -44,7 +45,8 @@ case "$state_should" in ;; wrongvalue) # change exisiting value - echo "sed \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\" | tee \"$file\" > /dev/null" + echo "sed \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\" > \"$file.cdist-tmp\"" + echo "mv \"$file.cdist-tmp\" \"$file\"" ;; *) echo "Unknown explorer state: $state_is" >&2 diff --git a/conf/type/__rvm/gencode-remote b/conf/type/__rvm/gencode-remote index cc527678..1ba1d499 100755 --- a/conf/type/__rvm/gencode-remote +++ b/conf/type/__rvm/gencode-remote @@ -32,7 +32,9 @@ DONE removed) cat << DONE su - $user -c "rm -Rf \"\\\$HOME/.rvm\"; -sed '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\" | tee \"\\\$HOME/.bashrc\" > /dev/null" +sed '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\" > \"\\\$HOME/.bashrc.cdist-tmp\" +mv \"\\\$HOME/.bashrc.cdist-tmp\" \"\\\$HOME/.bashrc\"" + DONE ;; esac diff --git a/conf/type/__start_on_boot/gencode-remote b/conf/type/__start_on_boot/gencode-remote index f6036dc1..78a82de3 100755 --- a/conf/type/__start_on_boot/gencode-remote +++ b/conf/type/__start_on_boot/gencode-remote @@ -32,7 +32,8 @@ case "$state_should" in present) case "$os" in archlinux) - echo "sed 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf | tee /etc/rc.conf > /dev/null" + echo "sed 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf > /etc/rc.conf.cdist-tmp" + echo "mv /etc/rc.conf.cdist-tmp /etc/rc.conf" ;; debian|ubuntu) echo "update-rc.d \"$name\" defaults >/dev/null" @@ -66,7 +67,8 @@ case "$state_should" in archlinux) # Replace a) at the beginning b) in the middle c) end d) only # Support @name as well...makes it more ugly, but well... - echo "sed /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/' | tee /etc/rc.conf > /dev/null" + echo "sed /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/' > /etc/rc.conf.cdist-tmp" + echo "mv /etc/rc.conf.cdist-tmp /etc/rc.conf" ;; debian|ubuntu) echo update-rc.d -f \"$name\" remove From 32d6cbb7a123683843eef903f0c616f6a7019c5a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 22 Apr 2012 01:20:32 +0200 Subject: [PATCH 5/8] ++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 1dd73d87..11235f8a 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -6,6 +6,8 @@ Feel free to pick one! CORE ---- - support default parameter +- document and add paremeters for remote-copy and remote-exec! + - remove hack, make a feature of it TESTS ----- From bc1a2d769dbbe2b7eac314343c90107efd58fdd9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 22 Apr 2012 01:20:44 +0200 Subject: [PATCH 6/8] ++title line Signed-off-by: Nico Schottelius --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index e514df91..73e5c210 100644 --- a/README +++ b/README @@ -288,7 +288,7 @@ Interesting information are for instance * What are the pros/cons you see in cdist? * General comments/critics -### Nico Schottelius, Systems Group ETH Zurich and privately +### Nico Schottelius, Systems Group ETH Zurich, local.ch and privately Yes, I'm actually eating my own dogfood and currently managing From 2ff286cf1d536bf6c83e81233726ffbf4688d21e Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 25 Apr 2012 17:18:16 +0200 Subject: [PATCH 7/8] inherit dependencies from defining object when setting up implicit dependencies through autorequire Signed-off-by: Steven Armstrong --- lib/cdist/emulator.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index c4b84feb..99b34554 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -160,10 +160,19 @@ class Emulator(object): 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 is the name of the object whose type manifest is currently executed __object_name = os.environ.get('__object_name', None) if __object_name: - _object = self.cdist_object.object_from_name(__object_name) - # prevent circular dependencies - if not _object.name in self.cdist_object.requirements: - _object.requirements.append(self.cdist_object.name) + # The object whose type manifest is currently run + parent = self.cdist_object.object_from_name(__object_name) + # The object currently being defined + current_object = self.cdist_object + # current_object shall have all dependencies that it's parent has + for req in parent.requirements: + if req not in current_object.requirements: + current_object.requirements.append(req) + # As parent defined current_object it shall automatically depend on it. + # But only if the user hasn't said otherwise. + # Must prevent circular dependencies. + if not parent.name in current_object.requirements: + parent.requirements.append(current_object.name) From 75aea916434c63681634be27c6d63f654739e5cb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 27 Apr 2012 11:39:08 +0200 Subject: [PATCH 8/8] ++changes(2.0.10) Signed-off-by: Nico Schottelius --- doc/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/changelog b/doc/changelog index e3f7d1a5..267be9e7 100644 --- a/doc/changelog +++ b/doc/changelog @@ -11,6 +11,8 @@ Changelog * Bugfix __start_on_boot: Correctly use sed and quotes (Steven Armstrong) * Feature __file: Support for --state exists (Steven Armstrong) * Feature core: Make variable __manifest available to type manifests + * Feature core: Correct parent dependency handling (Steven Armstrong) + * Bugfix several types: Fix sed for FreeBSD (Istvan Beregszaszi) 2.0.9: 2012-03-12 * Cleanup documentation: Fix environment variable list to be properly