]> gitweb.fluxo.info Git - hydra.git/commitdiff
Adding newkeys subcommand from keyringer
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 21 Nov 2010 19:07:50 +0000 (17:07 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 21 Nov 2010 19:07:50 +0000 (17:07 -0200)
lib/hydra/misc
share/hydra/newkeys [new file with mode: 0755]

index 77f717d648bff2022f6a56d44e0d5b957a1a01ef..fd90e93cf0486ef5eb39ebc5c66575bdfd01fb22 100644 (file)
@@ -39,6 +39,10 @@ function hydra_check_preferences {
     echo "Puppet folder not found: $PUPPET."
     exit 1
   fi
+
+  if [ -z "$PUPPET_KEYS" ]; then
+    PUPPET_KEYS="$PUPPET/files/keys"
+  fi
 }
 
 # Load a parameter from config
diff --git a/share/hydra/newkeys b/share/hydra/newkeys
new file mode 100755 (executable)
index 0000000..4970afb
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Create keys for new nodes.
+#
+
+function hydra_newkeys {
+  # Generates ssh and gpg keys for new nodes
+  # GPG keys should be manually imported in the nodes
+  for host in `hydra $HYDRA nodes`; do
+    node="`echo $host | cut -d . -f 1`"
+    privkey="$PUPPET_KEYS/"$node"_id_dsa"
+    pubkey="$privkey.pub"
+    if [ ! -e "$privkey" ] || [ ! -e "$pubkey" ]; then
+      keyringer $HYDRA genpair ssh $node/ssh/id_dsa $host $privkey
+      keyringer $HYDRA genpair gpg $node/gpg/key    $host
+
+      # Add key into puppet git repository.
+      ( cd $PUPPET_KEYS && git add $privkey $pubkey )
+    fi
+  done
+}
+
+# Load.
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+# Check for keyringer.
+if ! which keyringer &> /dev/null; then
+  echo "Error: please install keyringer."
+  exit 1
+fi
+
+hydra_newkeys