From e599e1684c8f1b54cdbf95812735602173271779 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 24 Feb 2011 16:33:08 +0100 Subject: [PATCH] continue on bin/cdist-object-explorer-all, make scp silent Signed-off-by: Nico Schottelius --- bin/cdist-bin-transfer | 3 +-- bin/cdist-config | 6 ++++++ bin/cdist-deploy-to | 7 +++--- bin/cdist-dir | 4 ++-- bin/cdist-object-explorer-all | 40 +++++++++++++++++++++-------------- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/bin/cdist-bin-transfer b/bin/cdist-bin-transfer index 53037698..ae204b13 100755 --- a/bin/cdist-bin-transfer +++ b/bin/cdist-bin-transfer @@ -36,7 +36,6 @@ __cdist_src_base=${__cdist_conf_dir_path%config} ssh "${__cdist_remote_user}@${__cdist_target_host}" \ "rm -rf \"${__cdist_my_remote_out_dir}\" && mkdir -p \"${__cdist_my_remote_out_dir}\"" -# FIXME: enable -q as soon as the code is cleaned up # Transfer cdist-* to the remote host -scp -r "${__cdist_src_base}"* \ +scp -qr "${__cdist_src_base}"* \ "root@${__cdist_target_host}:${__cdist_my_remote_out_dir}" diff --git a/bin/cdist-config b/bin/cdist-config index 8a4bb4a6..70013a50 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -89,6 +89,7 @@ __cdist_sane_regexp='[A-Za-z0-9]*[-A-Za-z0-9_]*' : ${__cdist_remote_conf_dir:=$__cdist_remote_base_dir/$__cdist_name_conf_dir} : ${__cdist_remote_explorer_dir:=$__cdist_remote_conf_dir/$__cdist_name_explorer} : ${__cdist_remote_bin_dir:=$__cdist_remote_conf_dir/$__cdist_name_bin} +: ${__cdist_remote_type_dir:=$__cdist_remote_conf_dir/$__cdist_name_type} # Remote out : ${__cdist_remote_out_dir:=$__cdist_remote_base_dir/$__cdist_name_out_dir} @@ -150,6 +151,11 @@ __cdist_type_explorer_dir() echo "${__cdist_type_dir}/$1/$__cdist_name_explorer" } +__cdist_remote_type_explorer_dir() +{ + echo "${__cdist_remote_type_dir}/$1/$__cdist_name_explorer" +} + __cdist_type_gencode() { local type="$1" diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index f9217c82..b0b70220 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -49,13 +49,14 @@ cdist-explorer-run-init "$__cdist_target_host" "$__cdist_out_explorer_dir" # Create initial object base cdist-manifest-run-init "$__cdist_target_host" "$__cdist_out_object_dir" -# Create dependent objects - BUG: does not abort on error in manifest!!!! +# Create dependent objects cdist-manifest-run-all "$__cdist_target_host" "$__cdist_out_object_dir" -exit 2 - # Run explorer of each type for every object of types with explorer cdist-object-explorer-all "$__cdist_target_host" "$__cdist_out_object_dir" + +exit 2 + cdist-object-codegen-all "$__cdist_target_host" "$__cdist_out_object_dir" "$__cdist_out_execs" cdist-exec-transfer "$__cdist_target_host" "$__cdist_out_execs" cdist-exec-run "$__cdist_target_host" diff --git a/bin/cdist-dir b/bin/cdist-dir index 7bdeb644..72f4730b 100755 --- a/bin/cdist-dir +++ b/bin/cdist-dir @@ -43,11 +43,11 @@ __cdist_top_dir="${__cdist_dst_dir%/*}" if [ "$__cdist_action" = "push" ]; then ssh "${__cdist_remote_user}@${__cdist_target_host}" \ "mkdir -p \"${__cdist_dst_dir}\"" - scp -r "$__cdist_src_dir" \ + scp -qr "$__cdist_src_dir" \ "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_top_dir}" elif [ "$__cdist_action" = "pull" ]; then mkdir -p "${__cdist_dst_dir}" - scp -r "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_src_dir}" \ + scp -qr "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_src_dir}" \ "${__cdist_top_dir}" else __cdist_exit_err "Unknown action $__cdist_action" diff --git a/bin/cdist-object-explorer-all b/bin/cdist-object-explorer-all index f2a8f42d..4bcee1ed 100755 --- a/bin/cdist-object-explorer-all +++ b/bin/cdist-object-explorer-all @@ -23,7 +23,7 @@ . cdist-config [ $# -eq 2 ] || __cdist_usage " " -set -eu +set -eux __cdist_target_host="$1"; shift __cdist_object_base_dir="$1"; shift @@ -36,31 +36,46 @@ type_listing_all="$__cdist_tmp_dir/types_all" type_listing="$__cdist_tmp_dir/types" # Get listing of objects -__cdist_object_list "$__cdist_object_base_dir" > "$__cdist_tmp_file" +__cdist_object_list "$__cdist_object_base_dir" > "$object_listing" # Get listing of types used while read object; do echo "$(__cdist_type_from_object "$object")" >> "$type_listing_all" -done < "$__cdist_tmp_file" +done < "$object_listing" sort "$type_listing_all" | uniq > "$type_listing" -cat "$type_listing" +# Create pseudo array to avoid issues with ssh +tc=0 +while read type; do + eval type_$tc=\"\$type\" + tc=$((tc+1)) +done < "$type_listing" # For every type that has explorers, Transfer the explorers +i=0 +while [ "$i" -le "$tc" ]; do + eval cur_type=\"type_$i\" -# For every object of a type that has explorers, execute the explorers -# and retrieve the results + src_dir="$(__cdist_type_explorer_dir "$cur_type")" + dst_dir="$(__cdist_remote_type_explorer_dir "$cur_type")" -exit 1 + if [ -d "$src_dir" ]; then + cdist-dir push "$__cdist_target_host" "$src_dir" "$dst_dir" + fi + i=$((i+1)) +done ################################################################################ -# Old code +# Explorer execution per object # # need to create pseudo array, as ssh in cdist-explorer-run will destroy while-read loops while read object; do set -- "$@" "$object" -done < "$__cdist_tmp_file" +done < "$object_listing" + +# For every object of a type that has explorers, execute the explorers +# and retrieve the results while [ $# -gt 0 ]; do object="$1"; shift @@ -94,13 +109,6 @@ while [ $# -gt 0 ]; do if [ -d "$local_src_dir" ]; then echo "Executing explorers for $object ..." - num="$(ls -1 "$local_src_dir" | wc -l)" - - # Skip if there is not at least one explorer - if [ "$num" -lt 1 ]; then - continue - fi - cdist-explorer-run "$__cdist_target_host" \ "$local_src_dir" "$local_dst_dir" \ "$remote_src_dir" "$remote_dst_dir" \