From 4687d32771316506396fb0214b6cdb073a4c1ad4 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 10:00:22 +0200 Subject: [PATCH 01/38] add half backed code for new object-run ideas Signed-off-by: Steven Armstrong --- bin/cdist-deploy-to | 2 +- bin/cdist-object-run-all | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 96b65e8b..c9aa1e2f 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -49,7 +49,7 @@ cdist-dir push "$__cdist_target_host" "${__cdist_abs_mydir}" "${__cdist_remote_b cdist-explorer-run-global "$__cdist_target_host" cdist-manifest-run-init "$__cdist_target_host" -cdist-manifest-run-all "$__cdist_target_host" +#cdist-manifest-run-all "$__cdist_target_host" cdist-object-run-all "$__cdist_target_host" echo "cdist $__cdist_version: Successfully finished run on $__cdist_target_host" diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index 14a6d9b3..abf01b23 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -48,6 +48,8 @@ done < "$__cdist_objects" while [ $# -gt 0 ]; do __cdist_object="$1"; shift + echo + echo "Running object $__cdist_object" __cdist_type="$(__cdist_type_from_object "$__cdist_object")" @@ -67,6 +69,9 @@ while [ $# -gt 0 ]; do fi + # Run the manifest for the current object + cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" + # Run the gencode scripts for the current object cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" From b5ab490a23a1413eb949ba9b3512561455303e07 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 10:02:13 +0200 Subject: [PATCH 02/38] add more half backed code for new object-run ideas Signed-off-by: Steven Armstrong --- bin/cdist-object-manifest-run | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 bin/cdist-object-manifest-run diff --git a/bin/cdist-object-manifest-run b/bin/cdist-object-manifest-run new file mode 100755 index 00000000..e20848cd --- /dev/null +++ b/bin/cdist-object-manifest-run @@ -0,0 +1,64 @@ +#!/bin/sh +# +# 2010 Nico Schottelius (nico-cdist at schottelius.org) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Run the manifest for the given object. +# + +. cdist-config +[ $# -eq 2 ] || __cdist_usage " " +set -eu + +__cdist_target_host="$1"; shift +__cdist_object="$1"; shift + +# Full path to current object +__cdist_cur_object_dir="$(__cdist_object_dir "$__cdist_object")" + +# Only the id +__cdist_object_id="$(__cdist_object_id_from_object "$__cdist_object")" + +if [ ! -f "${__cdist_cur_object_dir}/$__cdist_name_object_finished" ]; then + echo "Checking manifest for $__cdist_object ..." + + __cdist_type="$(__cdist_type_from_object "$__cdist_object")" + __cdist_manifest="$(__cdist_type_manifest "$__cdist_type")" + + if [ -f "$__cdist_manifest" ]; then + if [ -x "$__cdist_manifest" ]; then + # Make __cdist_manifest available for cdist-type-emulator + export __cdist_manifest + + echo "Executing manifest ${__cdist_manifest} ..." + # Make variables available to non-core - FIXME: beatify + export $__cdist_name_var_object="$__cdist_cur_object_dir" + export $__cdist_name_var_object_id="$__cdist_object_id" + export $__cdist_name_var_type="$(__cdist_type_dir "$__cdist_type")" + + cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest" + else + __cdist_exit_err "${__cdist_manifest} needs to be executable." + fi + fi +fi + +# done with this object +touch "$__cdist_cur_object_dir/$__cdist_name_object_finished" + From 4ee5d74c9ff5cb36132ef1751602087892b1d1fe Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 14:55:58 +0200 Subject: [PATCH 03/38] implement dependency handling at the object level Signed-off-by: Steven Armstrong --- bin/cdist-code-run | 15 ---------- bin/cdist-config | 16 ++++++++-- bin/cdist-object-manifest-run | 37 +++++++++++------------ bin/cdist-object-run | 54 ++++++++++++++++++++++------------ bin/cdist-object-run-all | 55 +++++++++++++++++------------------ 5 files changed, 93 insertions(+), 84 deletions(-) diff --git a/bin/cdist-code-run b/bin/cdist-code-run index a6a9137f..e969d942 100755 --- a/bin/cdist-code-run +++ b/bin/cdist-code-run @@ -32,31 +32,16 @@ if [ ! -d "$(__cdist_object_dir "$object")" ]; then __cdist_exit_err "Object $object is missing." fi -finished="$(__cdist_object_code_finished "$object")" -require="$(__cdist_object_require "$object")" - code="$(__cdist_object_code "$object")-${__cdist_gencode_type}" -# Do nothing if our work has been done -if [ -f "$finished" ]; then - exit 0 -fi - echo "Checking code-${__cdist_gencode_type} for $object ..." -if [ -f "$require" ]; then - while read requirement; do - echo "Requiring dependency $requirement for $object ..." - cdist-code-run "$requirement" "$__cdist_gencode_type" - done < "$require" -fi if [ -e "$code" ]; then if [ -f "$code" ]; then if [ -x "$code" ]; then echo "Executing code-${__cdist_gencode_type} for $object ..." "$code" - touch "$finished" else __cdist_exit_err "$code exists, but is not executable." fi diff --git a/bin/cdist-config b/bin/cdist-config index 26139819..1b172ddb 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -42,7 +42,6 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_bin:=bin} : ${__cdist_name_code:=code} -: ${__cdist_name_code_finished:=codedone} : ${__cdist_name_conf_dir:=conf} : ${__cdist_name_dot_cdist:=.cdist} : ${__cdist_name_explorer:=explorer} @@ -68,6 +67,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_type:=type} : ${__cdist_name_type_bin:=type_bin} : ${__cdist_name_type_explorer:=type_explorer} +: ${__cdist_name_objects_created:=objects_created} # Used for IDs: Allow everything not starting with - and . : ${__cdist_sane_regexp:=[^-\.].*} @@ -107,6 +107,7 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX") : ${__cdist_manifest_dir:=$__cdist_conf_dir/$__cdist_name_manifest} : ${__cdist_manifest_init:=$__cdist_manifest_dir/$__cdist_name_init} : ${__cdist_type_dir:=$__cdist_conf_dir/$__cdist_name_type} +: ${__cdist_new_objects_created:=$__cdist_local_base_dir/$__cdist_name_objects_created} ################################################################################ # Local output @@ -176,6 +177,14 @@ __cdist_init_deploy() ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir" } +__cdist_new_objects_created() { + touch "$__cdist_tmp_dir/object_created" +} + +__cdist_has_new_objects() { + touch "$__cdist_tmp_dir/object_created" +} + ################################################################################ # Object # @@ -185,9 +194,9 @@ __cdist_object_code() echo "$(__cdist_object_dir "$1")/${__cdist_name_code}" } -__cdist_object_code_finished() +__cdist_object_finished() { - echo "$(__cdist_object_dir "$1")/${__cdist_name_code_finished}" + echo "$(__cdist_object_dir "$1")/${__cdist_name_object_finished}" } __cdist_object_dir() @@ -250,6 +259,7 @@ __cdist_object_type_explorer_dir() echo "$(__cdist_object_dir "$1")/${__cdist_name_explorer}" } + ################################################################################ # Remote # diff --git a/bin/cdist-object-manifest-run b/bin/cdist-object-manifest-run index e20848cd..4f8111f6 100755 --- a/bin/cdist-object-manifest-run +++ b/bin/cdist-object-manifest-run @@ -35,30 +35,27 @@ __cdist_cur_object_dir="$(__cdist_object_dir "$__cdist_object")" # Only the id __cdist_object_id="$(__cdist_object_id_from_object "$__cdist_object")" -if [ ! -f "${__cdist_cur_object_dir}/$__cdist_name_object_finished" ]; then - echo "Checking manifest for $__cdist_object ..." +echo "Checking manifest for $__cdist_object ..." - __cdist_type="$(__cdist_type_from_object "$__cdist_object")" - __cdist_manifest="$(__cdist_type_manifest "$__cdist_type")" +__cdist_type="$(__cdist_type_from_object "$__cdist_object")" +__cdist_manifest="$(__cdist_type_manifest "$__cdist_type")" - if [ -f "$__cdist_manifest" ]; then - if [ -x "$__cdist_manifest" ]; then - # Make __cdist_manifest available for cdist-type-emulator - export __cdist_manifest +if [ -f "$__cdist_manifest" ]; then + if [ -x "$__cdist_manifest" ]; then + # Make __cdist_manifest available for cdist-type-emulator + export __cdist_manifest - echo "Executing manifest ${__cdist_manifest} ..." - # Make variables available to non-core - FIXME: beatify - export $__cdist_name_var_object="$__cdist_cur_object_dir" - export $__cdist_name_var_object_id="$__cdist_object_id" - export $__cdist_name_var_type="$(__cdist_type_dir "$__cdist_type")" + echo "Executing manifest ${__cdist_manifest} ..." + # Make variables available to non-core - FIXME: beatify + export $__cdist_name_var_object="$__cdist_cur_object_dir" + export $__cdist_name_var_object_id="$__cdist_object_id" + export $__cdist_name_var_type="$(__cdist_type_dir "$__cdist_type")" - cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest" - else - __cdist_exit_err "${__cdist_manifest} needs to be executable." - fi + cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest" + # Tell cdist that there may be new objects + touch "$__cdist_new_objects_created" + else + __cdist_exit_err "${__cdist_manifest} needs to be executable." fi fi -# done with this object -touch "$__cdist_cur_object_dir/$__cdist_name_object_finished" - diff --git a/bin/cdist-object-run b/bin/cdist-object-run index e123c7a4..6ad95656 100755 --- a/bin/cdist-object-run +++ b/bin/cdist-object-run @@ -21,6 +21,7 @@ # # For the given object: # - run type explorers +# - run type manifest # - generate code # - copy object to target # - execute code on target @@ -35,24 +36,41 @@ __cdist_object="$1"; shift __cdist_type="$(__cdist_type_from_object "$__cdist_object")" +__cdist_types_pushed="$__cdist_tmp_dir/types_pushed" +touch "$__cdist_types_pushed" -# Check if type of object has >= 1 explorer -__cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" +__cdist_object_finished="$(__cdist_object_finished "$__cdist_object")" +if [ ! -f "$__cdist_object_finished" ]; then + + echo + echo "Running object $__cdist_object" + + # Check if type of object has >= 1 explorer + __cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" + + # Run the type explorers for the current object if any + if [ "$__cdist_has_explorer" ]; then + if ! grep -q "$__cdist_type" "$__cdist_types_pushed"; then + cdist-type-explorer-push "$__cdist_target_host" "$__cdist_type" + echo "$__cdist_type" >> "$__cdist_types_pushed" + fi + + cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" + fi + + # Run the manifest for the current object + cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" + + # Run the gencode scripts for the current object + cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" + + # Transfer the current object to the target + cdist-object-push "$__cdist_target_host" "$__cdist_object" + + # Run the code for the current object + cdist-object-code-run "$__cdist_target_host" "$__cdist_object" + + # Mark this object as done + touch "$__cdist_object_finished" -# Run the type explorers for the current object if any -if [ "$__cdist_has_explorer" ]; then - cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" fi - -# Run the manifest for the current object -cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" - -# Run the gencode scripts for the current object -cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" - -# Transfer the current object to the target -cdist-object-push "$__cdist_target_host" "$__cdist_object" - -# Run the code for the current object -cdist-object-code-run "$__cdist_target_host" "$__cdist_object" - diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index 45a1ae2a..582ff163 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -29,39 +29,38 @@ set -eu __cdist_target_host="$1"; shift __cdist_objects="$__cdist_tmp_dir/objects" -__cdist_types_pushed="$__cdist_tmp_dir/types_pushed" -touch "$__cdist_types_pushed" + +# Loop until we do not create new objects anymore +# which is equal to all objects have been run +touch "$__cdist_new_objects_created" +while [ -f "$__cdist_new_objects_created" ]; do + # Assume we're done after this run + rm "$__cdist_new_objects_created" + + # Get listing of objects + __cdist_object_list "$__cdist_out_object_dir" > "$__cdist_objects" -# Get listing of objects -__cdist_object_list "$__cdist_out_object_dir" > "$__cdist_objects" + # NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP + while read __cdist_object; do + set -- "$@" "$__cdist_object" + done < "$__cdist_objects" + while [ $# -gt 0 ]; do + __cdist_object="$1"; shift -# NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP -while read __cdist_object; do - set -- "$@" "$__cdist_object" -done < "$__cdist_objects" + __cdist_object_require="$(__cdist_object_require "$__cdist_object")" + if [ -f "$__cdist_object_require" ]; then + echo + while read __cdist_requirement; do + echo "Resolving dependency $__cdist_object -> $__cdist_requirement ..." + cdist-object-run "$__cdist_target_host" "$__cdist_requirement" + done < "$__cdist_object_require" + fi -while [ $# -gt 0 ]; do - __cdist_object="$1"; shift - echo - echo "Running object $__cdist_object" - - __cdist_type="$(__cdist_type_from_object "$__cdist_object")" - - # Check if type of object has >= 1 explorer - __cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" - - # Transfer the type explorers if any - if [ "$__cdist_has_explorer" ]; then - if ! grep -q "$__cdist_type" "$__cdist_types_pushed"; then - cdist-type-explorer-push "$__cdist_target_host" "$__cdist_type" - echo "$__cdist_type" >> "$__cdist_types_pushed" - fi - fi - - # Process the given object - cdist-object-run "$__cdist_target_host" "$__cdist_object" + # Process the object + cdist-object-run "$__cdist_target_host" "$__cdist_object" + done done From 8b0b7052c67673684018d0010eea94611a6febe7 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 15:28:55 +0200 Subject: [PATCH 04/38] remove commented obsolete code Signed-off-by: Steven Armstrong --- bin/cdist-deploy-to | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index c9aa1e2f..b0a0117d 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -49,7 +49,7 @@ cdist-dir push "$__cdist_target_host" "${__cdist_abs_mydir}" "${__cdist_remote_b cdist-explorer-run-global "$__cdist_target_host" cdist-manifest-run-init "$__cdist_target_host" -#cdist-manifest-run-all "$__cdist_target_host" cdist-object-run-all "$__cdist_target_host" echo "cdist $__cdist_version: Successfully finished run on $__cdist_target_host" + From ba0bc4d02b320422a8605d56ea7932edb6de1c81 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:09:02 +0200 Subject: [PATCH 05/38] add somo todo proposals for steven / questions Signed-off-by: Nico Schottelius --- doc/dev/todo/steven-from-nico | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/dev/todo/steven-from-nico diff --git a/doc/dev/todo/steven-from-nico b/doc/dev/todo/steven-from-nico new file mode 100644 index 00000000..1aa81aaa --- /dev/null +++ b/doc/dev/todo/steven-from-nico @@ -0,0 +1,12 @@ +- check: echo without parameters == valid in posix? bin/cdist-object-run:45 and others +- align messages (already in todo for steven, but makes life much easier, thus repeated) +- advantage of touch/rm loop vs. y == variable? bin/cdist-object-run-all +- bin/cdist-object-run-all: "->" graphic: can be useful, but if -> consistent! + -> all graphics could look cool: + + Object foo + | + |--> Requires ... + |--> ... + + but maybe bad do parse from outside From 29b61f38eaede3edab65fc5ef3308caecce77da3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:09:35 +0200 Subject: [PATCH 06/38] remove unecessary empty lines (interrupts read flow) Signed-off-by: Nico Schottelius --- bin/cdist-object-run-all | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index 582ff163..a3745689 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -40,7 +40,6 @@ while [ -f "$__cdist_new_objects_created" ]; do # Get listing of objects __cdist_object_list "$__cdist_out_object_dir" > "$__cdist_objects" - # NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP while read __cdist_object; do set -- "$@" "$__cdist_object" @@ -60,7 +59,5 @@ while [ -f "$__cdist_new_objects_created" ]; do # Process the object cdist-object-run "$__cdist_target_host" "$__cdist_object" - done done - From 98c7b98aac81776d2a109dee08f3b8e0c25c15b0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:16:55 +0200 Subject: [PATCH 07/38] more todo for steven :-p Signed-off-by: Nico Schottelius --- doc/dev/todo/steven-from-nico | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/dev/todo/steven-from-nico b/doc/dev/todo/steven-from-nico index 1aa81aaa..c879144d 100644 --- a/doc/dev/todo/steven-from-nico +++ b/doc/dev/todo/steven-from-nico @@ -1,6 +1,7 @@ - check: echo without parameters == valid in posix? bin/cdist-object-run:45 and others - align messages (already in todo for steven, but makes life much easier, thus repeated) - advantage of touch/rm loop vs. y == variable? bin/cdist-object-run-all + also in bin/cdist-object-run - bin/cdist-object-run-all: "->" graphic: can be useful, but if -> consistent! -> all graphics could look cool: @@ -10,3 +11,7 @@ |--> ... but maybe bad do parse from outside + +- bin/cdist-object-run: type_explorer stuff: probably put into own binary + - sounds like cdist-object-explorer-run is already the right executable to + place such stuff into From 4ab770400a8f7349ca04f7c6d48f7581f3e678da Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:17:17 +0200 Subject: [PATCH 08/38] - lines + variable alignement Signed-off-by: Nico Schottelius --- bin/cdist-object-run | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/cdist-object-run b/bin/cdist-object-run index 6ad95656..90e61fd4 100755 --- a/bin/cdist-object-run +++ b/bin/cdist-object-run @@ -34,14 +34,12 @@ set -eu __cdist_target_host="$1"; shift __cdist_object="$1"; shift - __cdist_type="$(__cdist_type_from_object "$__cdist_object")" __cdist_types_pushed="$__cdist_tmp_dir/types_pushed" touch "$__cdist_types_pushed" __cdist_object_finished="$(__cdist_object_finished "$__cdist_object")" if [ ! -f "$__cdist_object_finished" ]; then - echo echo "Running object $__cdist_object" @@ -59,18 +57,17 @@ if [ ! -f "$__cdist_object_finished" ]; then fi # Run the manifest for the current object - cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" + cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" # Run the gencode scripts for the current object - cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" + cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" # Transfer the current object to the target - cdist-object-push "$__cdist_target_host" "$__cdist_object" + cdist-object-push "$__cdist_target_host" "$__cdist_object" # Run the code for the current object - cdist-object-code-run "$__cdist_target_host" "$__cdist_object" + cdist-object-code-run "$__cdist_target_host" "$__cdist_object" # Mark this object as done touch "$__cdist_object_finished" - fi From 4e68c3027b1b96a6f9348667241532c42d591d47 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:19:51 +0200 Subject: [PATCH 09/38] remove self explanatory comments Signed-off-by: Nico Schottelius --- bin/cdist-object-run | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bin/cdist-object-run b/bin/cdist-object-run index 90e61fd4..d633e537 100755 --- a/bin/cdist-object-run +++ b/bin/cdist-object-run @@ -56,16 +56,9 @@ if [ ! -f "$__cdist_object_finished" ]; then cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" fi - # Run the manifest for the current object cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" - - # Run the gencode scripts for the current object cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" - - # Transfer the current object to the target cdist-object-push "$__cdist_target_host" "$__cdist_object" - - # Run the code for the current object cdist-object-code-run "$__cdist_target_host" "$__cdist_object" # Mark this object as done From 10c96dee875240c8290da46b72e61271d5e25d33 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:26:17 +0200 Subject: [PATCH 10/38] -useless emptly line in bin/cdist-deploy-to Signed-off-by: Nico Schottelius --- bin/cdist-deploy-to | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index af33c3fe..e44ceff4 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -53,4 +53,3 @@ cdist-object-run-all "$__cdist_target_host" cdist-cache "$__cdist_target_host" echo "cdist $__cdist_version: Successfully finished run on $__cdist_target_host" - From 78777ba9f3e8870975089d63fbd787361adc915a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:30:09 +0200 Subject: [PATCH 11/38] use same argv processing as elsewhere Signed-off-by: Nico Schottelius --- bin/cdist-remote-explorer-run | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/cdist-remote-explorer-run b/bin/cdist-remote-explorer-run index 028f8d7d..cef91e0d 100755 --- a/bin/cdist-remote-explorer-run +++ b/bin/cdist-remote-explorer-run @@ -25,9 +25,7 @@ # . cdist-config -if [ $# -ne 3 ]; then - __cdist_usage " " -fi +[ $# -eq 3 ] || __cdist_usage " " set -ue # Variable that defines the home of the explorers From 332548ba4f231c7d47f39dd8c64ef3954963527a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:31:26 +0200 Subject: [PATCH 12/38] more todo, less whiteline in bin/cdist-object-explorer-run Signed-off-by: Nico Schottelius --- bin/cdist-object-explorer-run | 1 - doc/dev/todo/steven-from-nico | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bin/cdist-object-explorer-run b/bin/cdist-object-explorer-run index e349a490..637d4448 100755 --- a/bin/cdist-object-explorer-run +++ b/bin/cdist-object-explorer-run @@ -24,7 +24,6 @@ . cdist-config [ $# -eq 2 ] || __cdist_usage " " - set -eu __cdist_target_host="$1"; shift diff --git a/doc/dev/todo/steven-from-nico b/doc/dev/todo/steven-from-nico index c879144d..bbfe13dc 100644 --- a/doc/dev/todo/steven-from-nico +++ b/doc/dev/todo/steven-from-nico @@ -15,3 +15,31 @@ - bin/cdist-object-run: type_explorer stuff: probably put into own binary - sounds like cdist-object-explorer-run is already the right executable to place such stuff into + +- remove enormous amount of empty lines :-) + - at end of file + - between [ $# -eq 2 ] || and set + - after if + - before fi + +- cdist-type-explorer-push: wherefore if [ -d "$src_dir" ];? + -> does this not even hide bugs? + -> not sure whether covering cdist-dir in its own script makes + sense, as cdist-dir push is only a one liner + -> if cdist-dir does too less, enhance it + +- code aus cdist-object-run-all für requirements: + in cdist-object-requirements oder so auslagern? + cdist-object-run-all wäre dann eine schöne zwei-zeiler-schleife + +- try to prefix all internal variables with __cdist! + - only avoid if waayyyyyyyyyyy tooooooooo long + - f.i.: cdist-object-explorer-run + +- cdist-object-explorer-run and bin/cdist-object-run seem to contain + very very similar code regarding transfer and co. + + +- general: cdist-object-run-all looks like a good idea! + + From 8abd5ce33ed323719bd29b1e8f97b3b1b14e85e4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:37:26 +0200 Subject: [PATCH 13/38] - another empty line Signed-off-by: Nico Schottelius --- bin/cdist-object-gencode-run | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/cdist-object-gencode-run b/bin/cdist-object-gencode-run index 76ce6953..bfc65730 100755 --- a/bin/cdist-object-gencode-run +++ b/bin/cdist-object-gencode-run @@ -41,4 +41,3 @@ cdist-object-gencode "$__cdist_target_host" "$__cdist_object" \ "${__cdist_name_gencode_remote}" > "${code_remote}" chmod u+x "${code_local}" "${code_remote}" - From 8315ac2e256ff7de0f77bf9806ae94b391bd01bc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:38:08 +0200 Subject: [PATCH 14/38] - blank lines Signed-off-by: Nico Schottelius --- bin/cdist-object-push | 2 -- doc/dev/todo/steven-from-nico | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cdist-object-push b/bin/cdist-object-push index 9c44d14e..170aaef3 100755 --- a/bin/cdist-object-push +++ b/bin/cdist-object-push @@ -29,9 +29,7 @@ set -eu __cdist_target_host="$1"; shift __cdist_object="$1"; shift - echo "Transferring object $__cdist_object to target host ..." cdist-dir push "$__cdist_target_host" \ "$(__cdist_object_dir "$__cdist_object")" \ "$(__cdist_remote_object_dir "$__cdist_object")" - diff --git a/doc/dev/todo/steven-from-nico b/doc/dev/todo/steven-from-nico index bbfe13dc..52d3047f 100644 --- a/doc/dev/todo/steven-from-nico +++ b/doc/dev/todo/steven-from-nico @@ -39,6 +39,8 @@ - cdist-object-explorer-run and bin/cdist-object-run seem to contain very very similar code regarding transfer and co. +- cdist-object-manifest-run: + # Tell cdist that there may be new objects -> WHO? :-) - general: cdist-object-run-all looks like a good idea! From a46c0a43726e66ed1903f0b7018bb9c5282d5089 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:38:43 +0200 Subject: [PATCH 15/38] replace CONSTANT target host by variable target host Signed-off-by: Nico Schottelius --- bin/cdist-object-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cdist-object-push b/bin/cdist-object-push index 170aaef3..f7d46be4 100755 --- a/bin/cdist-object-push +++ b/bin/cdist-object-push @@ -29,7 +29,7 @@ set -eu __cdist_target_host="$1"; shift __cdist_object="$1"; shift -echo "Transferring object $__cdist_object to target host ..." +echo "Transferring object $__cdist_object to $__cdist_target_host ..." cdist-dir push "$__cdist_target_host" \ "$(__cdist_object_dir "$__cdist_object")" \ "$(__cdist_remote_object_dir "$__cdist_object")" From c80fa65af1236c68e391ad6753d37a2631ad420d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 18:42:04 +0200 Subject: [PATCH 16/38] -blank line Signed-off-by: Nico Schottelius --- bin/cdist-object-code-run | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/cdist-object-code-run b/bin/cdist-object-code-run index b75f6f46..d0722788 100755 --- a/bin/cdist-object-code-run +++ b/bin/cdist-object-code-run @@ -39,4 +39,3 @@ cdist-run-remote "$__cdist_target_host" \ "export __cdist_out_object_dir=\"$__cdist_remote_out_object_dir\";" \ "cdist-code-run" "$__cdist_object" "${__cdist_name_gencode_remote}" \ || __cdist_exit_err "Remote code failed for $__cdist_object" - From bb66523ea517822874125b4959ea9be4b52b131e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 22:43:50 +0200 Subject: [PATCH 17/38] todo: fix __ in asciidoc Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 138f7714..b362d491 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -18,4 +18,7 @@ Types to be written/extended: -> aka sed. - __cron - +DOCUMENTATION +-------------- +- asciidoc interprets __, which we use for variables + names -> seek through docs and replace with \_\_! From 3618b225a39835d56bac0c1eda11b07688e1bb49 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 29 Mar 2011 10:34:04 +0200 Subject: [PATCH 18/38] make all internal variables __cdist_ prefixed Signed-off-by: Nico Schottelius --- bin/cdist-object-explorer-run | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/cdist-object-explorer-run b/bin/cdist-object-explorer-run index 637d4448..e9a20921 100755 --- a/bin/cdist-object-explorer-run +++ b/bin/cdist-object-explorer-run @@ -33,10 +33,10 @@ __object_id="$(__cdist_object_id_from_object "$__object")" __cdist_type="$(__cdist_type_from_object "$__object")" # Check if type of object has >= 1 explorer -has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" +__cdist_has_explorer="$(__cdist_type___cdist_has_explorer "$__cdist_type")" # If so, run explorers on remote side -if [ "$has_explorer" ]; then +if [ "$__cdist_has_explorer" ]; then echo "Running explorers for $__object ..." # Copy object parameters cdist-dir push "$__cdist_target_host" \ @@ -57,4 +57,3 @@ if [ "$has_explorer" ]; then "$(__cdist_remote_object_type_explorer_dir "$__object")" \ "$(__cdist_object_type_explorer_dir "$__object")" fi - From 5306737d22aa2da3b685cd02a0134202e401a7ca Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 29 Mar 2011 10:38:35 +0200 Subject: [PATCH 19/38] discuss todos / cleanup / make more fun for us Signed-off-by: Nico Schottelius --- bin/cdist-config | 2 -- bin/cdist-object-manifest-run | 3 +- bin/cdist-object-run | 1 + bin/cdist-object-run-all | 7 ++++- doc/dev/todo/niconext | 2 ++ doc/dev/todo/steven-from-nico | 59 +++++++++++++++++++++-------------- 6 files changed, 45 insertions(+), 29 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index c4b8d44c..9a00395d 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -68,7 +68,6 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_type:=type} : ${__cdist_name_type_bin:=type_bin} : ${__cdist_name_type_explorer:=type_explorer} -: ${__cdist_name_objects_created:=objects_created} # Used for IDs: Allow everything not starting with - and . : ${__cdist_sane_regexp:=[^-\.].*} @@ -109,7 +108,6 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX") : ${__cdist_manifest_dir:=$__cdist_conf_dir/$__cdist_name_manifest} : ${__cdist_manifest_init:=$__cdist_manifest_dir/$__cdist_name_init} : ${__cdist_type_dir:=$__cdist_conf_dir/$__cdist_name_type} -: ${__cdist_new_objects_created:=$__cdist_local_base_dir/$__cdist_name_objects_created} ################################################################################ # Local output diff --git a/bin/cdist-object-manifest-run b/bin/cdist-object-manifest-run index 4f8111f6..a65ed138 100755 --- a/bin/cdist-object-manifest-run +++ b/bin/cdist-object-manifest-run @@ -52,10 +52,9 @@ if [ -f "$__cdist_manifest" ]; then export $__cdist_name_var_type="$(__cdist_type_dir "$__cdist_type")" cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest" - # Tell cdist that there may be new objects + FIXME: Tell cdist that there may be new objects - WHO? Mama? touch "$__cdist_new_objects_created" else __cdist_exit_err "${__cdist_manifest} needs to be executable." fi fi - diff --git a/bin/cdist-object-run b/bin/cdist-object-run index d633e537..015d95fa 100755 --- a/bin/cdist-object-run +++ b/bin/cdist-object-run @@ -46,6 +46,7 @@ if [ ! -f "$__cdist_object_finished" ]; then # Check if type of object has >= 1 explorer __cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" + FIXME: put into cdist-object-explorer-run # Run the type explorers for the current object if any if [ "$__cdist_has_explorer" ]; then if ! grep -q "$__cdist_type" "$__cdist_types_pushed"; then diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index a3745689..7c87660b 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -30,6 +30,9 @@ __cdist_target_host="$1"; shift __cdist_objects="$__cdist_tmp_dir/objects" +FIXME: reuse in subscripts, save in objects_base_dir +export __cdist_objects_created="$__cdist_tmp_dir/objects_created" + # Loop until we do not create new objects anymore # which is equal to all objects have been run touch "$__cdist_new_objects_created" @@ -48,11 +51,13 @@ while [ -f "$__cdist_new_objects_created" ]; do while [ $# -gt 0 ]; do __cdist_object="$1"; shift + FIXME: migrate into cdist-object-run + FIXME: take care of SSH foo after migration in while loop __cdist_object_require="$(__cdist_object_require "$__cdist_object")" if [ -f "$__cdist_object_require" ]; then echo while read __cdist_requirement; do - echo "Resolving dependency $__cdist_object -> $__cdist_requirement ..." + echo "Resolving dependency $__cdist_requirement for $__cdist_object ..." cdist-object-run "$__cdist_target_host" "$__cdist_requirement" done < "$__cdist_object_require" fi diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index e9a6ddfc..be66a33d 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,3 +1,5 @@ +/ prefix all internal variables with __cdist! -> Nico + Cache: - add example how to use - export variable $__cache diff --git a/doc/dev/todo/steven-from-nico b/doc/dev/todo/steven-from-nico index 52d3047f..c04e980f 100644 --- a/doc/dev/todo/steven-from-nico +++ b/doc/dev/todo/steven-from-nico @@ -1,8 +1,5 @@ -- check: echo without parameters == valid in posix? bin/cdist-object-run:45 and others -- align messages (already in todo for steven, but makes life much easier, thus repeated) -- advantage of touch/rm loop vs. y == variable? bin/cdist-object-run-all - also in bin/cdist-object-run -- bin/cdist-object-run-all: "->" graphic: can be useful, but if -> consistent! +x check: echo without parameters == valid in posix? bin/cdist-object-run:45 and others +x bin/cdist-object-run-all: "->" graphic: can be useful, but if -> consistent! -> all graphics could look cool: Object foo @@ -12,36 +9,50 @@ but maybe bad do parse from outside -- bin/cdist-object-run: type_explorer stuff: probably put into own binary - - sounds like cdist-object-explorer-run is already the right executable to - place such stuff into - -- remove enormous amount of empty lines :-) +x advantage of touch/rm loop vs. y == variable? bin/cdist-object-run-all + also in bin/cdist-object-run + -> cool :-) +x remove enormous amount of empty lines :-) - at end of file - between [ $# -eq 2 ] || and set - after if - before fi +x code aus cdist-object-run-all für requirements: + in cdist-object-requirements oder so auslagern? + cdist-object-run-all wäre dann eine schöne zwei-zeiler-schleife + +x cdist-object-explorer-run and bin/cdist-object-run seem to contain + very very similar code regarding transfer and co. + -> indirect solved by moving code into cdist-object-explorer-run + +x cdist-object-manifest-run: + # Tell cdist that there may be new objects -> WHO? :-) + +x general: cdist-object-run-all looks like a good idea! + +- export $__cdist_name_var_self=$__cdist_object_self -> non core + +- bin/cdist-object-run: type_explorer stuff: probably put into own binary + - sounds like cdist-object-explorer-run is already the right executable to + place such stuff into + - cdist-type-explorer-push: wherefore if [ -d "$src_dir" ];? -> does this not even hide bugs? -> not sure whether covering cdist-dir in its own script makes sense, as cdist-dir push is only a one liner -> if cdist-dir does too less, enhance it + => merge into cdist-object-explorer-run -- code aus cdist-object-run-all für requirements: - in cdist-object-requirements oder so auslagern? - cdist-object-run-all wäre dann eine schöne zwei-zeiler-schleife +- marker for type transferred / pushed goes into out/type/ + -> new variables for out/type + -> new variables for out/type/.MARKERFOONAMEMEGOOD -- try to prefix all internal variables with __cdist! - - only avoid if waayyyyyyyyyyy tooooooooo long - - f.i.: cdist-object-explorer-run - -- cdist-object-explorer-run and bin/cdist-object-run seem to contain - very very similar code regarding transfer and co. - -- cdist-object-manifest-run: - # Tell cdist that there may be new objects -> WHO? :-) - -- general: cdist-object-run-all looks like a good idea! +- new function: __cdist_type_explorer_created $name + if ! -d foo -> mkdir foo, echo $name >> foo/$NEW_FANCY_VAR +- align messages (already in todo for steven, but makes life much easier, thus repeated) + -> prefix all object stuff with $__self + -> __cdist_echo object string + -> $__cdist_object_self :-) From f187ed257aed536c8b0d12a8d0d42bb83d327dec Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 14:36:35 +0200 Subject: [PATCH 20/38] implement the big code shuffle Signed-off-by: Steven Armstrong --- bin/cdist-config | 20 ++++++++++++++++++ bin/cdist-object-explorer-run | 14 +++++++++--- bin/cdist-object-manifest-run | 4 ++-- bin/cdist-object-run | 29 +++++++++++++------------ bin/cdist-object-run-all | 21 +++--------------- bin/cdist-type-explorer-push | 40 ----------------------------------- doc/dev/todo/steven-from-nico | 19 +++++++++-------- doc/man/cdist-stages.text | 7 ++++-- 8 files changed, 67 insertions(+), 87 deletions(-) delete mode 100755 bin/cdist-type-explorer-push diff --git a/bin/cdist-config b/bin/cdist-config index 9a00395d..2c751cd8 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -57,6 +57,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_object_finished:=done} : ${__cdist_name_object_id:=object_id} : ${__cdist_name_object_source:=source} +: ${__cdist_name_objects_created:=.objects_created} : ${__cdist_name_out_dir:=out} : ${__cdist_name_parameter:=parameter} : ${__cdist_name_parameter_required:=required} @@ -68,6 +69,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_type:=type} : ${__cdist_name_type_bin:=type_bin} : ${__cdist_name_type_explorer:=type_explorer} +: ${__cdist_name_type_explorer_pushed:=.explorer_pushed} # Used for IDs: Allow everything not starting with - and . : ${__cdist_sane_regexp:=[^-\.].*} @@ -115,6 +117,7 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX") : ${__cdist_out_dir:=$__cdist_local_base_dir/$__cdist_name_out_dir} : ${__cdist_out_explorer_dir:=$__cdist_out_dir/$__cdist_name_explorer} : ${__cdist_out_object_dir:=$__cdist_out_dir/$__cdist_name_object} +: ${__cdist_out_type_dir:=$__cdist_out_dir/$__cdist_name_type} : ${__cdist_out_type_bin_dir:=$__cdist_out_dir/$__cdist_name_type_bin} ################################################################################ @@ -134,6 +137,11 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX") : ${__cdist_remote_out_explorer_dir:=$__cdist_remote_out_dir/$__cdist_name_explorer} : ${__cdist_remote_out_object_dir:=$__cdist_remote_out_dir/$__cdist_name_object} +################################################################################ +# Global internal variables +# +: ${__cdist_objects_created:=$__cdist_out_object_dir/$__cdist_name_objects_created} + ################################################################################ # Internal functions # @@ -329,6 +337,18 @@ __cdist_type_has_explorer() fi } +__cdist_type_explorer_pushed() +{ + [ -f "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}" ] \ + && grep -q "$1" "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}" +} + +__cdist_type_explorer_pushed_add() +{ + [ -d "$__cdist_out_type_dir" ] || mkdir "$__cdist_out_type_dir" + echo "$1" >> "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}" +} + __cdist_type_gencode() { echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}" diff --git a/bin/cdist-object-explorer-run b/bin/cdist-object-explorer-run index e9a20921..72ca7a1d 100755 --- a/bin/cdist-object-explorer-run +++ b/bin/cdist-object-explorer-run @@ -32,11 +32,19 @@ __object="$1"; shift __object_id="$(__cdist_object_id_from_object "$__object")" __cdist_type="$(__cdist_type_from_object "$__object")" -# Check if type of object has >= 1 explorer -__cdist_has_explorer="$(__cdist_type___cdist_has_explorer "$__cdist_type")" -# If so, run explorers on remote side +# Check if type of object has >= 1 explorer +__cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" +# Run the type explorers for the current object if any if [ "$__cdist_has_explorer" ]; then + if ! __cdist_type_explorer_pushed "$__cdist_type"; then + src_dir="$(__cdist_type_explorer_dir "$__cdist_type")" + dst_dir="$(__cdist_remote_type_explorer_dir "$__cdist_type")" + echo "Transfering explorers for $__cdist_type ..." + cdist-dir push "$__cdist_target_host" "$src_dir" "$dst_dir" + __cdist_type_explorer_pushed_add "$__cdist_type" + fi + echo "Running explorers for $__object ..." # Copy object parameters cdist-dir push "$__cdist_target_host" \ diff --git a/bin/cdist-object-manifest-run b/bin/cdist-object-manifest-run index a65ed138..25378eb2 100755 --- a/bin/cdist-object-manifest-run +++ b/bin/cdist-object-manifest-run @@ -52,8 +52,8 @@ if [ -f "$__cdist_manifest" ]; then export $__cdist_name_var_type="$(__cdist_type_dir "$__cdist_type")" cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest" - FIXME: Tell cdist that there may be new objects - WHO? Mama? - touch "$__cdist_new_objects_created" + # Tell cdist-object-run-all that there may be new objects + touch "$__cdist_objects_created" else __cdist_exit_err "${__cdist_manifest} needs to be executable." fi diff --git a/bin/cdist-object-run b/bin/cdist-object-run index 015d95fa..f5d846e3 100755 --- a/bin/cdist-object-run +++ b/bin/cdist-object-run @@ -40,23 +40,26 @@ touch "$__cdist_types_pushed" __cdist_object_finished="$(__cdist_object_finished "$__cdist_object")" if [ ! -f "$__cdist_object_finished" ]; then - echo - echo "Running object $__cdist_object" - # Check if type of object has >= 1 explorer - __cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" + # Resolve dependencies if any + __cdist_object_require="$(__cdist_object_require "$__cdist_object")" + if [ -f "$__cdist_object_require" ]; then + echo + # NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP + while read __cdist_requirement; do + set -- "$@" "$__cdist_requirement" + done < "$__cdist_object_require" - FIXME: put into cdist-object-explorer-run - # Run the type explorers for the current object if any - if [ "$__cdist_has_explorer" ]; then - if ! grep -q "$__cdist_type" "$__cdist_types_pushed"; then - cdist-type-explorer-push "$__cdist_target_host" "$__cdist_type" - echo "$__cdist_type" >> "$__cdist_types_pushed" - fi - - cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" + while [ $# -gt 0 ]; do + __cdist_requirement="$1"; shift + echo "Resolving dependency $__cdist_requirement for $__cdist_object ..." + cdist-object-run "$__cdist_target_host" "$__cdist_requirement" + done fi + echo + echo "Running object $__cdist_object" + cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" cdist-object-push "$__cdist_target_host" "$__cdist_object" diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index 7c87660b..c646ab16 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -30,15 +30,12 @@ __cdist_target_host="$1"; shift __cdist_objects="$__cdist_tmp_dir/objects" -FIXME: reuse in subscripts, save in objects_base_dir -export __cdist_objects_created="$__cdist_tmp_dir/objects_created" - # Loop until we do not create new objects anymore # which is equal to all objects have been run -touch "$__cdist_new_objects_created" -while [ -f "$__cdist_new_objects_created" ]; do +touch "$__cdist_objects_created" +while [ -f "$__cdist_objects_created" ]; do # Assume we're done after this run - rm "$__cdist_new_objects_created" + rm "$__cdist_objects_created" # Get listing of objects __cdist_object_list "$__cdist_out_object_dir" > "$__cdist_objects" @@ -50,18 +47,6 @@ while [ -f "$__cdist_new_objects_created" ]; do while [ $# -gt 0 ]; do __cdist_object="$1"; shift - - FIXME: migrate into cdist-object-run - FIXME: take care of SSH foo after migration in while loop - __cdist_object_require="$(__cdist_object_require "$__cdist_object")" - if [ -f "$__cdist_object_require" ]; then - echo - while read __cdist_requirement; do - echo "Resolving dependency $__cdist_requirement for $__cdist_object ..." - cdist-object-run "$__cdist_target_host" "$__cdist_requirement" - done < "$__cdist_object_require" - fi - # Process the object cdist-object-run "$__cdist_target_host" "$__cdist_object" done diff --git a/bin/cdist-type-explorer-push b/bin/cdist-type-explorer-push deleted file mode 100755 index 7ba412ca..00000000 --- a/bin/cdist-type-explorer-push +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# -# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# Push the given types explorers to the target host -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " - -set -eu - -__cdist_target_host="$1"; shift -__cdist_type="$1"; shift - -src_dir="$(__cdist_type_explorer_dir "$__cdist_type")" -dst_dir="$(__cdist_remote_type_explorer_dir "$__cdist_type")" - -if [ -d "$src_dir" ]; then - echo "Transfering explorers for $__cdist_type ..." - cdist-dir push "$__cdist_target_host" "$src_dir" "$dst_dir" -fi - diff --git a/doc/dev/todo/steven-from-nico b/doc/dev/todo/steven-from-nico index c04e980f..2f0ca2b5 100644 --- a/doc/dev/todo/steven-from-nico +++ b/doc/dev/todo/steven-from-nico @@ -31,28 +31,29 @@ x cdist-object-manifest-run: x general: cdist-object-run-all looks like a good idea! -- export $__cdist_name_var_self=$__cdist_object_self -> non core - -- bin/cdist-object-run: type_explorer stuff: probably put into own binary - - sounds like cdist-object-explorer-run is already the right executable to - place such stuff into - -- cdist-type-explorer-push: wherefore if [ -d "$src_dir" ];? +x cdist-type-explorer-push: wherefore if [ -d "$src_dir" ];? -> does this not even hide bugs? -> not sure whether covering cdist-dir in its own script makes sense, as cdist-dir push is only a one liner -> if cdist-dir does too less, enhance it => merge into cdist-object-explorer-run -- marker for type transferred / pushed goes into out/type/ +x bin/cdist-object-run: type_explorer stuff: probably put into own binary + - sounds like cdist-object-explorer-run is already the right executable to + place such stuff into + +x marker for type transferred / pushed goes into out/type/ -> new variables for out/type -> new variables for out/type/.MARKERFOONAMEMEGOOD -- new function: __cdist_type_explorer_created $name +x new function: __cdist_type_explorer_created $name if ! -d foo -> mkdir foo, echo $name >> foo/$NEW_FANCY_VAR +- export $__cdist_name_var_self=$__cdist_object_self -> non core + - align messages (already in todo for steven, but makes life much easier, thus repeated) -> prefix all object stuff with $__self -> __cdist_echo object string -> $__cdist_object_self :-) + diff --git a/doc/man/cdist-stages.text b/doc/man/cdist-stages.text index 4ab93cff..fbd60cea 100644 --- a/doc/man/cdist-stages.text +++ b/doc/man/cdist-stages.text @@ -51,8 +51,11 @@ Related manpages: - cdist-manifest-run-init(1) -STAGE 3: EXECUTION OF TYPES ---------------------------- +STAGE 3: EXECUTION OF OBJECTS +----------------------------- +Each object in the cconfig database is run through the following stages: +- + Every object is checked whether its type has a manifest file. If the type has a manifest file and it is executable, it will be executed. The manifest script may generate and change the created objects. In other words, one type can reuse From 801d2be3d2fbfacd84affbd2e50f85685278d848 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 15:17:45 +0200 Subject: [PATCH 21/38] remove legacy variables Signed-off-by: Steven Armstrong --- bin/cdist-object-run | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/cdist-object-run b/bin/cdist-object-run index f5d846e3..af543316 100755 --- a/bin/cdist-object-run +++ b/bin/cdist-object-run @@ -35,8 +35,6 @@ __cdist_target_host="$1"; shift __cdist_object="$1"; shift __cdist_type="$(__cdist_type_from_object "$__cdist_object")" -__cdist_types_pushed="$__cdist_tmp_dir/types_pushed" -touch "$__cdist_types_pushed" __cdist_object_finished="$(__cdist_object_finished "$__cdist_object")" if [ ! -f "$__cdist_object_finished" ]; then From 32392d129a3cafdaca0ba509e1aada102e656b48 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 15:27:17 +0200 Subject: [PATCH 22/38] implement $__self Signed-off-by: Steven Armstrong --- bin/cdist-config | 2 ++ bin/cdist-object-explorer-run | 1 + bin/cdist-object-run | 2 ++ 3 files changed, 5 insertions(+) diff --git a/bin/cdist-config b/bin/cdist-config index 2c751cd8..19c127d4 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -63,6 +63,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_parameter_required:=required} : ${__cdist_name_parameter_optional:=optional} : ${__cdist_name_require:=require} +: ${__cdist_name_self:=self} : ${__cdist_name_singleton:=singleton} : ${__cdist_name_target_host:=target_host} : ${__cdist_name_target_user:=target_user} @@ -89,6 +90,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_var_target_user:=__$__cdist_name_target_user} : ${__cdist_name_var_object:=__$__cdist_name_object} : ${__cdist_name_var_object_id:=__$__cdist_name_object_id} +: ${__cdist_name_var_self:=__$__cdist_name_self} : ${__cdist_name_var_type:=__$__cdist_name_type} diff --git a/bin/cdist-object-explorer-run b/bin/cdist-object-explorer-run index 72ca7a1d..99e12e89 100755 --- a/bin/cdist-object-explorer-run +++ b/bin/cdist-object-explorer-run @@ -55,6 +55,7 @@ if [ "$__cdist_has_explorer" ]; then cdist-run-remote "$__cdist_target_host" \ "__object=\"$(__cdist_remote_object_dir "$__object")\"" \ "__object_id=\"$__object_id\"" \ + "$__cdist_name_var_self=\"$__cdist_object\"" \ cdist-remote-explorer-run \ "$__cdist_name_var_type_explorer" \ "$(__cdist_remote_type_explorer_dir "$__cdist_type")" \ diff --git a/bin/cdist-object-run b/bin/cdist-object-run index af543316..450ba361 100755 --- a/bin/cdist-object-run +++ b/bin/cdist-object-run @@ -33,6 +33,8 @@ set -eu __cdist_target_host="$1"; shift __cdist_object="$1"; shift +# Export to non-core for use in manifest and gencode scripts +export $__cdist_name_var_self=$__cdist_object __cdist_type="$(__cdist_type_from_object "$__cdist_object")" From ce62775aecd5117040cc4f188d5ff700e7dc46d7 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 15:29:56 +0200 Subject: [PATCH 23/38] remove hard coded variable names; prefix all variables with __cdist_ Signed-off-by: Steven Armstrong --- bin/cdist-object-explorer-run | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/cdist-object-explorer-run b/bin/cdist-object-explorer-run index 99e12e89..ff0668e5 100755 --- a/bin/cdist-object-explorer-run +++ b/bin/cdist-object-explorer-run @@ -27,10 +27,10 @@ set -eu __cdist_target_host="$1"; shift -__object="$1"; shift +__cdist_object="$1"; shift -__object_id="$(__cdist_object_id_from_object "$__object")" -__cdist_type="$(__cdist_type_from_object "$__object")" +__object_id="$(__cdist_object_id_from_object "$__cdist_object")" +__cdist_type="$(__cdist_type_from_object "$__cdist_object")" # Check if type of object has >= 1 explorer @@ -45,24 +45,24 @@ if [ "$__cdist_has_explorer" ]; then __cdist_type_explorer_pushed_add "$__cdist_type" fi - echo "Running explorers for $__object ..." + echo "Running explorers for $__cdist_object ..." # Copy object parameters cdist-dir push "$__cdist_target_host" \ - "$(__cdist_object_parameter_dir "$__object")" \ - "$(__cdist_remote_object_parameter_dir "$__object")" + "$(__cdist_object_parameter_dir "$__cdist_object")" \ + "$(__cdist_remote_object_parameter_dir "$__cdist_object")" # Execute explorers cdist-run-remote "$__cdist_target_host" \ - "__object=\"$(__cdist_remote_object_dir "$__object")\"" \ - "__object_id=\"$__object_id\"" \ - "$__cdist_name_var_self=\"$__cdist_object\"" \ + "$__cdist_name_var_object=\"$(__cdist_remote_object_dir "$__cdist_object")\"" \ + "$__cdist_name_var_object_id=\"$__object_id\"" \ + "$__cdist_name_var_self=\"$__cdist_object\"" \ cdist-remote-explorer-run \ "$__cdist_name_var_type_explorer" \ "$(__cdist_remote_type_explorer_dir "$__cdist_type")" \ - "$(__cdist_remote_object_type_explorer_dir "$__object")" + "$(__cdist_remote_object_type_explorer_dir "$__cdist_object")" # Copy back results cdist-dir pull "$__cdist_target_host" \ - "$(__cdist_remote_object_type_explorer_dir "$__object")" \ - "$(__cdist_object_type_explorer_dir "$__object")" + "$(__cdist_remote_object_type_explorer_dir "$__cdist_object")" \ + "$(__cdist_object_type_explorer_dir "$__cdist_object")" fi From f671df1c67abdebf79918596cd3407339c57d036 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 15:33:37 +0200 Subject: [PATCH 24/38] less todo Signed-off-by: Steven Armstrong --- doc/dev/todo/steven-from-nico | 54 ----------------------------------- 1 file changed, 54 deletions(-) diff --git a/doc/dev/todo/steven-from-nico b/doc/dev/todo/steven-from-nico index 2f0ca2b5..21c8fb52 100644 --- a/doc/dev/todo/steven-from-nico +++ b/doc/dev/todo/steven-from-nico @@ -1,57 +1,3 @@ -x check: echo without parameters == valid in posix? bin/cdist-object-run:45 and others -x bin/cdist-object-run-all: "->" graphic: can be useful, but if -> consistent! - -> all graphics could look cool: - - Object foo - | - |--> Requires ... - |--> ... - - but maybe bad do parse from outside - -x advantage of touch/rm loop vs. y == variable? bin/cdist-object-run-all - also in bin/cdist-object-run - -> cool :-) -x remove enormous amount of empty lines :-) - - at end of file - - between [ $# -eq 2 ] || and set - - after if - - before fi - -x code aus cdist-object-run-all für requirements: - in cdist-object-requirements oder so auslagern? - cdist-object-run-all wäre dann eine schöne zwei-zeiler-schleife - -x cdist-object-explorer-run and bin/cdist-object-run seem to contain - very very similar code regarding transfer and co. - -> indirect solved by moving code into cdist-object-explorer-run - -x cdist-object-manifest-run: - # Tell cdist that there may be new objects -> WHO? :-) - -x general: cdist-object-run-all looks like a good idea! - -x cdist-type-explorer-push: wherefore if [ -d "$src_dir" ];? - -> does this not even hide bugs? - -> not sure whether covering cdist-dir in its own script makes - sense, as cdist-dir push is only a one liner - -> if cdist-dir does too less, enhance it - => merge into cdist-object-explorer-run - -x bin/cdist-object-run: type_explorer stuff: probably put into own binary - - sounds like cdist-object-explorer-run is already the right executable to - place such stuff into - -x marker for type transferred / pushed goes into out/type/ - -> new variables for out/type - -> new variables for out/type/.MARKERFOONAMEMEGOOD - -x new function: __cdist_type_explorer_created $name - if ! -d foo -> mkdir foo, echo $name >> foo/$NEW_FANCY_VAR - -- export $__cdist_name_var_self=$__cdist_object_self -> non core - - - align messages (already in todo for steven, but makes life much easier, thus repeated) -> prefix all object stuff with $__self -> __cdist_echo object string From f2967ef9f13596a4fdaef6e7d07b569ed4ad1154 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 15:36:23 +0200 Subject: [PATCH 25/38] remove legacy script Signed-off-by: Steven Armstrong --- bin/cdist-manifest-run-all | 77 -------------------------------------- 1 file changed, 77 deletions(-) delete mode 100755 bin/cdist-manifest-run-all diff --git a/bin/cdist-manifest-run-all b/bin/cdist-manifest-run-all deleted file mode 100755 index a431576d..00000000 --- a/bin/cdist-manifest-run-all +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# -# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# Run all manifests -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -set -eu - -__cdist_target_host="$1"; shift - -__cdist_objects_list="${__cdist_tmp_dir}/objects_file" -__cdist_new_objects_list="${__cdist_tmp_dir}/new_objects_file" - -# Loop until we do not create new objects anymore -# which is equal to all objects have been run -__cdist_new_objects_created=y -while [ "$__cdist_new_objects_created" = "y" ]; do - # Assume we're done after this run - __cdist_new_objects_created=n - - __cdist_object_list "$__cdist_out_object_dir" > "$__cdist_objects_list" - - # Check every object, if we need to run it - while read __cdist_object_self; do - # Full path to current object - __cdist_cur_object_dir="$(__cdist_object_dir "$__cdist_object_self")" - - # Only the id - __cdist_object_id="$(__cdist_object_id_from_object "$__cdist_object_self")" - - if [ ! -f "${__cdist_cur_object_dir}/$__cdist_name_object_finished" ]; then - echo "Checking manifest for ${__cdist_object_self} ..." - - __cdist_type="$(__cdist_type_from_object "$__cdist_object_self")" - __cdist_manifest="$(__cdist_type_manifest "${__cdist_type}")" - - if [ -f "$__cdist_manifest" ]; then - if [ -x "$__cdist_manifest" ]; then - # Make __cdist_manifest available for cdist-type-emulator - export __cdist_manifest - - echo "Executing manifest ${__cdist_manifest} ..." - # Make variables available to non-core - FIXME: beatify - export $__cdist_name_var_object="$__cdist_cur_object_dir" - export $__cdist_name_var_object_id="$__cdist_object_id" - export $__cdist_name_var_type="$(__cdist_type_dir "$__cdist_type")" - - cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest" - __cdist_new_objects_created=y - else - __cdist_exit_err "${__cdist_manifest} needs to be executable." - fi - fi - fi - - # done with this object - touch "$__cdist_cur_object_dir/$__cdist_name_object_finished" - done < "$__cdist_objects_list" -done From 49e987236fed77a1fc4314a1637ac82b29eba3bc Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 15:42:17 +0200 Subject: [PATCH 26/38] add manpage for cdist-object-manifest-run Signed-off-by: Steven Armstrong --- doc/man/cdist-object-manifest-run.text | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 doc/man/cdist-object-manifest-run.text diff --git a/doc/man/cdist-object-manifest-run.text b/doc/man/cdist-object-manifest-run.text new file mode 100644 index 00000000..76132425 --- /dev/null +++ b/doc/man/cdist-object-manifest-run.text @@ -0,0 +1,32 @@ +cdist-object-manifest-run(1) +============================ +Nico Schottelius +Steven Armstrong + + +NAME +---- +cdist-object-manifest-run - Run an objects manifest + + +SYNOPSIS +-------- +cdist-object-manifest-run HOSTNAME OBJECT + + +DESCRIPTION +----------- +Run the manifest for the given object. + + +SEE ALSO +-------- +- cdist(7) +- cdist-deploy-to(1) +- cdist-manifest-run(1) + + +COPYING +------- +Copyright \(C) 2011 Nico Schottelius, Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). From 59cc3dc1b3afb9f5abc2a4dc55fd4984ed3b05b1 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 15:42:40 +0200 Subject: [PATCH 27/38] remove legacy manpage Signed-off-by: Steven Armstrong --- doc/man/cdist-manifest-run-all.text | 32 ----------------------------- 1 file changed, 32 deletions(-) delete mode 100644 doc/man/cdist-manifest-run-all.text diff --git a/doc/man/cdist-manifest-run-all.text b/doc/man/cdist-manifest-run-all.text deleted file mode 100644 index 717089ad..00000000 --- a/doc/man/cdist-manifest-run-all.text +++ /dev/null @@ -1,32 +0,0 @@ -cdist-manifest-run-all(1) -========================== -Nico Schottelius - - -NAME ----- -cdist-manifest-run-all - Run manifests of all created types - - -SYNOPSIS --------- -cdist-manifest-run-all HOSTNAME - - -DESCRIPTION ------------ -cdist-manifest-run-all iterates over every existing object and -executes the manifest of its type. - - -SEE ALSO --------- -- cdist(7) -- cdist-deploy-to(1) -- cdist-manifest-run-init(1) - - -COPYING -------- -Copyright \(C) 2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). From 7ff24008308faf57bc1638c68e967230c918c4cc Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 15:43:37 +0200 Subject: [PATCH 28/38] remove legacy manpage Signed-off-by: Steven Armstrong --- doc/man/cdist-type-explorer-push.text | 32 --------------------------- 1 file changed, 32 deletions(-) delete mode 100644 doc/man/cdist-type-explorer-push.text diff --git a/doc/man/cdist-type-explorer-push.text b/doc/man/cdist-type-explorer-push.text deleted file mode 100644 index e32f10a4..00000000 --- a/doc/man/cdist-type-explorer-push.text +++ /dev/null @@ -1,32 +0,0 @@ -cdist-type-explorer-push(1) -=========================== -Nico Schottelius -Steven Armstrong - - -NAME ----- -cdist-type-explorer-push - Transfer type explorers to the target host - - -SYNOPSIS --------- -cdist-type-explorer-push HOSTNAME TYPE - - -DESCRIPTION ------------ -Transfers the explorers of the given type to the target host. - - -SEE ALSO --------- -- cdist(7) -- cdist-object-run(1) -- cdist-type(1) - - -COPYING -------- -Copyright \(C) 2011 Nico Schottelius, Steven Armstrong. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). From 7c920231b7ac1de4b3aead46b0ed288c29b0721f Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 16:11:38 +0200 Subject: [PATCH 29/38] update stages man page to reflect new situation Signed-off-by: Steven Armstrong --- doc/man/cdist-stages.text | 60 ++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/doc/man/cdist-stages.text b/doc/man/cdist-stages.text index fbd60cea..465a7fc8 100644 --- a/doc/man/cdist-stages.text +++ b/doc/man/cdist-stages.text @@ -1,6 +1,7 @@ cdist-stages(7) =============== Nico Schottelius +Steven Armstrong NAME @@ -12,8 +13,8 @@ DESCRIPTION ----------- Starting the execution of deployment with cdist-deploy-to(1), cdist passes through different stages, each can be triggered and debugged on its own. -Reading the source of the cdist-deploy-to executable shous the scripts -responsible for each stage. +Reading the source of the cdist-deploy-to and cdist-object-run-all executables +shows the scripts responsible for each stage. STAGE 0: INTERNAL PREPERATION @@ -23,7 +24,7 @@ to contain cdist binaries and creates a clean environment for the configuration run. Related manpages: - - cdist-bin-transfer(1) + - cdist-bin-transfer(1) FIXME: does not exist STAGE 1: TARGET INFORMATION RETRIEVAL @@ -34,6 +35,8 @@ explorers are copied back into the local cache. The results can be used by manifests and types. Related manpages: + - cdist-explorer-run-global(1) + - cdist-remote-explorer-run(1) - cdist-explorer(7) @@ -46,16 +49,27 @@ no conflicts may occur, i.e. no object of the same type with the same id may be created. Related manpages: - - cdist-manifest(7) - - cdist-manifest-run(1) - cdist-manifest-run-init(1) + - cdist-manifest-run(1) + - cdist-manifest(7) -STAGE 3: EXECUTION OF OBJECTS ------------------------------ -Each object in the cconfig database is run through the following stages: -- +STAGE 3: OBJECT INFORMATION RETRIEVAL +------------------------------------- +Every object is checked whether its type has explorers and if so, these are +transfered to the target host and executed. The results are transfered back +and can be used in the following stages to decide what changes need to made +on the target to implement the desired state. +Related manpages: + - cdist-object-explorer-run(1) + - cdist-remote-explorer-run(1) + - cdist-type(7) + - cdist-explorer(7) + + +STAGE 4: RUN THE OBJECT MANIFEST +-------------------------------- Every object is checked whether its type has a manifest file. If the type has a manifest file and it is executable, it will be executed. The manifest script may generate and change the created objects. In other words, one type can reuse @@ -69,12 +83,12 @@ may occur during the merge. A conflict would mean that two different objects try to create the same object, which indicates a broken configuration. Related manpages: + - cdist-object-manifest-run(1) - cdist-manifest-run(1) - - cdist-manifest-run-all(1) - cdist-type(7) -STAGE 4: CODE GENERATION +STAGE 5: CODE GENERATION ------------------------ In this stage for every created objects its type is checked whether it has a gencode script. If the type has a gencode script and it is executable it will @@ -83,19 +97,27 @@ on stdout. If the gencode executable fails, it must print diagnostic messages on stderr and exit non-zero. Related manpages: - - cdist-gencode(1) - - cdist-gencode-all(1) + - cdist-object-gencode-run(1) + - cdist-object-gencode(1) - cdist-type(7) -STAGE 5: CODE EXECUTION +STAGE 6: CODE EXECUTION ----------------------- -The resulting code from the previous stage is transferred to the target host -and executed there to apply the configuration changes, +For every object the resulting code from the previous stage is transferred to +the target host and executed there to apply the configuration changes. Related manpages: - - cdist-exec-run(1) - - cdist-exec-transfer(1) + - cdist-object-code-run(1) + - cdist-code-run(1) + + +STAGE 7: CACHE +-------------- +The cache stores the information from the current run for later use. + +Related manpages: + - cdist-cache(1) SUMMARY @@ -115,5 +137,5 @@ SEE ALSO COPYING ------- -Copyright \(C) 2010-2011 Nico Schottelius. Free use of this software is +Copyright \(C) 2010-2011 Nico Schottelius, Steven Armstrong. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3). From 44fd2e3c1ce0f59e0c0b0d4de54c4c5a2955b4f9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 29 Mar 2011 16:23:45 +0200 Subject: [PATCH 30/38] :%s/Related manpages/Related documentation/g Signed-off-by: Nico Schottelius --- doc/man/cdist-stages.text | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/man/cdist-stages.text b/doc/man/cdist-stages.text index 465a7fc8..279e1d5f 100644 --- a/doc/man/cdist-stages.text +++ b/doc/man/cdist-stages.text @@ -23,7 +23,7 @@ Before running the user facing stages, cdist prepares the target host to contain cdist binaries and creates a clean environment for the configuration run. -Related manpages: +Related documentation: - cdist-bin-transfer(1) FIXME: does not exist @@ -34,7 +34,7 @@ explorers. Every existing explorer is run on the target and the output of all explorers are copied back into the local cache. The results can be used by manifests and types. -Related manpages: +Related documentation: - cdist-explorer-run-global(1) - cdist-remote-explorer-run(1) - cdist-explorer(7) @@ -48,7 +48,7 @@ the objects as defined in the manifest for the specific host. In this stage, no conflicts may occur, i.e. no object of the same type with the same id may be created. -Related manpages: +Related documentation: - cdist-manifest-run-init(1) - cdist-manifest-run(1) - cdist-manifest(7) @@ -61,7 +61,7 @@ transfered to the target host and executed. The results are transfered back and can be used in the following stages to decide what changes need to made on the target to implement the desired state. -Related manpages: +Related documentation: - cdist-object-explorer-run(1) - cdist-remote-explorer-run(1) - cdist-type(7) @@ -82,7 +82,7 @@ The newly created objects are merged back into the existing tree. No conflicts may occur during the merge. A conflict would mean that two different objects try to create the same object, which indicates a broken configuration. -Related manpages: +Related documentation: - cdist-object-manifest-run(1) - cdist-manifest-run(1) - cdist-type(7) @@ -96,7 +96,7 @@ be executed. This executable should create code to be executed on the target on stdout. If the gencode executable fails, it must print diagnostic messages on stderr and exit non-zero. -Related manpages: +Related documentation: - cdist-object-gencode-run(1) - cdist-object-gencode(1) - cdist-type(7) @@ -107,7 +107,7 @@ STAGE 6: CODE EXECUTION For every object the resulting code from the previous stage is transferred to the target host and executed there to apply the configuration changes. -Related manpages: +Related documentation: - cdist-object-code-run(1) - cdist-code-run(1) @@ -116,7 +116,7 @@ STAGE 7: CACHE -------------- The cache stores the information from the current run for later use. -Related manpages: +Related documentation: - cdist-cache(1) From e2e4936103379d6e25de2198a633b6bc8ae9bfca Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 29 Mar 2011 16:24:13 +0200 Subject: [PATCH 31/38] -FIXME in doc/man/cdist-stages.text Signed-off-by: Nico Schottelius --- doc/man/cdist-stages.text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/cdist-stages.text b/doc/man/cdist-stages.text index 279e1d5f..6ac6efe2 100644 --- a/doc/man/cdist-stages.text +++ b/doc/man/cdist-stages.text @@ -24,7 +24,7 @@ to contain cdist binaries and creates a clean environment for the configuration run. Related documentation: - - cdist-bin-transfer(1) FIXME: does not exist + - Source of cdist-deploy-to STAGE 1: TARGET INFORMATION RETRIEVAL From 3fae65539e58b02cbad9bc3e901f65098bad6772 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 16:25:26 +0200 Subject: [PATCH 32/38] remove legacy man pages Signed-off-by: Steven Armstrong --- build.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 709c1c55..335bbe9c 100755 --- a/build.sh +++ b/build.sh @@ -70,12 +70,11 @@ case "$1" in ;; man1) - for man in cdist-code-run.text cdist-code-run-all.text cdist-config.text \ + for man in cdist-code-run.text cdist-config.text \ cdist-dir.text cdist-env.text cdist-explorer-run-global.text \ cdist-deploy-to.text cdist-explorer.text cdist-manifest.text \ cdist-manifest-run.text cdist-manifest-run-init.text \ - cdist-manifest-run-all.text cdist-object-explorer-all.text \ - cdist-object-gencode.text cdist-object-gencode-all.text \ + cdist-object-gencode.text \ cdist-remote-explorer-run.text cdist-run-remote.text \ cdist-type-build-emulation.text cdist-type-emulator.text \ cdist-type-template.text From ad7a9f82f77526a2c52b30447686ecf6391cd6e3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 29 Mar 2011 16:27:57 +0200 Subject: [PATCH 33/38] __cdist_objects_created == local output Signed-off-by: Nico Schottelius --- bin/cdist-config | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 19c127d4..1882d1bb 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -122,6 +122,8 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX") : ${__cdist_out_type_dir:=$__cdist_out_dir/$__cdist_name_type} : ${__cdist_out_type_bin_dir:=$__cdist_out_dir/$__cdist_name_type_bin} +: ${__cdist_objects_created:=$__cdist_out_object_dir/$__cdist_name_objects_created} + ################################################################################ # Remote base # @@ -139,10 +141,6 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX") : ${__cdist_remote_out_explorer_dir:=$__cdist_remote_out_dir/$__cdist_name_explorer} : ${__cdist_remote_out_object_dir:=$__cdist_remote_out_dir/$__cdist_name_object} -################################################################################ -# Global internal variables -# -: ${__cdist_objects_created:=$__cdist_out_object_dir/$__cdist_name_objects_created} ################################################################################ # Internal functions From 6be9d02e6a8f588d4b40ef0fdf01743d8f9736cc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 29 Mar 2011 16:28:59 +0200 Subject: [PATCH 34/38] consistency: function {} begin on next line Signed-off-by: Nico Schottelius --- bin/cdist-config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 1882d1bb..531f709c 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -185,11 +185,13 @@ __cdist_init_deploy() ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir" } -__cdist_new_objects_created() { +__cdist_new_objects_created() +{ touch "$__cdist_tmp_dir/object_created" } -__cdist_has_new_objects() { +__cdist_has_new_objects() +{ touch "$__cdist_tmp_dir/object_created" } @@ -267,7 +269,6 @@ __cdist_object_type_explorer_dir() echo "$(__cdist_object_dir "$1")/${__cdist_name_explorer}" } - ################################################################################ # Remote # From 0422eda599f51916c9c7d3cbd213b818d00c62e0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 29 Mar 2011 16:33:09 +0200 Subject: [PATCH 35/38] WARNING: WHITESPACE-NAZI Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 138f7714..e63d3dfb 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -17,5 +17,3 @@ Types to be written/extended: - regexp replace (can probably cover all?) -> aka sed. - __cron - - From a5586aecff4ef3a37e41da1fe86b772027130329 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 16:36:10 +0200 Subject: [PATCH 36/38] changelog++ Signed-off-by: Steven Armstrong --- doc/changelog | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/changelog b/doc/changelog index 7faf789b..20c59b93 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,7 +1,11 @@ 1.5.0: * Add cache functionality * New type __process - * Restructured execution: Run whole object at once (REPHRASE) (Steven Armstrong) + * Restructured execution: (Steven Armstrong) + Process each object as a whole, resolve dependencies and ensure + correct execution order. + * Documentation: Rewrite stages docs + * Documentation: Remove legacy man pages 1.4.1: 2011-03-25 * New type __key_value (Steven Armstrong) From ebbacf48732ee2375a7fe8704985162ce121ed87 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Mar 2011 16:41:38 +0200 Subject: [PATCH 37/38] remove unused functions Signed-off-by: Steven Armstrong --- bin/cdist-config | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 531f709c..eb2a8e90 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -185,16 +185,6 @@ __cdist_init_deploy() ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir" } -__cdist_new_objects_created() -{ - touch "$__cdist_tmp_dir/object_created" -} - -__cdist_has_new_objects() -{ - touch "$__cdist_tmp_dir/object_created" -} - ################################################################################ # Object # From 5024c4bf580141e049bc30e825c660306295eeb5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 29 Mar 2011 16:45:16 +0200 Subject: [PATCH 38/38] more changes, quote author correctly Signed-off-by: Nico Schottelius --- doc/changelog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/changelog b/doc/changelog index 20c59b93..5e0e2314 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,11 +1,11 @@ 1.5.0: - * Add cache functionality + * Add basic cache functionality * New type __process * Restructured execution: (Steven Armstrong) Process each object as a whole, resolve dependencies and ensure correct execution order. - * Documentation: Rewrite stages docs - * Documentation: Remove legacy man pages + * Documentation: Rewrite stages docs (Steven Armstrong) + * Documentation: Remove legacy man pages (Steven Armstrong) 1.4.1: 2011-03-25 * New type __key_value (Steven Armstrong)