Create, finish and integrate bin/cdist-exec-transfer

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-02-17 15:11:41 +01:00
parent da4cd7235c
commit 255124b8c9
4 changed files with 16 additions and 63 deletions

View file

@ -52,3 +52,6 @@ cdist-object-codegen-all localhost "$object_tmp" "$exec_tmp"
# Display result # Display result
find "$exec_tmp" find "$exec_tmp"
# Transfer generated code
cdist-exec-transfer localhost "$exec_tmp"

View file

@ -77,6 +77,7 @@ export __cdist_remote_explorer_dir
: ${__cdist_remote_cache_explorer:=$__cdist_remote_cache_dir/$__cdist_name_explorer} : ${__cdist_remote_cache_explorer:=$__cdist_remote_cache_dir/$__cdist_name_explorer}
export __cdist_remote_cache_explorer export __cdist_remote_cache_explorer
: ${__cdist_remote_cache_bin:=$__cdist_remote_base_dir/$__cdist_name_bin} : ${__cdist_remote_cache_bin:=$__cdist_remote_base_dir/$__cdist_name_bin}
: ${__cdist_remote_cache_exec:=$__cdist_remote_base_dir/$__cdist_name_exec}
# Tempfiles need to be recreated for each individual script, unshared! # Tempfiles need to be recreated for each individual script, unshared!
__cdist_tmp_dir=$(mktemp -d "/tmp/cdist.XXXXXXXXXXXX") __cdist_tmp_dir=$(mktemp -d "/tmp/cdist.XXXXXXXXXXXX")

View file

@ -38,10 +38,12 @@ cdist-explorer-run "$__cdist_target_host" "$tmp_exp"
cdist-manifest-init "$__cdist_target_host" "$tmp_obj" cdist-manifest-init "$__cdist_target_host" "$tmp_obj"
cdist-manifest-run-all "$__cdist_target_host" "$tmp_obj" cdist-manifest-run-all "$__cdist_target_host" "$tmp_obj"
cdist-object-codegen-all "$__cdist_target_host" "$tmp_obj" "$tmp_exec" cdist-object-codegen-all "$__cdist_target_host" "$tmp_obj" "$tmp_exec"
cdist-object-codegen-all "$__cdist_target_host" "$tmp_obj" "$tmp_exec"
exit 1 exit 1
cdist-target-exec "$__cdist_target_host" "$tmp_code" cdist-exec-transfer "$__cdist_target_host" "$tmp_exec"
cdist-exec-run "$__cdist_target_host" "$tmp_exec"
# Create new cache - put into seperate script? # Create new cache - put into seperate script?
# cdist-cache migrate? # cdist-cache migrate?

View file

@ -18,74 +18,21 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
# #
# FIXME: This script is ugly, should be either seperated into smaller ones, # Transfer executables
# but definitely be cleaned up - PROOF OF CONCEPT CODE
# #
. cdist-config . cdist-config
if [ $# -ne 2 ]; then [ $# -eq 2 ] || __cdist_usage "<target host> <exec_dir>"
__cdist_usage "<target host> <outdir>"
fi
export __cdist_target_host="$1"; shift
export __cdist_output_dir="$1"; shift
set -e set -e
# create basedir export __cdist_target_host="$1"; shift
ssh root@${__cdist_target_host} "mkdir -p \"${__cdist_remote_base_dir}\" \ export __cdist_exec_dir="$1"; shift
\"${__cdist_remote_cache_dir}\" \"${__cdist_remote_cache_bin}\" \
\"${__cdist_remote_cache_explorer}\""
# Transfer all explorers to the target dir - must be one level above, so
# coyping it multiple times works: a -> remote:/base/ = remote:/base/a vs. # re-create basedir so it's clean
# a -> remote:/base/a = remote:/base/a/a (second copy) ssh "root@${__cdist_target_host}" "rm -rf \"${__cdist_remote_cache_exec}\" && mkdir -p \"${__cdist_remote_cache_exec}\""
# FIXME: enable -q as soon as the code is cleaned up # FIXME: enable -q as soon as the code is cleaned up
scp -r "${__cdist_explorer_dir}" \ scp -r "${__cdist_exec_dir}"/* \
"root@${__cdist_target_host}:${__cdist_remote_base_dir}" "root@${__cdist_target_host}:${__cdist_remote_cache_exec}"
# Transfer cdist binaries - FIXME: should transfer all (needed?) of them!
scp "$(which cdist-explorer-coordinator)" "$(which cdist-config)" \
"root@${__cdist_target_host}:${__cdist_remote_cache_bin}"
# Execute explorer coordinator, which will save results on target
ssh root@${__cdist_target_host} \
"PATH=\"${__cdist_remote_cache_bin}:\$PATH\"
\"${__cdist_remote_cache_bin}/cdist-explorer-coordinator\" \
\"${__cdist_remote_explorer_dir}\" \"${__cdist_remote_cache_explorer}\""
# Ensure local destination directory exists
mkdir -p "$__cdist_output_dir"
# FIXME: enable -q as soon as the code is cleaned up
# Transfer back all results - FIXME: Add 2 level cache, so old version is kept until success
scp -r "root@${__cdist_target_host}:${__cdist_remote_cache_explorer}/*" \
"$__cdist_output_dir"
exit 0
# --------------------------------------------------------------------------------
# old idea with shell scripts (also sexy)
# Keep until above version successfully works
cd "${__cdist_explorer_dir}"
ls > "${__cdist_tmp_file}"
# first load all functions
while read funcfull; do
cat "${funcfull}"
done < "${__cdist_tmp_file}"
# then execute functions
while read funcfull; do
sh="${funcfull##*/}"
func="${sh%.sh}"
var="__$func"
echo "$var=\"\$($func)\""
echo "echo $var=\\\"\$$var\\\""
done < "${CDIST_TMP}"