From 07a0dfa4a63e7a5b00452907c93562d6a82fdbfd Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 16 Jun 2018 11:51:03 -0300 Subject: Set ansible_user --- share/hydra/ansible | 2 +- share/hydra/deploy | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) 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 -- cgit v1.2.3