continue on bin/cdist-object-explorer-all, make scp silent

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-02-24 16:33:08 +01:00
parent 241548c6ec
commit e599e1684c
5 changed files with 37 additions and 23 deletions

View file

@ -36,7 +36,6 @@ __cdist_src_base=${__cdist_conf_dir_path%config}
ssh "${__cdist_remote_user}@${__cdist_target_host}" \ ssh "${__cdist_remote_user}@${__cdist_target_host}" \
"rm -rf \"${__cdist_my_remote_out_dir}\" && mkdir -p \"${__cdist_my_remote_out_dir}\"" "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 # 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}" "root@${__cdist_target_host}:${__cdist_my_remote_out_dir}"

View file

@ -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_conf_dir:=$__cdist_remote_base_dir/$__cdist_name_conf_dir}
: ${__cdist_remote_explorer_dir:=$__cdist_remote_conf_dir/$__cdist_name_explorer} : ${__cdist_remote_explorer_dir:=$__cdist_remote_conf_dir/$__cdist_name_explorer}
: ${__cdist_remote_bin_dir:=$__cdist_remote_conf_dir/$__cdist_name_bin} : ${__cdist_remote_bin_dir:=$__cdist_remote_conf_dir/$__cdist_name_bin}
: ${__cdist_remote_type_dir:=$__cdist_remote_conf_dir/$__cdist_name_type}
# Remote out # Remote out
: ${__cdist_remote_out_dir:=$__cdist_remote_base_dir/$__cdist_name_out_dir} : ${__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" 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() __cdist_type_gencode()
{ {
local type="$1" local type="$1"

View file

@ -49,13 +49,14 @@ cdist-explorer-run-init "$__cdist_target_host" "$__cdist_out_explorer_dir"
# Create initial object base # Create initial object base
cdist-manifest-run-init "$__cdist_target_host" "$__cdist_out_object_dir" 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" 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 # Run explorer of each type for every object of types with explorer
cdist-object-explorer-all "$__cdist_target_host" "$__cdist_out_object_dir" 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-object-codegen-all "$__cdist_target_host" "$__cdist_out_object_dir" "$__cdist_out_execs"
cdist-exec-transfer "$__cdist_target_host" "$__cdist_out_execs" cdist-exec-transfer "$__cdist_target_host" "$__cdist_out_execs"
cdist-exec-run "$__cdist_target_host" cdist-exec-run "$__cdist_target_host"

View file

@ -43,11 +43,11 @@ __cdist_top_dir="${__cdist_dst_dir%/*}"
if [ "$__cdist_action" = "push" ]; then if [ "$__cdist_action" = "push" ]; then
ssh "${__cdist_remote_user}@${__cdist_target_host}" \ ssh "${__cdist_remote_user}@${__cdist_target_host}" \
"mkdir -p \"${__cdist_dst_dir}\"" "mkdir -p \"${__cdist_dst_dir}\""
scp -r "$__cdist_src_dir" \ scp -qr "$__cdist_src_dir" \
"${__cdist_remote_user}@${__cdist_target_host}:${__cdist_top_dir}" "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_top_dir}"
elif [ "$__cdist_action" = "pull" ]; then elif [ "$__cdist_action" = "pull" ]; then
mkdir -p "${__cdist_dst_dir}" 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}" "${__cdist_top_dir}"
else else
__cdist_exit_err "Unknown action $__cdist_action" __cdist_exit_err "Unknown action $__cdist_action"

View file

@ -23,7 +23,7 @@
. cdist-config . cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <object_base_dir>" [ $# -eq 2 ] || __cdist_usage "<target host> <object_base_dir>"
set -eu set -eux
__cdist_target_host="$1"; shift __cdist_target_host="$1"; shift
__cdist_object_base_dir="$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" type_listing="$__cdist_tmp_dir/types"
# Get listing of objects # 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 # Get listing of types used
while read object; do while read object; do
echo "$(__cdist_type_from_object "$object")" >> "$type_listing_all" echo "$(__cdist_type_from_object "$object")" >> "$type_listing_all"
done < "$__cdist_tmp_file" done < "$object_listing"
sort "$type_listing_all" | uniq > "$type_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 # 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 src_dir="$(__cdist_type_explorer_dir "$cur_type")"
# and retrieve the results 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 # need to create pseudo array, as ssh in cdist-explorer-run will destroy while-read loops
while read object; do while read object; do
set -- "$@" "$object" 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 while [ $# -gt 0 ]; do
object="$1"; shift object="$1"; shift
@ -94,13 +109,6 @@ while [ $# -gt 0 ]; do
if [ -d "$local_src_dir" ]; then if [ -d "$local_src_dir" ]; then
echo "Executing explorers for $object ..." 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" \ cdist-explorer-run "$__cdist_target_host" \
"$local_src_dir" "$local_dst_dir" \ "$local_src_dir" "$local_dst_dir" \
"$remote_src_dir" "$remote_dst_dir" \ "$remote_src_dir" "$remote_dst_dir" \