From 613d66b7a702950fdec68ec5fd5bdc328092aac3 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Thu, 9 Jan 2014 16:09:49 +0100 Subject: [PATCH 1/4] corrected man page and gencode update for correct messages --- cdist/conf/type/__directory/gencode-remote | 16 +++++++++------- cdist/conf/type/__directory/man.text | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/cdist/conf/type/__directory/gencode-remote b/cdist/conf/type/__directory/gencode-remote index 05c301b3..aba618ac 100755 --- a/cdist/conf/type/__directory/gencode-remote +++ b/cdist/conf/type/__directory/gencode-remote @@ -2,6 +2,7 @@ # # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Steven Armstrong (steven-cdist armstrong.cc) +# 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -73,14 +74,15 @@ set_mode() { case "$state_should" in present) if [ "$type" != "directory" ]; then - # our destination is not a directory, remove whatever is there - # and then create our directory and set all attributes set_attributes=1 - cat << DONE -rm -f "$destination" -mkdir $mkdiropt "$destination" -DONE - echo "remove non directory" >> "$__messages_out" + if [ "$type" != "none" ]; then + # our destination is not a directory, remove whatever is there + # and then create our directory and set all attributes + echo rm -f "\"$destination\"" + echo "remove non directory" >> "$__messages_out" + fi + echo "mkdir $mkdiropt \"$destination\"" + echo "create" >> "$__messages_out" fi # Note: Mode - needs to happen last as a chown/chgrp can alter mode by diff --git a/cdist/conf/type/__directory/man.text b/cdist/conf/type/__directory/man.text index cc327af2..a0bf8062 100644 --- a/cdist/conf/type/__directory/man.text +++ b/cdist/conf/type/__directory/man.text @@ -46,6 +46,21 @@ recursive:: If supplied the chgrp and chown call will run recursively. This does *not* influence the behaviour of chmod. +MESSAGES +-------- +chgrp :: + Changed group membership +chown :: + Changed owner +chmod :: + Changed mode +create:: + Empty directory was created +remove:: + Directory exists, but state is absent, directory will be removed by generated code. +remove non directory:: + Someting other than a directory with the same name exists and was removed prior to create. + EXAMPLES -------- From 5cb5c3bfdffa74d51ee34c959b92a48a9b3678c4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 10 Jan 2014 11:26:23 +0100 Subject: [PATCH 2/4] update changelog Signed-off-by: Nico Schottelius --- docs/changelog | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/changelog b/docs/changelog index f75bfa9a..c0cb9d65 100644 --- a/docs/changelog +++ b/docs/changelog @@ -9,8 +9,7 @@ Changelog * Core: Allow hostnames to start with / * Type __line: Remove unecessary backslash escape * Type __directory: Add messaging support (Daniel Heule) - * Type __directory: Do not generate code if mode is 0xxx ((Daniel Heule) - * Type __directory: Add messaging support (Daniel Heule) + * Type __directory: Do not generate code if mode is 0xxx (Daniel Heule) * Type __package: Fix typo in optional parameter ptype (Daniel Heule) * Type __start_on_boot: Fix for SuSE's chkconfig (Daniel Heule) From ef1394f4d1cc6b042057d4f071f6765d09f18c2a Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 13 Jan 2014 22:07:05 +0100 Subject: [PATCH 3/4] filter out special/hidden files when iterating over explorers Signed-off-by: Steven Armstrong --- cdist/core/explorer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index d926552a..14dac9f6 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -79,7 +79,7 @@ class Explorer(object): def list_global_explorer_names(self): """Return a list of global explorer names.""" - return os.listdir(self.local.global_explorer_path) + return glob.glob1(self.local.global_explorer_path, '*') def run_global_explorers(self, out_path): """Run global explorers and save output to files in the given @@ -111,7 +111,7 @@ class Explorer(object): """Return a list of explorer names for the given type.""" source = os.path.join(self.local.type_path, cdist_type.explorer_path) try: - return os.listdir(source) + return glob.glob1(source, '*') except EnvironmentError: return [] From 94aa0df74798e1b5e5d110a66863201a9a8ada81 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 13 Jan 2014 22:09:07 +0100 Subject: [PATCH 4/4] add missing import Signed-off-by: Steven Armstrong --- cdist/core/explorer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index 14dac9f6..41851bd6 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -22,6 +22,7 @@ import logging import os +import glob import cdist