diff options
Diffstat (limited to 'share')
-rwxr-xr-x | share/hydra/deploy | 35 | ||||
-rwxr-xr-x | share/hydra/mass | 9 | ||||
-rwxr-xr-x | share/hydra/module-update | 24 | ||||
-rwxr-xr-x | share/hydra/nodes | 13 | ||||
-rwxr-xr-x | share/hydra/register | 4 |
5 files changed, 75 insertions, 10 deletions
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 <<EOF + ##### BEGIN REMOTE SCRIPT ##### + if [ ! -d /usr/local/hydra ]; then + sudo git clone $ORIGIN /usr/local/hydra + sudo ln -s /usr/local/hydra/hydra /usr/local/sbin/hydra + sudo ln -s /usr/local/hydra/hydra /usr/local/sbin/hydractl + else + ( cd /usr/local/hydra && sudo git pull ) + fi + ##### END REMOTE SCRIPT ####### +EOF +done diff --git a/share/hydra/mass b/share/hydra/mass index 410e36d..06447c2 100755 --- a/share/hydra/mass +++ b/share/hydra/mass @@ -4,6 +4,7 @@ # # Issue commands with pssh +# See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549117 function mass_pssh { hydra_set_tmpfile nodes hydra $HYDRA nodes > $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 <hydra> module-update <module>" + 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 |