]> gitweb.fluxo.info Git - hydra.git/commitdiff
Deploy: import keys if needed
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 23 May 2018 19:45:09 +0000 (16:45 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 23 May 2018 19:45:09 +0000 (16:45 -0300)
TODO.md
share/hydra/deploy

diff --git a/TODO.md b/TODO.md
index 43149472ff8cb88dfcb2f6ba339d98ad842aeefa..be5e2c2ceb5fc606e1c34ef0bb03b445f5d820f6 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -7,4 +7,3 @@ TODO
 * hydra:
   * deploy:
     * manage ansible package at local machine
-    * check if server needs import-keys, or always import them
index 32dc700d57ad94c7cdea97ef3ad83bd1635b516c..63ff54e8c96f6da74dd4eba4e3b8ffaa72cfd0f3 100755 (executable)
@@ -84,6 +84,11 @@ for node in $NODES; do
     echo "Applying configuration..."
     LC_ALL=C HOSTNAME=$FQDN FACTER_domain=$DOMAIN FACTER_hostname=$FQDN FACTER_fqdn=$HOSTNAME.$DOMAIN $DEPLOY_APPLY 2>&1 | \
       tee $HYDRA_FOLDER/puppet/logs/$FQDN.`date +%Y%m%d%H%M`.log
+
+    # Check if keys should be imported
+    if ! $SUDO test -f $FOLDER/root/.ssh/id_rsa; then
+      echo "No $FOLDER/root/.ssh/id_rsa found. Please import it and other keys when the system is online using import-keys action"
+    fi
   elif [ "$node" == "localhost" ] || [ "$node" == "`facter fqdn`" ] || [ "$node" == "`facter hostname`" ]; then
     echo "Deploying to localhost..."
 
@@ -118,6 +123,11 @@ for node in $NODES; do
 
     # Fix ssl folder ownership
     $SUDO chown -R `whoami`. $HYDRA_FOLDER/puppet/ssl
+
+    # Import keys if needed
+    if ! $SUDO test -f /root/.ssh/id_rsa; then
+      hydra $HYDRA import-keys localhost
+    fi
   else
     echo "Deploying to $node..."
 
@@ -196,5 +206,10 @@ EOF
     echo "Applying configuration..."
     $DEPLOY_APPLY 2>&1 | \
       tee $HYDRA_FOLDER/puppet/logs/$FQDN.`date +%Y%m%d%H%M`.log
+
+    # Import keys if needed
+    if ! $HYDRA_CONNECT $FQDN sudo test -f /root/.ssh/id_rsa; then
+      hydra $HYDRA import-keys localhost
+    fi
   fi
 done