From: Silvio Rhatto Date: Sat, 16 Jun 2018 14:51:03 +0000 (-0300) Subject: Set ansible_user X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=07a0dfa4a63e7a5b00452907c93562d6a82fdbfd;p=hydra.git Set ansible_user --- diff --git a/share/hydra/ansible b/share/hydra/ansible index ee46169..a76b80f 100755 --- a/share/hydra/ansible +++ b/share/hydra/ansible @@ -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 diff --git a/share/hydra/deploy b/share/hydra/deploy index 0392f63..da3357b 100755 --- a/share/hydra/deploy +++ b/share/hydra/deploy @@ -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