Refactor options usage

This commit is contained in:
Luke Murphy 2020-03-21 01:47:43 +01:00
parent e8458d041a
commit 4059039bc3
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -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"
}