]> gitweb.fluxo.info Git - hydra.git/commitdiff
Deploy improvements: run newkeys, eyaml and check for ansible config
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 31 May 2018 01:40:43 +0000 (22:40 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 31 May 2018 01:40:43 +0000 (22:40 -0300)
share/hydra/deploy

index 070f8cd3f09aa0a0428103c73efce0373203ef5f..5e5a822b0594c02e3c67edb0a9c0ac85185f5ac4 100755 (executable)
@@ -66,6 +66,12 @@ for node in $NODES; do
     FOLDER=$node
     hydra_deploy_setup folder $FOLDER || continue
 
+    # Make sure keys exists for this node
+    hydra $HYDRA newkeys $FQDN
+
+    # Ensure key availability
+    hydra $HYDRA eyaml $FQDN
+
     if ! sudo -n true; then
       echo "Please set passwordless sudo on localhost."
       continue
@@ -117,6 +123,9 @@ for node in $NODES; do
     # Setup deploy environment
     hydra_deploy_setup || continue
 
+    # Make sure keys exists for this node
+    hydra $HYDRA newkeys $FQDN
+
     # Ensure key availability
     hydra $HYDRA eyaml $FQDN
 
@@ -153,6 +162,12 @@ for node in $NODES; do
     # Setup deploy environment
     hydra_deploy_setup remote $node || continue
 
+    # Make sure keys exists for this node
+    hydra $HYDRA newkeys $FQDN
+
+    # Ensure key availability
+    hydra $HYDRA eyaml $FQDN
+
     # Check for passwordless connections
     # http://stackoverflow.com/questions/3830508/check-if-passwordless-access-has-been-setup#3830680
     if ! $HYDRA_CONNECT -o NumberOfPasswordPrompts=0 $FQDN true; then
@@ -238,38 +253,39 @@ done
 #
 # Deploy using ansible own iterator
 #
-
-# Command line arguments
-NODES="$*"
-
-# Build node list
-#if [ -z "$NODES" ]; then
-#  #NODES="`BACKEND=ansible hydra $HYDRA nodes | xargs | sed -e "s/^/'~(/" -e "s/ /|/g" -e "s/$/)'/`"
-#  NODES="all"
-#else
-if [ ! -z "$NODES" ]; then
-  # Check if first param is a node name, otherwise assume its a class
-  if [ -z "$2" ]; then
-    NODES="`BACKEND=ansible hydra $HYDRA nodes $1`"
-
-    if [ -z "$NODES" ]; then
-      NODES="`BACKEND=ansible hydra $HYDRA nodes $1'*'`"
-    fi
-
-    # It's a class
-    if [ ! -z "$NODES" ] && [ "`echo $NODES | wc -w`" != "1" ]; then
-      #NODES="`echo $NODES | xargs | sed -e "s/^/'~(/" -e "s/ /|/g" -e "s/$/)'/"`"
-      NODES="$*"
+if [ -e "$HYDRA_FOLDER/ansible/ansible.cfg" ]; then
+  # Command line arguments
+  NODES="$*"
+
+  # Build node list
+  #if [ -z "$NODES" ]; then
+  #  #NODES="`BACKEND=ansible hydra $HYDRA nodes | xargs | sed -e "s/^/'~(/" -e "s/ /|/g" -e "s/$/)'/`"
+  #  NODES="all"
+  #else
+  if [ ! -z "$NODES" ]; then
+    # Check if first param is a node name, otherwise assume its a class
+    if [ -z "$2" ]; then
+      NODES="`BACKEND=ansible hydra $HYDRA nodes $1`"
+
+      if [ -z "$NODES" ]; then
+        NODES="`BACKEND=ansible hydra $HYDRA nodes $1'*'`"
+      fi
+
+      # It's a class
+      if [ ! -z "$NODES" ] && [ "`echo $NODES | wc -w`" != "1" ]; then
+        #NODES="`echo $NODES | xargs | sed -e "s/^/'~(/" -e "s/ /|/g" -e "s/$/)'/"`"
+        NODES="$*"
+      fi
     fi
+  else
+    NODES="all"
   fi
-else
-  NODES="all"
-fi
 
-if [ ! -z "$NODES" ]; then
-  if [ "$NODES" == "all" ]; then
-    hydra $HYDRA ansible-playbook site.yml
-  else
-    hydra $HYDRA ansible-playbook site.yml --limit $NODES
+  if [ ! -z "$NODES" ]; then
+    if [ "$NODES" == "all" ]; then
+      hydra $HYDRA ansible-playbook site.yml
+    else
+      hydra $HYDRA ansible-playbook site.yml --limit $NODES
+    fi
   fi
 fi