]> gitweb.fluxo.info Git - hydra.git/commitdiff
Initial deploy and module-update tasks
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 13 Nov 2010 18:01:50 +0000 (16:01 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 13 Nov 2010 18:01:50 +0000 (16:01 -0200)
share/hydra/deploy
share/hydra/mass
share/hydra/module-update [new file with mode: 0755]
share/hydra/nodes
share/hydra/register

index a9bf588e2f88457fdf73ac7361ef1d596fb81453..81f29ca54115cbda2e42f89640acee517a631364 100755 (executable)
@@ -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
index 410e36d2baca114d8177c1a020f2e21189776e94..06447c2aa3a863acb38e77b28f16ab039ea6f8c2 100755 (executable)
@@ -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 (executable)
index 0000000..3887bd2
--- /dev/null
@@ -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 )
index c7e4c4cb78c8c0f8cde8a37624b55bf9159e143b..6b9d1012a0ae205b765dd8e7d5b72342ee8f6c74 100755 (executable)
@@ -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
index e3d3ed641d04f776c681d276d8f82ce0d46856ca..40a139085e18d28412ee53fabb55d2816b1315da 100755 (executable)
@@ -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