2020-03-19 00:43:41 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|
|
|
|
2020-03-19 22:45:06 +00:00
|
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
|
|
|
2020-03-20 00:00:19 +00:00
|
|
|
|
2020-03-19 00:43:41 +00:00
|
|
|
function run_playbook() {
|
2020-03-19 23:11:35 +00:00
|
|
|
local app="$1"
|
|
|
|
local play_path="$2"
|
|
|
|
local requirements="$3"
|
2020-03-19 00:43:41 +00:00
|
|
|
|
2020-03-20 00:00:19 +00:00
|
|
|
export ANSIBLE_ROLES_PATH="$DOKKU_LIB_ROOT/data/ansible/$APP/roles"
|
|
|
|
export ANSIBLE_LIBRARY="$DOKKU_LIB_ROOT/data/ansible/$APP/roles/*/library"
|
|
|
|
|
2020-03-19 01:05:30 +00:00
|
|
|
if [[ ! -f "$play_path" ]]; then
|
2020-03-19 22:42:53 +00:00
|
|
|
dokku_col_log_info1_quiet "$play_path not found or executable bit not set"
|
2020-03-19 00:43:41 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-03-19 01:19:57 +00:00
|
|
|
if [[ -f "$requirements" ]]; then
|
2020-03-19 22:42:53 +00:00
|
|
|
dokku_col_log_info1_quiet "$requirements file found"
|
2020-03-20 00:02:52 +00:00
|
|
|
dokku_col_log_info1_quiet "Using $ANSIBLE_ROLES_PATH as role path"
|
2020-03-19 23:16:59 +00:00
|
|
|
ansible-galaxy \
|
2020-03-19 23:15:45 +00:00
|
|
|
install \
|
2020-03-19 23:45:06 +00:00
|
|
|
--force \
|
2020-03-20 00:02:52 +00:00
|
|
|
--roles-path "$ANSIBLE_ROLES_PATH" \
|
2020-03-19 23:11:35 +00:00
|
|
|
--role-file "$requirements"
|
2020-03-19 00:43:41 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-19 22:42:53 +00:00
|
|
|
dokku_col_log_info1_quiet "$play_path file found"
|
2020-03-20 00:02:52 +00:00
|
|
|
dokku_col_log_info1_quiet "Using $ANSIBLE_LIBRARY as module path"
|
2020-03-19 23:15:45 +00:00
|
|
|
ansible-playbook \
|
2020-03-19 23:11:35 +00:00
|
|
|
--inventory "$(hostname)", \
|
|
|
|
--connection local \
|
2020-03-20 00:00:19 +00:00
|
|
|
--module-path "$ANSIBLE_LIBRARY" \
|
|
|
|
"$play_path"
|
2020-03-19 00:43:41 +00:00
|
|
|
}
|