From 2c710186996f40b2e7ef1182ddd176897d3abdb2 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 26 Mar 2011 01:52:15 +0100 Subject: [PATCH] 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"