forked from ungleich-public/cdist
		
	migrate to new workflow
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								0dab5b5f7e
							
						
					
				
			
			
				commit
				
					
						2c71018699
					
				
			
		
					 4 changed files with 0 additions and 212 deletions
				
			
		| 
						 | 
					@ -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 <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Exec code locally and remote
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 1 ] || __cdist_usage "<target host>"
 | 
					 | 
				
			||||||
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"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -50,21 +50,6 @@ cdist-dir push "$__cdist_target_host" "${__cdist_abs_mydir}" "${__cdist_remote_b
 | 
				
			||||||
cdist-explorer-run-global     "$__cdist_target_host"
 | 
					cdist-explorer-run-global     "$__cdist_target_host"
 | 
				
			||||||
cdist-manifest-run-init       "$__cdist_target_host"
 | 
					cdist-manifest-run-init       "$__cdist_target_host"
 | 
				
			||||||
cdist-manifest-run-all        "$__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"
 | 
					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"
 | 
					echo "cdist $__cdist_version: Successfully finished run on $__cdist_target_host"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# For each created object check the explorers and run them if needed.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 1 ] || __cdist_usage "<target host>"
 | 
					 | 
				
			||||||
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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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 <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# For each created object create the code to be executed on the target.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 1 ] || __cdist_usage "<target host>"
 | 
					 | 
				
			||||||
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"
 | 
					 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue