]> gitweb.fluxo.info Git - hydra.git/commitdiff
Set ansible_user
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 16 Jun 2018 14:51:03 +0000 (11:51 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 16 Jun 2018 14:51:03 +0000 (11:51 -0300)
share/hydra/ansible
share/hydra/deploy

index ee461695405a75bf6a1dd988161f9283d7ce0b56..a76b80f4f01f7c236c74b6e81b755dcdfef4216c 100755 (executable)
@@ -37,6 +37,6 @@ if [ -d "$HYDRA_FOLDER/ansible" ]; then
 
   (
   cd $HYDRA_FOLDER/ansible
-  ANSIBLE_CONFIG=ansible.cfg $BASENAME -i inventories $*
+  ANSIBLE_CONFIG=ansible.cfg $BASENAME -i inventories "$@"
   )
 fi
index 0392f630268b6fc2d151300b564a352e867b969b..da3357bc63d43057cc5a00030185df437716141c 100755 (executable)
@@ -285,11 +285,20 @@ if [ -e "$HYDRA_FOLDER/ansible/ansible.cfg" ]; then
     NODES="all"
   fi
 
+  # Build ansible args
+  if [ ! -z "$SSH_USER" ]; then
+    # Avoid ESTABLISH SSH CONNECTION FOR USER: None
+    # See https://stackoverflow.com/questions/35024576/establish-ssh-connection-for-user-none-when-specify-a-single-host-on-the-comman#40610316
+    ANSIBLE_ARGS="-e ansible_user=$SSH_USER"
+  else
+    ANSIBLE_ARGS="-e ansible_user=`whoami`"
+  fi
+
   if [ ! -z "$NODES" ]; then
     if [ "$NODES" == "all" ]; then
-      hydra $HYDRA ansible-playbook site.yml
+      hydra $HYDRA ansible-playbook site.yml $ANSIBLE_ARGS
     else
-      hydra $HYDRA ansible-playbook site.yml --limit $NODES
+      hydra $HYDRA ansible-playbook site.yml $ANSIBLE_ARGS --limit $NODES
     fi
   fi
 fi