From 17c6a650ff4a8124634d6eba41c1556749f05c87 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 24 Mar 2011 15:06:56 +0100 Subject: [PATCH 01/29] change workflow proposal Signed-off-by: Nico Schottelius --- bin/cdist-deploy-to | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 9a2fd303..7a63f5ca 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -50,6 +50,8 @@ 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" + +# Change workflow here: cdist-object-{apply, run, foo} cdist-object-explorer-all "$__cdist_target_host" cdist-object-gencode-all "$__cdist_target_host" @@ -59,4 +61,6 @@ cdist-dir push "$__cdist_target_host" "$__cdist_out_object_dir" \ cdist-code-run-all "$__cdist_target_host" +# Stop change here + echo "cdist $__cdist_version: Successfully finished run on $__cdist_target_host" From 086e47a636c765835f132735d319da9141f34696 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 00:23:59 +0100 Subject: [PATCH 02/29] extract code to transfer type explorers into its own executable Signed-off-by: Steven Armstrong --- bin/cdist-type-explorer-push | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 bin/cdist-type-explorer-push diff --git a/bin/cdist-type-explorer-push b/bin/cdist-type-explorer-push new file mode 100755 index 00000000..7ba412ca --- /dev/null +++ b/bin/cdist-type-explorer-push @@ -0,0 +1,40 @@ +#!/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 + From 92005e25670206302ae87d1b3da561f0911aa176 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 00:24:35 +0100 Subject: [PATCH 03/29] extract code to run an objects explorers into its own executable Signed-off-by: Steven Armstrong --- bin/cdist-object-explorer-run | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 bin/cdist-object-explorer-run diff --git a/bin/cdist-object-explorer-run b/bin/cdist-object-explorer-run new file mode 100755 index 00000000..e349a490 --- /dev/null +++ b/bin/cdist-object-explorer-run @@ -0,0 +1,61 @@ +#!/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 . +# +# +# Run the explorers for the given object on the target host. +# + +. cdist-config +[ $# -eq 2 ] || __cdist_usage " " + +set -eu + +__cdist_target_host="$1"; shift +__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 +has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" + +# If so, run explorers on remote side +if [ "$has_explorer" ]; then + echo "Running explorers for $__object ..." + # Copy object parameters + cdist-dir push "$__cdist_target_host" \ + "$(__cdist_object_parameter_dir "$__object")" \ + "$(__cdist_remote_object_parameter_dir "$__object")" + + # Execute explorers + cdist-run-remote "$__cdist_target_host" \ + "__object=\"$(__cdist_remote_object_dir "$__object")\"" \ + "__object_id=\"$__object_id\"" \ + cdist-remote-explorer-run \ + "$__cdist_name_var_type_explorer" \ + "$(__cdist_remote_type_explorer_dir "$__cdist_type")" \ + "$(__cdist_remote_object_type_explorer_dir "$__object")" + + # Copy back results + cdist-dir pull "$__cdist_target_host" \ + "$(__cdist_remote_object_type_explorer_dir "$__object")" \ + "$(__cdist_object_type_explorer_dir "$__object")" +fi + From f7d20c002cd8f2d34ebdf3296a6e70d473ca885e Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 00:25:46 +0100 Subject: [PATCH 04/29] introduce new executable to process objects Signed-off-by: Steven Armstrong --- bin/cdist-object-run-all | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 bin/cdist-object-run-all diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all new file mode 100755 index 00000000..1dfef04f --- /dev/null +++ b/bin/cdist-object-run-all @@ -0,0 +1,61 @@ +#!/bin/sh +# +# 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 . +# +# +# For each created object: +# - run type explorers +# - generate code +# - copy object to target +# - execute code on target +# + +. cdist-config +[ $# -eq 1 ] || __cdist_usage "" +set -eu + +__cdist_target_host="$1"; shift + +object_listing="$__cdist_tmp_dir/objects" +type_listing_all="$__cdist_tmp_dir/types_all" +type_listing="$__cdist_tmp_dir/types" +types_pushed="$__cdist_tmp_dir/types_pushed" +touch "$types_pushed" + + +# Get listing of objects +__cdist_object_list "$__cdist_out_object_dir" > "$object_listing" + + +while read object; do + __cdist_type="$(__cdist_type_from_object "$object")" + if __cdist_type_has_explorer "$__cdist_type"; then + # Transfer the type explorers + if ! grep -q "$__cdist_type" "$types_pushed"; then + cdist-type-explorer-push "$__cdist_target_host" "$__cdist_type" + echo "$__cdist_type" >> "$types_pushed" + fi + + # Run the type explorers for the current object + cdist-object-explorer-run "$__cdist_target_host" "$object" + + fi + +done < "$object_listing" + From b740a4b934dc719f9a4f6a2cca4dd8c21d211c95 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 00:26:12 +0100 Subject: [PATCH 05/29] use new workflow Signed-off-by: Steven Armstrong --- bin/cdist-deploy-to | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 7a63f5ca..29c3a847 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -52,6 +52,9 @@ cdist-manifest-run-init "$__cdist_target_host" cdist-manifest-run-all "$__cdist_target_host" # Change workflow here: cdist-object-{apply, run, foo} +cdist-object-run-all "$__cdist_target_host" +exit + cdist-object-explorer-all "$__cdist_target_host" cdist-object-gencode-all "$__cdist_target_host" From 31a0b6c3d0b202f6624f236c122d27a93b9ce3e7 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:43:55 +0100 Subject: [PATCH 06/29] fixed inconsistencies between local and remote variable naming - /__cdist_remote_out_object_base_dir/__cdist_remote_out_object_dir/ - __cdist_remote_object_dir += __cdist_name_dot_cdist Signed-off-by: Steven Armstrong --- bin/cdist-code-run-all | 2 +- bin/cdist-config | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/cdist-code-run-all b/bin/cdist-code-run-all index 1486cc46..6f5aeb92 100755 --- a/bin/cdist-code-run-all +++ b/bin/cdist-code-run-all @@ -44,7 +44,7 @@ while [ $# -ge 1 ]; do # Code remote cdist-run-remote "$__cdist_target_host" \ - "export __cdist_out_object_dir=\"$__cdist_remote_out_object_base_dir\";" \ + "export __cdist_out_object_dir=\"$__cdist_remote_out_object_dir\";" \ "cdist-code-run" "$object" "${__cdist_name_gencode_remote}" \ || __cdist_exit_err "Remote code failed for $object" done < "$__cdist_tmp_file" diff --git a/bin/cdist-config b/bin/cdist-config index 86039f00..26139819 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -131,7 +131,7 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX") # : ${__cdist_remote_out_dir:=$__cdist_remote_base_dir/$__cdist_name_out_dir} : ${__cdist_remote_out_explorer_dir:=$__cdist_remote_out_dir/$__cdist_name_explorer} -: ${__cdist_remote_out_object_base_dir:=$__cdist_remote_out_dir/$__cdist_name_object} +: ${__cdist_remote_out_object_dir:=$__cdist_remote_out_dir/$__cdist_name_object} ################################################################################ # Internal functions @@ -254,9 +254,14 @@ __cdist_object_type_explorer_dir() # Remote # +__cdist_remote_object_base_dir() +{ + echo "${__cdist_remote_out_object_dir}/$1" +} + __cdist_remote_object_dir() { - echo "${__cdist_remote_out_object_base_dir}/$1" + echo "$(__cdist_remote_object_base_dir "$1")/${__cdist_name_dot_cdist}" } __cdist_remote_object_parameter_dir() From 14ece853df0a5daf6ee1dd7ec5da06b8596988ac Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:46:02 +0100 Subject: [PATCH 07/29] trust nico when he says: SSH DESTROYS WHILE READ LOOP Signed-off-by: Steven Armstrong --- bin/cdist-object-run-all | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index 1dfef04f..a6e5790d 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -43,9 +43,21 @@ touch "$types_pushed" __cdist_object_list "$__cdist_out_object_dir" > "$object_listing" +# NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP while read object; do + set -- "$@" "$object" +done < "$object_listing" + +while [ $# -gt 0 ]; do + object="$1"; shift + __cdist_type="$(__cdist_type_from_object "$object")" - if __cdist_type_has_explorer "$__cdist_type"; then + + # Check if type of object has >= 1 explorer + has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" + + # If so, run explorers on remote side + if [ "$has_explorer" ]; then # Transfer the type explorers if ! grep -q "$__cdist_type" "$types_pushed"; then cdist-type-explorer-push "$__cdist_target_host" "$__cdist_type" @@ -57,5 +69,14 @@ while read object; do fi -done < "$object_listing" + # Run the gencode scripts for the current object + cdist-object-gencode-run "$__cdist_target_host" "$object" + + # Transfer the current object to the target + cdist-object-push "$__cdist_target_host" "$object" + + # Run the code for the current object + cdist-object-code-run "$__cdist_target_host" "$object" + +done From e8d656556cb15f7f8f975415ae3b75e5f1494968 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:46:53 +0100 Subject: [PATCH 08/29] /__cdist_remote_out_object_base_dir/__cdist_remote_out_object_dir/ Signed-off-by: Steven Armstrong --- bin/cdist-deploy-to | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 29c3a847..db26a988 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -51,6 +51,7 @@ cdist-explorer-run-global "$__cdist_target_host" cdist-manifest-run-init "$__cdist_target_host" cdist-manifest-run-all "$__cdist_target_host" + # Change workflow here: cdist-object-{apply, run, foo} cdist-object-run-all "$__cdist_target_host" exit @@ -60,7 +61,7 @@ cdist-object-gencode-all "$__cdist_target_host" echo "Transferring objects to $__cdist_target_host ..." cdist-dir push "$__cdist_target_host" "$__cdist_out_object_dir" \ - "${__cdist_remote_out_object_base_dir}" + "${__cdist_remote_out_object_dir}" cdist-code-run-all "$__cdist_target_host" From 31842564d37374e844a56d2bc3f5629dfc8d2a18 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:47:51 +0100 Subject: [PATCH 09/29] extract code to run gencode scripts into its own executable Signed-off-by: Steven Armstrong --- bin/cdist-object-gencode-run | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 bin/cdist-object-gencode-run diff --git a/bin/cdist-object-gencode-run b/bin/cdist-object-gencode-run new file mode 100755 index 00000000..76ce6953 --- /dev/null +++ b/bin/cdist-object-gencode-run @@ -0,0 +1,44 @@ +#!/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 . +# +# +# For the given object create the code to be executed on the target. +# + +. cdist-config +[ $# -eq 2 ] || __cdist_usage " " +set -eu + +__cdist_target_host="$1"; shift +__cdist_object="$1"; shift + +code_local="$(__cdist_object_code "$__cdist_object")-${__cdist_name_gencode_local}" +code_remote="$(__cdist_object_code "$__cdist_object")-${__cdist_name_gencode_remote}" + +echo "Generating local code for $__cdist_object ..." +cdist-object-gencode "$__cdist_target_host" "$__cdist_object" \ + "${__cdist_name_gencode_local}" > "${code_local}" + +echo "Generating remote code for $__cdist_object ..." +cdist-object-gencode "$__cdist_target_host" "$__cdist_object" \ + "${__cdist_name_gencode_remote}" > "${code_remote}" + +chmod u+x "${code_local}" "${code_remote}" + From 4c6f115a434eaf9e33ec1b305179b306f53d0edd Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:48:19 +0100 Subject: [PATCH 10/29] extract code to execute gencode-generated scripts into its own executable Signed-off-by: Steven Armstrong --- bin/cdist-object-code-run | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 bin/cdist-object-code-run diff --git a/bin/cdist-object-code-run b/bin/cdist-object-code-run new file mode 100755 index 00000000..b75f6f46 --- /dev/null +++ b/bin/cdist-object-code-run @@ -0,0 +1,42 @@ +#!/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 . +# +# +# Exec the code for the given object locally and remote +# + +. cdist-config +[ $# -eq 2 ] || __cdist_usage " " +set -e + +__cdist_target_host="$1"; shift +__cdist_object="$1"; shift + +# Code local +export __cdist_out_object_dir="$__cdist_out_object_dir" +cdist-code-run "$__cdist_object" "${__cdist_name_gencode_local}" \ + || __cdist_exit_err "Local code failed for $__cdist_object" + +# Code remote +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 0dab5b5f7e80a69c4a39e708e22c6920d4095713 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:48:44 +0100 Subject: [PATCH 11/29] extract code to transfer objects into its own executable Signed-off-by: Steven Armstrong --- bin/cdist-object-push | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 bin/cdist-object-push diff --git a/bin/cdist-object-push b/bin/cdist-object-push new file mode 100755 index 00000000..9c44d14e --- /dev/null +++ b/bin/cdist-object-push @@ -0,0 +1,37 @@ +#!/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 . +# +# +# Transfer the given object to the target host. +# + +. cdist-config +[ $# -eq 2 ] || __cdist_usage " " +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")" + From 2c710186996f40b2e7ef1182ddd176897d3abdb2 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:52:15 +0100 Subject: [PATCH 12/29] migrate to new workflow Signed-off-by: Steven Armstrong --- bin/cdist-code-run-all | 50 ----------------- bin/cdist-deploy-to | 15 ----- bin/cdist-object-explorer-all | 102 ---------------------------------- bin/cdist-object-gencode-all | 45 --------------- 4 files changed, 212 deletions(-) delete mode 100755 bin/cdist-code-run-all delete mode 100755 bin/cdist-object-explorer-all delete mode 100755 bin/cdist-object-gencode-all diff --git a/bin/cdist-code-run-all b/bin/cdist-code-run-all deleted file mode 100755 index 6f5aeb92..00000000 --- a/bin/cdist-code-run-all +++ /dev/null @@ -1,50 +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 . -# -# -# Exec code locally and remote -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -set -e - -__cdist_target_host="$1"; shift - -__cdist_object_list "$__cdist_out_object_dir" > "$__cdist_tmp_file" - -# NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP -while read object; do - set -- "$@" "$object" -done < "$__cdist_tmp_file" - -while [ $# -ge 1 ]; do - object="$1"; shift - - # Code local - export __cdist_out_object_dir="$__cdist_out_object_dir" - cdist-code-run "$object" "${__cdist_name_gencode_local}" \ - || __cdist_exit_err "Local code failed for $object" - - # Code remote - cdist-run-remote "$__cdist_target_host" \ - "export __cdist_out_object_dir=\"$__cdist_remote_out_object_dir\";" \ - "cdist-code-run" "$object" "${__cdist_name_gencode_remote}" \ - || __cdist_exit_err "Remote code failed for $object" -done < "$__cdist_tmp_file" diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index db26a988..96b65e8b 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -50,21 +50,6 @@ 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" - - -# Change workflow here: cdist-object-{apply, run, foo} cdist-object-run-all "$__cdist_target_host" -exit - -cdist-object-explorer-all "$__cdist_target_host" -cdist-object-gencode-all "$__cdist_target_host" - -echo "Transferring objects to $__cdist_target_host ..." -cdist-dir push "$__cdist_target_host" "$__cdist_out_object_dir" \ - "${__cdist_remote_out_object_dir}" - -cdist-code-run-all "$__cdist_target_host" - -# Stop change here echo "cdist $__cdist_version: Successfully finished run on $__cdist_target_host" diff --git a/bin/cdist-object-explorer-all b/bin/cdist-object-explorer-all deleted file mode 100755 index 692a79bb..00000000 --- a/bin/cdist-object-explorer-all +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -# -# 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 . -# -# -# For each created object check the explorers and run them if needed. -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -set -eu - -__cdist_target_host="$1"; shift - -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_out_object_dir" > "$object_listing" - -# Get listing of types used -while read object; do - echo "$(__cdist_type_from_object "$object")" >> "$type_listing_all" -done < "$object_listing" -sort "$type_listing_all" | uniq > "$type_listing" - -# Create pseudo array to avoid issues with ssh -tc=0 -while read type; do - eval type_$tc=\"\$type\" - tc=$((tc+1)) -done < "$type_listing" - -# For every type that has explorers, Transfer the explorers -i=0 -while [ "$i" -lt "$tc" ]; do - eval cur_type=\"\$type_$i\" - - src_dir="$(__cdist_type_explorer_dir "$cur_type")" - dst_dir="$(__cdist_remote_type_explorer_dir "$cur_type")" - - if [ -d "$src_dir" ]; then - cdist-dir push "$__cdist_target_host" "$src_dir" "$dst_dir" - fi - i=$((i+1)) -done - -################################################################################ -# Explorer execution per object -# -# need to create pseudo array, as ssh in cdist-explorer-run will destroy while-read loops -while read object; do - set -- "$@" "$object" -done < "$object_listing" - -while [ $# -gt 0 ]; do - __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 - has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" - - # If so, run explorers on remote side - if [ "$has_explorer" ]; then - echo "Running explorers for $__object ..." - # Copy object parameters - cdist-dir push "$__cdist_target_host" \ - "$(__cdist_object_parameter_dir "$__object")" \ - "$(__cdist_remote_object_parameter_dir "$__object")" - - # Execute explorers - cdist-run-remote "$__cdist_target_host" \ - "__object=\"$(__cdist_remote_object_dir "$__object")\"" \ - "__object_id=\"$__object_id\"" \ - cdist-remote-explorer-run \ - "$__cdist_name_var_type_explorer" \ - "$(__cdist_remote_type_explorer_dir "$__cdist_type")" \ - "$(__cdist_remote_object_type_explorer_dir "$__object")" - - # Copy back results - cdist-dir pull "$__cdist_target_host" \ - "$(__cdist_remote_object_type_explorer_dir "$__object")" \ - "$(__cdist_object_type_explorer_dir "$__object")" - fi -done diff --git a/bin/cdist-object-gencode-all b/bin/cdist-object-gencode-all deleted file mode 100755 index 00ac1664..00000000 --- a/bin/cdist-object-gencode-all +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# -# 2010 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 . -# -# -# For each created object create the code to be executed on the target. -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -set -eu - -__cdist_target_host="$1"; shift - -__cdist_object_list "$__cdist_out_object_dir" > "$__cdist_tmp_file" - -while read object; do - code_local="$(__cdist_object_code "$object")-${__cdist_name_gencode_local}" - code_remote="$(__cdist_object_code "$object")-${__cdist_name_gencode_remote}" - - echo "Generating local code for $object ..." - cdist-object-gencode "$__cdist_target_host" "$object" \ - "${__cdist_name_gencode_local}" > "${code_local}" - - echo "Generating remote code for $object ..." - cdist-object-gencode "$__cdist_target_host" "$object" \ - "${__cdist_name_gencode_remote}" > "${code_remote}" - - chmod u+x "${code_local}" "${code_remote}" -done < "$__cdist_tmp_file" From 4e2d063911587fda08d703c6fc74b28b112c42b3 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:53:03 +0100 Subject: [PATCH 13/29] cleanup: remove unused variables Signed-off-by: Steven Armstrong --- bin/cdist-object-run-all | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index a6e5790d..67c69154 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -33,8 +33,6 @@ set -eu __cdist_target_host="$1"; shift object_listing="$__cdist_tmp_dir/objects" -type_listing_all="$__cdist_tmp_dir/types_all" -type_listing="$__cdist_tmp_dir/types" types_pushed="$__cdist_tmp_dir/types_pushed" touch "$types_pushed" From bdf3e4b86e752909575744b28b1e15a83b0f5479 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 22:09:19 +0100 Subject: [PATCH 14/29] prefix all variables with __cdist_ Signed-off-by: Steven Armstrong --- bin/cdist-object-run-all | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index 67c69154..14a6d9b3 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -32,49 +32,49 @@ set -eu __cdist_target_host="$1"; shift -object_listing="$__cdist_tmp_dir/objects" -types_pushed="$__cdist_tmp_dir/types_pushed" -touch "$types_pushed" +__cdist_objects="$__cdist_tmp_dir/objects" +__cdist_types_pushed="$__cdist_tmp_dir/types_pushed" +touch "$__cdist_types_pushed" # Get listing of objects -__cdist_object_list "$__cdist_out_object_dir" > "$object_listing" +__cdist_object_list "$__cdist_out_object_dir" > "$__cdist_objects" # NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP -while read object; do - set -- "$@" "$object" -done < "$object_listing" +while read __cdist_object; do + set -- "$@" "$__cdist_object" +done < "$__cdist_objects" while [ $# -gt 0 ]; do - object="$1"; shift + __cdist_object="$1"; shift - __cdist_type="$(__cdist_type_from_object "$object")" + __cdist_type="$(__cdist_type_from_object "$__cdist_object")" # Check if type of object has >= 1 explorer - has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" + __cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" # If so, run explorers on remote side - if [ "$has_explorer" ]; then + if [ "$__cdist_has_explorer" ]; then # Transfer the type explorers - if ! grep -q "$__cdist_type" "$types_pushed"; then + if ! grep -q "$__cdist_type" "$__cdist_types_pushed"; then cdist-type-explorer-push "$__cdist_target_host" "$__cdist_type" - echo "$__cdist_type" >> "$types_pushed" + echo "$__cdist_type" >> "$__cdist_types_pushed" fi # Run the type explorers for the current object - cdist-object-explorer-run "$__cdist_target_host" "$object" + cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" fi # Run the gencode scripts for the current object - cdist-object-gencode-run "$__cdist_target_host" "$object" + cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" # Transfer the current object to the target - cdist-object-push "$__cdist_target_host" "$object" + cdist-object-push "$__cdist_target_host" "$__cdist_object" # Run the code for the current object - cdist-object-code-run "$__cdist_target_host" "$object" + cdist-object-code-run "$__cdist_target_host" "$__cdist_object" done From 3d87f3f19a6de515923a74fcdd761bfcf3d76bf7 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 09:58:36 +0200 Subject: [PATCH 15/29] more ideas for future version Signed-off-by: Steven Armstrong --- doc/dev/logs/2011-03-28.execution-order | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 doc/dev/logs/2011-03-28.execution-order diff --git a/doc/dev/logs/2011-03-28.execution-order b/doc/dev/logs/2011-03-28.execution-order new file mode 100644 index 00000000..940da522 --- /dev/null +++ b/doc/dev/logs/2011-03-28.execution-order @@ -0,0 +1,14 @@ +run global explorers +run init manitest + +run all objects + -> depencies aufloesen wie/was/wo ???????? + run object + run explorer + run manifest + -> object liste wird evt veraendert + run gencode + run push -> target + run exec code + + From c5d8eaa63dd7f44990a2e4bf4fe282198adf1131 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 10:54:22 +0200 Subject: [PATCH 16/29] add stevens todo list Signed-off-by: Steven Armstrong --- doc/dev/todo/steven | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 doc/dev/todo/steven diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven new file mode 100644 index 00000000..5f91a198 --- /dev/null +++ b/doc/dev/todo/steven @@ -0,0 +1,16 @@ +- document object_id=$1 for manifest + gencode :-) + +- update docs regarding flow in cdist-stages.text +- create man pages for new executables +- nuke legacy manpages + +- prettify output of cdist-deploy-to, e.g. + +Processing object __file/etc/cdist-configured + transfering type explorers ... + running type explorers ... + running manifest ... + running gencode ... + transfering object to target ... + running code ... + From d7a607d54a9b595259408e2f3a60e7e1cf368568 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 11:22:25 +0200 Subject: [PATCH 17/29] update man pages for type explorer transfer and execution Signed-off-by: Steven Armstrong --- doc/man/cdist-object-explorer-all.text | 33 -------------------------- doc/man/cdist-object-explorer-run.text | 32 +++++++++++++++++++++++++ doc/man/cdist-type-explorer-push.text | 32 +++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 33 deletions(-) delete mode 100644 doc/man/cdist-object-explorer-all.text create mode 100644 doc/man/cdist-object-explorer-run.text create mode 100644 doc/man/cdist-type-explorer-push.text diff --git a/doc/man/cdist-object-explorer-all.text b/doc/man/cdist-object-explorer-all.text deleted file mode 100644 index dda3d30d..00000000 --- a/doc/man/cdist-object-explorer-all.text +++ /dev/null @@ -1,33 +0,0 @@ -cdist-object-explorer-all(1) -============================ -Nico Schottelius - - -NAME ----- -cdist-object-explorer-all - Run type explorer for every object - - -SYNOPSIS --------- -cdist-object-explorer-all HOSTNAME - - -DESCRIPTION ------------ -For every object, it checks whether the type has one or more explorers. -If so, the explorers of the type are copied to the target and executed -once per object. - - -SEE ALSO --------- -- cdist(7) -- cdist-deploy-to(1) -- cdist-remote-explorer-run(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). diff --git a/doc/man/cdist-object-explorer-run.text b/doc/man/cdist-object-explorer-run.text new file mode 100644 index 00000000..a94047c3 --- /dev/null +++ b/doc/man/cdist-object-explorer-run.text @@ -0,0 +1,32 @@ +cdist-object-explorer-run(1) +============================ +Nico Schottelius +Steven Armstrong + + +NAME +---- +cdist-object-explorer-run - Run type explorers for a object + + +SYNOPSIS +-------- +cdist-object-explorer-run HOSTNAME OBJECT + + +DESCRIPTION +----------- +Runs the explorers for the given object on the target host. + + +SEE ALSO +-------- +- cdist(7) +- cdist-deploy-to(1) +- cdist-remote-explorer-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). diff --git a/doc/man/cdist-type-explorer-push.text b/doc/man/cdist-type-explorer-push.text new file mode 100644 index 00000000..31da880c --- /dev/null +++ b/doc/man/cdist-type-explorer-push.text @@ -0,0 +1,32 @@ +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 269ad8c4325c6435c288cc3071f0e8c3949d6cbd Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 11:27:05 +0200 Subject: [PATCH 18/29] update man pages for object gencode generation Signed-off-by: Steven Armstrong --- doc/man/cdist-object-gencode-all.text | 32 -------------------------- doc/man/cdist-object-gencode-run.text | 33 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 32 deletions(-) delete mode 100644 doc/man/cdist-object-gencode-all.text create mode 100644 doc/man/cdist-object-gencode-run.text diff --git a/doc/man/cdist-object-gencode-all.text b/doc/man/cdist-object-gencode-all.text deleted file mode 100644 index b1c96748..00000000 --- a/doc/man/cdist-object-gencode-all.text +++ /dev/null @@ -1,32 +0,0 @@ -cdist-object-gencode-all(1) -=========================== -Nico Schottelius - - -NAME ----- -cdist-object-gencode-all - Generate code for every existing object - - -SYNOPSIS --------- -cdist-object-gencode-all HOSTNAME - - -DESCRIPTION ------------ -For every object that exists, the cdist-object-gencode is executed. - - -SEE ALSO --------- -- cdist(7) -- cdist-code-run(1) -- cdist-deploy-to(1) -- cdist-object-gencode(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). diff --git a/doc/man/cdist-object-gencode-run.text b/doc/man/cdist-object-gencode-run.text new file mode 100644 index 00000000..d69d1787 --- /dev/null +++ b/doc/man/cdist-object-gencode-run.text @@ -0,0 +1,33 @@ +cdist-object-gencode-run(1) +=========================== +Nico Schottelius +Steven Armstrong + + +NAME +---- +cdist-object-gencode-run - Generate code for a object + + +SYNOPSIS +-------- +cdist-object-gencode-run HOSTNAME OBJECT + + +DESCRIPTION +----------- +For the given object, generate the code for local and remote execution. + + +SEE ALSO +-------- +- cdist(7) +- cdist-code-run(1) +- cdist-object-run-all(1) +- cdist-object-gencode(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 70caac86e914eee4a0c969003a3be691d1bb5377 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:11:55 +0200 Subject: [PATCH 19/29] man page for cdist-object-push Signed-off-by: Steven Armstrong --- doc/man/cdist-object-push.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 doc/man/cdist-object-push.txt diff --git a/doc/man/cdist-object-push.txt b/doc/man/cdist-object-push.txt new file mode 100644 index 00000000..c4190e00 --- /dev/null +++ b/doc/man/cdist-object-push.txt @@ -0,0 +1,32 @@ +cdist-object-push(1) +============================ +Nico Schottelius +Steven Armstrong + + +NAME +---- +cdist-object-push - Transfer a object to the target host + + +SYNOPSIS +-------- +cdist-object-push HOSTNAME OBJECT + + +DESCRIPTION +----------- +Transfers the given object to the target host. + + +SEE ALSO +-------- +- cdist(7) +- cdist-object-run-all(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 2ee4f7e95207dfcb2b6cac9c0dabe99ba106e224 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:12:57 +0200 Subject: [PATCH 20/29] cdist-object-push.txt -> cdist-object-push.text Signed-off-by: Steven Armstrong --- doc/man/{cdist-object-push.txt => cdist-object-push.text} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/man/{cdist-object-push.txt => cdist-object-push.text} (100%) diff --git a/doc/man/cdist-object-push.txt b/doc/man/cdist-object-push.text similarity index 100% rename from doc/man/cdist-object-push.txt rename to doc/man/cdist-object-push.text From c680f3e81d45c6afd4d74ef3bacb86fb88e54ef3 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:21:45 +0200 Subject: [PATCH 21/29] added man page for cdist-object-run-all Signed-off-by: Steven Armstrong --- doc/man/cdist-object-run-all.text | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 doc/man/cdist-object-run-all.text diff --git a/doc/man/cdist-object-run-all.text b/doc/man/cdist-object-run-all.text new file mode 100644 index 00000000..c5163208 --- /dev/null +++ b/doc/man/cdist-object-run-all.text @@ -0,0 +1,38 @@ +cdist-object-run-all(1) +======================= +Nico Schottelius +Steven Armstrong + + +NAME +---- +cdist-object-run-all - Run all created objects on the target host + + +SYNOPSIS +-------- +cdist-object-run-all HOSTNAME + + +DESCRIPTION +----------- +Iterates over all objects and runs them on the given target host. +The different subtasks are dispatched to specialized exectuables. +See related man pages for details. + + +SEE ALSO +-------- +- cdist(7) +- cdist-type-explorer-push(1) +- cdist-object-explorer-run(1) +- cdist-object-gencode-run(1) +- cdist-object-push(1) +- cdist-object-code-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 a5633df809cc05c5a242e086f1e82ee9262fbf8b Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:23:52 +0200 Subject: [PATCH 22/29] fix asciidoc headers Signed-off-by: Steven Armstrong --- doc/man/cdist-object-push.text | 2 +- doc/man/cdist-type-explorer-push.text | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/man/cdist-object-push.text b/doc/man/cdist-object-push.text index c4190e00..69648a4d 100644 --- a/doc/man/cdist-object-push.text +++ b/doc/man/cdist-object-push.text @@ -1,5 +1,5 @@ cdist-object-push(1) -============================ +==================== Nico Schottelius Steven Armstrong diff --git a/doc/man/cdist-type-explorer-push.text b/doc/man/cdist-type-explorer-push.text index 31da880c..e32f10a4 100644 --- a/doc/man/cdist-type-explorer-push.text +++ b/doc/man/cdist-type-explorer-push.text @@ -1,5 +1,5 @@ cdist-type-explorer-push(1) -============================ +=========================== Nico Schottelius Steven Armstrong From 23e2fb82c7c725b097e34c4e36c197d1ef822a22 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:27:43 +0200 Subject: [PATCH 23/29] add man page for cdist-object-code-run Signed-off-by: Steven Armstrong --- doc/man/cdist-object-code-run.text | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 doc/man/cdist-object-code-run.text diff --git a/doc/man/cdist-object-code-run.text b/doc/man/cdist-object-code-run.text new file mode 100644 index 00000000..4d19b5eb --- /dev/null +++ b/doc/man/cdist-object-code-run.text @@ -0,0 +1,33 @@ +cdist-object-code-run(1) +======================== +Nico Schottelius +Steven Armstrong + + +NAME +---- +cdist-object-code-run - Execute the generated code for a object + + +SYNOPSIS +-------- +cdist-object-code-run HOSTNAME OBJECT + + +DESCRIPTION +----------- +Execute the local and remote code for the given object. + + +SEE ALSO +-------- +- cdist(7) +- cdist-object-run-all(1) +- cdist-code-run(1) +- cdist-run-remote(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 d56b7d19448282594047480936e7d976f4614eaa Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:29:46 +0200 Subject: [PATCH 24/29] remove legacy man pages Signed-off-by: Steven Armstrong --- doc/man/cdist-code-run-all.text | 32 -------------------------------- doc/man/cdist-run-remote.text | 2 +- 2 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 doc/man/cdist-code-run-all.text diff --git a/doc/man/cdist-code-run-all.text b/doc/man/cdist-code-run-all.text deleted file mode 100644 index fba2e7e3..00000000 --- a/doc/man/cdist-code-run-all.text +++ /dev/null @@ -1,32 +0,0 @@ -cdist-code-run-all(1) -===================== -Nico Schottelius - - -NAME ----- -cdist-code-run-all - Execute all generated code on the target - - -SYNOPSIS --------- -cdist-code-run-all HOSTNAME - - -DESCRIPTION ------------ -cdist-code-run-all is just a wrapper for cdist-remote-code-run-all. - - -SEE ALSO --------- -- cdist(7) -- cdist-deploy-to(1) -- cdist-remote-code-run-all(1) -- cdist-run-remote(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). diff --git a/doc/man/cdist-run-remote.text b/doc/man/cdist-run-remote.text index 6f06360f..ee7a6337 100644 --- a/doc/man/cdist-run-remote.text +++ b/doc/man/cdist-run-remote.text @@ -22,7 +22,7 @@ It ensures PATH is setup correctly on the target side. SEE ALSO -------- - cdist(7) -- cdist-code-run-all(1) +- cdist-object-code-run(1) - cdist-deploy-to(1) - cdist-remote-code-run-all(1) From 0f2193c5e3b731e4f92be2631e63c471d3f6a838 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:44:03 +0200 Subject: [PATCH 25/29] concentrate on iteration in cdist-object-run-all; move all execution code into new executable bin/cdist-object-run Signed-off-by: Steven Armstrong --- bin/cdist-object-run | 55 ++++++++++++++++++++++++++++++++++++++++ bin/cdist-object-run-all | 29 +++++---------------- 2 files changed, 61 insertions(+), 23 deletions(-) create mode 100755 bin/cdist-object-run diff --git a/bin/cdist-object-run b/bin/cdist-object-run new file mode 100755 index 00000000..44be01be --- /dev/null +++ b/bin/cdist-object-run @@ -0,0 +1,55 @@ +#!/bin/sh +# +# 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 . +# +# +# For the given object: +# - run type explorers +# - generate code +# - copy object to target +# - execute code on target +# + +. cdist-config +[ $# -eq 2 ] || __cdist_usage " " +set -eu + +__cdist_target_host="$1"; shift +__cdist_object="$1"; shift + + +__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")" + +# 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 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 14a6d9b3..3d2cb21c 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -19,11 +19,7 @@ # along with cdist. If not, see . # # -# For each created object: -# - run type explorers -# - generate code -# - copy object to target -# - execute code on target +# Run cdist-object-run for each created object. # . cdist-config @@ -49,32 +45,19 @@ done < "$__cdist_objects" while [ $# -gt 0 ]; do __cdist_object="$1"; shift - __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")" - # If so, run explorers on remote side + # Transfer the type explorers if any if [ "$__cdist_has_explorer" ]; then - # Transfer the type explorers 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 - - # Run the type explorers for the current object - cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" - + echo "$__cdist_type" >> "$__cdist_types_pushed" + fi fi - # 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" + # Process the given object + cdist-object-run "$__cdist_target_host" "$__cdist_object" done From 1c51d32cdca9a6372274ff8dedaf845222973712 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:45:16 +0200 Subject: [PATCH 26/29] add missing variable __cdist_type Signed-off-by: Steven Armstrong --- bin/cdist-object-run-all | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/cdist-object-run-all b/bin/cdist-object-run-all index 3d2cb21c..e95c7841 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-run-all @@ -45,6 +45,8 @@ done < "$__cdist_objects" while [ $# -gt 0 ]; do __cdist_object="$1"; shift + __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")" From 0726735f38623efe0b825644a45a8ce63ed889b8 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 28 Mar 2011 12:49:46 +0200 Subject: [PATCH 27/29] update man pages for cdist-object-run-all and cdist-object-run Signed-off-by: Steven Armstrong --- doc/man/cdist-object-run-all.text | 10 +++------ doc/man/cdist-object-run.text | 37 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 doc/man/cdist-object-run.text diff --git a/doc/man/cdist-object-run-all.text b/doc/man/cdist-object-run-all.text index c5163208..a3a8d56b 100644 --- a/doc/man/cdist-object-run-all.text +++ b/doc/man/cdist-object-run-all.text @@ -16,19 +16,15 @@ cdist-object-run-all HOSTNAME DESCRIPTION ----------- -Iterates over all objects and runs them on the given target host. -The different subtasks are dispatched to specialized exectuables. -See related man pages for details. +Transfers type explorers to the target then runs cdist-object-run(1) +for each created object. SEE ALSO -------- - cdist(7) - cdist-type-explorer-push(1) -- cdist-object-explorer-run(1) -- cdist-object-gencode-run(1) -- cdist-object-push(1) -- cdist-object-code-run(1) +- cdist-object-run(1) - cdist-type(1) diff --git a/doc/man/cdist-object-run.text b/doc/man/cdist-object-run.text new file mode 100644 index 00000000..b527c0e6 --- /dev/null +++ b/doc/man/cdist-object-run.text @@ -0,0 +1,37 @@ +cdist-object-run(1) +=================== +Nico Schottelius +Steven Armstrong + + +NAME +---- +cdist-object-run - Run an object + + +SYNOPSIS +-------- +cdist-object-run HOSTNAME OBJECT + + +DESCRIPTION +----------- +Runs the given object on the given target host. +The different subtasks are dispatched to specialized exectuables. +See related man pages for details. + + +SEE ALSO +-------- +- cdist(7) +- cdist-object-explorer-run(1) +- cdist-object-gencode-run(1) +- cdist-object-push(1) +- cdist-object-code-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 62c4f0d086d76f54a5cc63e5a8741d5f30a7691a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 15:16:48 +0200 Subject: [PATCH 28/29] ABORT if explorer fails, not only WARN Signed-off-by: Nico Schottelius --- bin/cdist-remote-explorer-run | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/cdist-remote-explorer-run b/bin/cdist-remote-explorer-run index 1fdd1467..028f8d7d 100755 --- a/bin/cdist-remote-explorer-run +++ b/bin/cdist-remote-explorer-run @@ -57,16 +57,16 @@ for explorer in "$__cdist_explorer_dir/"*; do if [ -f "$explorer" ]; then if [ ! -x "$explorer" ]; then - echo "Explorer \"$explorer\" exists, but is not executable." - continue + echo "Explorer \"$explorer\" exists, but is not executable." >&2 + exit 1 fi # Execute explorers and save results in remote destination directory "$explorer" > "${__cdist_my_out_dir}/$explorer_name" else if [ -e "$explorer" ]; then - echo "Explorer \"$explorer\" exists, but is not a file." - continue + echo "Explorer \"$explorer\" exists, but is not a file." >&2 + exit 1 fi fi done From 9bdba19d4a077641d8a797ff1ae7f1cca4d696b8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 15:20:58 +0200 Subject: [PATCH 29/29] prepend slash when using __object_id as name for __process Signed-off-by: Nico Schottelius --- conf/type/__process/explorer/runs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 240ebef9..2bfa8f84 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -24,7 +24,7 @@ if [ -f "$__object/parameter/name" ]; then name="$(cat "$__object/parameter/name")" else - name="$__object_id" + name="/$__object_id" fi pgrep -x -f "$name" || true