From e540502830e7ce54c081e97504347e22c5ae6ac8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 3 Apr 2012 05:59:24 +0200 Subject: [PATCH 1/9] Missing cat in __package_yum Signed-off-by: Nico Schottelius --- conf/type/__package_yum/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__package_yum/gencode-remote b/conf/type/__package_yum/gencode-remote index a10e60dd..df2bf405 100755 --- a/conf/type/__package_yum/gencode-remote +++ b/conf/type/__package_yum/gencode-remote @@ -22,7 +22,7 @@ # if [ -f "$__object/parameter/name" ]; then - name="$__object/parameter/name" + name="$(cat "$__object/parameter/name")" else name="$__object_id" fi From 941e89f950d0c121cfbd06cbd2cfec24bd80f0ab Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 3 Apr 2012 06:00:00 +0200 Subject: [PATCH 2/9] ++changes(2.0.10) Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index ce9f798b..127b33ee 100644 --- a/doc/changelog +++ b/doc/changelog @@ -7,6 +7,7 @@ Changelog 2.0.10: * Cleanup __group: No getent gshadow in old Redhat, use groupmod -g (Matt Coddington) + * Bugfix __package_yum: Missing cat 2.0.9: 2012-03-12 * Cleanup documentation: Fix environment variable list to be properly From 386c12f2512b45a197450fd7ece6bb8a634004ab Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 3 Apr 2012 17:52:58 +0200 Subject: [PATCH 3/9] nested quotes should not be escaped Signed-off-by: Steven Armstrong --- conf/type/__start_on_boot/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__start_on_boot/gencode-remote b/conf/type/__start_on_boot/gencode-remote index 974abb30..b9e26815 100755 --- a/conf/type/__start_on_boot/gencode-remote +++ b/conf/type/__start_on_boot/gencode-remote @@ -32,7 +32,7 @@ case "$state_should" in present) case "$os" in archlinux) - echo "sed -i /etc/rc.conf \'s/^\\(DAEMONS=.*\\))/\\1 $name)/\'" + echo "sed -i /etc/rc.conf 's/^\\(DAEMONS=.*\\))/\\1 $name)/'" ;; debian|ubuntu) echo "update-rc.d \"$name\" defaults >/dev/null" From 18a25dc65bf8b00a41ad805efcc2941aa2e61829 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 3 Apr 2012 17:53:28 +0200 Subject: [PATCH 4/9] file must be last argument Signed-off-by: Steven Armstrong --- conf/type/__start_on_boot/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__start_on_boot/gencode-remote b/conf/type/__start_on_boot/gencode-remote index b9e26815..a64c1096 100755 --- a/conf/type/__start_on_boot/gencode-remote +++ b/conf/type/__start_on_boot/gencode-remote @@ -32,7 +32,7 @@ case "$state_should" in present) case "$os" in archlinux) - echo "sed -i /etc/rc.conf 's/^\\(DAEMONS=.*\\))/\\1 $name)/'" + echo "sed -i 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf" ;; debian|ubuntu) echo "update-rc.d \"$name\" defaults >/dev/null" From ffcf57ee45783145451484ae94f8edc25e6a9195 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 4 Apr 2012 00:08:23 +0200 Subject: [PATCH 5/9] implement --state exists Signed-off-by: Steven Armstrong --- conf/type/__file/gencode-local | 3 +++ conf/type/__file/man.text | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conf/type/__file/gencode-local b/conf/type/__file/gencode-local index d9839a19..a55cfc2b 100755 --- a/conf/type/__file/gencode-local +++ b/conf/type/__file/gencode-local @@ -23,6 +23,9 @@ destination="/$__object_id" state_should="$(cat "$__object/parameter/state")" +exists="$(cat "$__object/explorer/exists")" + +[ "$state_should" = "exists" -a "$exists" = "yes" ] && exit 0 # nothing to do if [ "$state_should" = "present" ]; then if [ -f "$__object/parameter/source" ]; then diff --git a/conf/type/__file/man.text b/conf/type/__file/man.text index 5e91599f..db20d857 100644 --- a/conf/type/__file/man.text +++ b/conf/type/__file/man.text @@ -21,7 +21,11 @@ None. OPTIONAL PARAMETERS ------------------- state:: - 'present' or 'absent', defaults to 'present' + 'present', 'absent' or 'exists', defaults to 'present' + where: + present: the file is exactly the one from source + absent: the file does not exist + exists: the file from source but only if it doesn't already exist group:: Group to chgrp to. From e3f767f5a1cfba53cf8ba5dc6a7490de02bf1eb4 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 4 Apr 2012 09:37:18 +0200 Subject: [PATCH 6/9] += example Signed-off-by: Steven Armstrong --- conf/type/__file/man.text | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf/type/__file/man.text b/conf/type/__file/man.text index db20d857..0215027a 100644 --- a/conf/type/__file/man.text +++ b/conf/type/__file/man.text @@ -59,6 +59,11 @@ __file /etc/issue --source "$__type/files/archlinux" --state present __file /etc/shadow --source "$__type/files/shadow" \ --owner root --group shadow --mode 0640 \ --state present + +# Provide a default file, but let the user change it +__file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \ + --state exists \ + --owner frodo --mode 0600 -------------------------------------------------------------------------------- From 9da25ca4eaa7ca2a5be27d4f871d90ecc08b904d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 4 Apr 2012 09:44:57 +0200 Subject: [PATCH 7/9] ++changes(2.0.10) Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index 127b33ee..08232af6 100644 --- a/doc/changelog +++ b/doc/changelog @@ -8,6 +8,7 @@ Changelog * Cleanup __group: No getent gshadow in old Redhat, use groupmod -g (Matt Coddington) * Bugfix __package_yum: Missing cat + * Feature __file: Support for --state exists (Steven Armstrong) 2.0.9: 2012-03-12 * Cleanup documentation: Fix environment variable list to be properly From 689acb4c2167a42574645b4d03bfae16f0b5c784 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 4 Apr 2012 09:47:52 +0200 Subject: [PATCH 8/9] ++changes(2.0.10) Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index 08232af6..0bd00135 100644 --- a/doc/changelog +++ b/doc/changelog @@ -8,6 +8,7 @@ Changelog * Cleanup __group: No getent gshadow in old Redhat, use groupmod -g (Matt Coddington) * Bugfix __package_yum: Missing cat + * Bugfix __start_on_boot: Correctly use sed and quotes (Steven Armstrong) * Feature __file: Support for --state exists (Steven Armstrong) 2.0.9: 2012-03-12 From 7d2799d958ce90769f19d54f74359f4b4db7fba6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 4 Apr 2012 17:21:54 +0200 Subject: [PATCH 9/9] Make __manifest usable in type manifests Signed-off-by: Nico Schottelius --- doc/changelog | 1 + doc/man/cdist-reference.text.sh | 2 +- lib/cdist/core/manifest.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/changelog b/doc/changelog index 0bd00135..e3f7d1a5 100644 --- a/doc/changelog +++ b/doc/changelog @@ -10,6 +10,7 @@ Changelog * Bugfix __package_yum: Missing cat * 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 2.0.9: 2012-03-12 * Cleanup documentation: Fix environment variable list to be properly diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index 6bd5f1b8..2aa87aa1 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -173,7 +173,7 @@ __explorer:: Available for: explorer, type explorer __manifest:: Directory that contains the initial manifest. - Available for: initial manifest + Available for: initial manifest, type manifest __global:: Directory that contains generic output like explorer. Available for: initial manifest, type manifest, type gencode diff --git a/lib/cdist/core/manifest.py b/lib/cdist/core/manifest.py index 8b784229..4b798883 100644 --- a/lib/cdist/core/manifest.py +++ b/lib/cdist/core/manifest.py @@ -92,6 +92,7 @@ class Manifest(object): env = os.environ.copy() env.update(self.env) env.update({ + '__manifest': self.local.manifest_path, '__object': cdist_object.absolute_path, '__object_id': cdist_object.object_id, '__object_name': cdist_object.name,