From 1c975d65f221eb78baf2808893c059091740da2a Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 13 Nov 2010 16:01:50 -0200 Subject: Initial deploy and module-update tasks --- share/hydra/deploy | 35 +++++++++++++++++++++++++++++++++++ share/hydra/mass | 9 ++++++--- share/hydra/module-update | 24 ++++++++++++++++++++++++ share/hydra/nodes | 13 ++++++++----- share/hydra/register | 4 ++-- 5 files changed, 75 insertions(+), 10 deletions(-) create mode 100755 share/hydra/module-update diff --git a/share/hydra/deploy b/share/hydra/deploy index a9bf588..81f29ca 100755 --- a/share/hydra/deploy +++ b/share/hydra/deploy @@ -1 +1,36 @@ #!/bin/bash +# +# Deploy hydra suite on multiple nodes. +# + +# Load +source $APP_BASE/lib/hydra/functions || exit 1 +hydra_config_load + +# Command line arguments +ORIGIN="$1" + +# Build node list +NODES="`hydra $HYDRA nodes`" + +# Validation +if [ -z "$ORIGIN" ]; then + ORIGIN="git://git.sarava.org/hydra.git" +fi + +# Deploy +# TODO: code signature +for node in $NODES; do + echo "Deploying to $node..." + ssh -o ConnectTimeout=15 $node < $TMPWORK @@ -14,15 +15,14 @@ function mass_pssh { # Issue commands with a for loop function mass_loop { for node in $NODES; do + echo "Issuing $COMMAND on multiple nodes..." echo "Connecting to $node..." ssh -o ConnectTimeout=15 $node $COMMAND done } -# Load functions +# Load source $APP_BASE/lib/hydra/functions || exit 1 - -# Load config hydra_config_load # Command line arguments @@ -34,6 +34,9 @@ if [ "$BASENAME" == "mass-update" ]; then COMMAND="sudo aptitude update" elif [ "$BASENAME" == "mass-update" ]; then COMMAND="sudo aptitude safe-upgrade" +elif [ "$BASENAME" == "mass-web" ]; then + echo "Currently not implemented." + exit 1 fi # Build node list diff --git a/share/hydra/module-update b/share/hydra/module-update new file mode 100755 index 0000000..3887bd2 --- /dev/null +++ b/share/hydra/module-update @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Update a puppet module +# + +# Load +source $APP_BASE/lib/hydra/functions || exit 1 +hydra_config_load + +# Command line arguments +MODULE="$1" + +# Validation +if [ -z "$MODULE" ]; then + echo "Usage: hydra module-update " + exit 1 +elif [ ! -d "$PUPPET/modules/$MODULE" ]; then + echo "No such module $MODULE at $HYDRA puppet configuration." + exit 1 +fi + +# Update the module +( cd $PUPPET/modules/$MODULE; git pull origin master ) +( cd $PUPPET; git commit -a -m "Updating module $MODULE"; git push ) diff --git a/share/hydra/nodes b/share/hydra/nodes index c7e4c4c..6b9d101 100755 --- a/share/hydra/nodes +++ b/share/hydra/nodes @@ -6,13 +6,16 @@ # Default node retrieval method function hydra_get_nodes { # See http://www.mail-archive.com/puppet-users@googlegroups.com/msg01615.html - grep ^node $* | sed -e 's/^node //' | awk -F, '{for(i=1;i<=NF;i++) {print $i}}' | cut -d "'" -f2 + if [ -d "$PUPPET/manifests/nodes/" ]; then + files="$PUPPET/manifests/nodes/*" + else + files="`find $PUPPET -name 'nodes.pp'`" + fi + grep ^node $files | sed -e 's/^node //' | awk -F, '{for(i=1;i<=NF;i++) {print $i}}' | cut -d "'" -f2 } -# Load functions +# Load source $APP_BASE/lib/hydra/functions || exit 1 - -# Load config hydra_config_load # Validation @@ -22,4 +25,4 @@ if [ -z "$PUPPET" ]; then fi # Get nodes -hydra_get_nodes $PUPPET/manifests/nodes/* +hydra_get_nodes diff --git a/share/hydra/register b/share/hydra/register index e3d3ed6..40a1390 100755 --- a/share/hydra/register +++ b/share/hydra/register @@ -3,8 +3,9 @@ # Register an existing hydra # -# Load functions +# Load source $APP_BASE/lib/hydra/functions || exit 1 +hydra_config_load # Command line arguments BASEDIR="$1" @@ -25,7 +26,6 @@ BASEDIR="`cd $BASEDIR && pwd`" echo "Registering hydra $HYDRA..." mkdir -p $BASEDIR chmod 700 $BASEDIR -hydra_config_load echo "$HYDRA=\"$BASEDIR\"" >> $CONFIG # Puppet configuration -- cgit v1.2.3