From 4059039bc38bed91654b2609d5249982c6317364 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 21 Mar 2020 01:47:43 +0100 Subject: [PATCH] Refactor options usage --- functions | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/functions b/functions index 115a901..e1e6fb3 100755 --- a/functions +++ b/functions @@ -14,7 +14,7 @@ function run_playbook() { local app="$1" local play_path="$2" local requirements="$3" - local vault_file="$DOKKU_LIB/ansible/$APP/.vault.sh" + local vault_file="$DOKKU_LIB/ansible/$app/.vault.sh" validate_dependencies @@ -32,19 +32,13 @@ function run_playbook() { mkdir -p $DOKKU_ROOT/.ansible/{roles,plugins/modules} cp -R $DOKKU_ROOT/.ansible/roles/*/library/* $DOKKU_ROOT/.ansible/plugins/modules + local args="--inventory "$(hostname)", --connection local" + if [[ -f "$vault_file" ]]; then - dokku_col_log_info1_quiet "$play_path file found" dokku_col_log_info1_quiet "$vault_file file found" - ansible-playbook \ - --inventory "$(hostname)", \ - --connection local \ - --vault-password-file "$vault_file" - "$play_path" - else - dokku_col_log_info1_quiet "$play_path file found" - ansible-playbook \ - --inventory "$(hostname)", \ - --connection local \ - "$play_path" + args+="--vault-password-file \"$vault_file\"" fi + + dokku_col_log_info1_quiet "$play_path file found" + ansible-playbook "$args" "$play_path" }