forked from ungleich-public/cdist
introduce new variable names and use __explorers
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
e2ecdd92ab
commit
f5eccb2cb1
7 changed files with 41 additions and 11 deletions
|
@ -39,6 +39,9 @@ set -au
|
|||
: ${__cdist_name_conf_dir:=conf}
|
||||
: ${__cdist_name_type_bin:=type_bin}
|
||||
|
||||
# Exported variable names
|
||||
: ${__cdist_name_var_explorer:=__$__cdist_name_explorer}
|
||||
|
||||
# Name of the manifest file in types
|
||||
: ${__cdist_name_manifest:=manifest}
|
||||
|
||||
|
|
|
@ -33,8 +33,9 @@ cdist-dir push "$__cdist_target_host" \
|
|||
"${__cdist_explorer_dir}" "${__cdist_remote_explorer_dir}"
|
||||
|
||||
# run the initial explorers remotely
|
||||
cdist-explorer-run "$__cdist_target_host" "$__cdist_remote_base_dir" \
|
||||
"$__cdist_remote_explorer_dir" "$__cdist_remote_out_explorer_dir"
|
||||
cdist-run-remote "${__cdist_target_host}" cdist-remote-explorer-run \
|
||||
"$__cdist_remote_base_dir" "$__cdist_remote_explorer_dir" \
|
||||
"$__cdist_name_var_explorer" "$__cdist_remote_out_explorer_dir"
|
||||
|
||||
# retrieve the results
|
||||
cdist-dir pull "$__cdist_target_host" \
|
||||
|
|
|
@ -45,4 +45,5 @@ fi
|
|||
mkdir -p "${__cdist_output_dir}" || __cdist_exit_err "Cannot create output dir ${__cdist_output_dir}"
|
||||
|
||||
cd "$__cdist_work_dir" || __cdist_exit_err "Cannot change to work dir \"$__cdist_work_dir\"."
|
||||
|
||||
__cdist_exec_fail_on_error "${__cdist_manifest}" "$@"
|
||||
|
|
|
@ -31,22 +31,32 @@ __cdist_object_base_dir="$1"; shift
|
|||
################################################################################
|
||||
# New code
|
||||
#
|
||||
object_listing="$__cdist_tmp_dir/objects"
|
||||
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"
|
||||
|
||||
# Get listing of types used
|
||||
while read object; do
|
||||
echo "$(__cdist_type_from_object "$object")" >> "$type_listing_all"
|
||||
done < "$__cdist_tmp_file"
|
||||
sort "$type_listing_all" | uniq > "$type_listing"
|
||||
|
||||
cat "$type_listing"
|
||||
|
||||
# For every type that has explorers, Transfer the explorers
|
||||
|
||||
# For every object of a type that has explorers, execute the explorers
|
||||
# and retrieve the results
|
||||
|
||||
exit 1
|
||||
|
||||
################################################################################
|
||||
# Old code
|
||||
#
|
||||
|
||||
__cdist_object_list "$__cdist_object_base_dir" > "$__cdist_tmp_file"
|
||||
|
||||
# need to create pseudo array, as ssh in cdist-explorer-run will destroy while-read loops
|
||||
while read object; do
|
||||
set -- "$@" "$object"
|
||||
|
|
|
@ -19,23 +19,31 @@
|
|||
#
|
||||
#
|
||||
# This binary is executed on the remote side to execute explorers
|
||||
#
|
||||
# It supports different variables names to be used, so __explorers
|
||||
# and __type_explorers can be submitted :-)
|
||||
#
|
||||
|
||||
. cdist-config
|
||||
if [ $# -lt 3 ]; then
|
||||
__cdist_usage "<work dir> <explorer dir> <out dir> [explorer args]"
|
||||
if [ $# -lt 4 ]; then
|
||||
__cdist_usage "<work dir> <explorer dir> <variable name> <out dir> [explorer args]"
|
||||
fi
|
||||
set -ue
|
||||
|
||||
# cd to this dir
|
||||
__cdist_work_dir="$1"; shift
|
||||
|
||||
# find explorers here
|
||||
# Find explorers here
|
||||
__cdist_explorer_dir="$1"; shift
|
||||
|
||||
# write output here
|
||||
# Variable that defines the home of the explorers
|
||||
__cdist_variable_name="$1"; shift
|
||||
|
||||
# Write output here
|
||||
__cdist_my_out_dir="$1"; shift
|
||||
|
||||
# Setup environment
|
||||
eval export $__cdist_variable_name=\"$__cdist_explorer_dir\"
|
||||
cd "${__cdist_work_dir}"
|
||||
mkdir -p "$__cdist_my_out_dir"
|
||||
|
||||
|
@ -45,6 +53,8 @@ if [ "$num" -lt 1 ]; then
|
|||
__cdist_exit_err "${__cdist_explorer_dir}: Contains no explorers"
|
||||
fi
|
||||
|
||||
# Setup environment for explorer
|
||||
|
||||
# Execute all explorers
|
||||
for explorer in "$__cdist_explorer_dir/"*; do
|
||||
explorer_name="${explorer##*/}"
|
||||
|
|
|
@ -19,10 +19,14 @@
|
|||
#
|
||||
#
|
||||
|
||||
case "$(./conf/explorers/os)" in
|
||||
os="$("$__explorers/os")"
|
||||
|
||||
case "$os" in
|
||||
archlinux) echo pacman ;;
|
||||
debian|ubuntu) echo apt ;;
|
||||
gentoo) echo emerge ;;
|
||||
*)
|
||||
echo "Unknown OS: $os" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
add explorers per type/object
|
||||
- change exec directory for all stages
|
||||
- create cdist-remote-explorer-run that sets
|
||||
|
|
Loading…
Reference in a new issue