diff --git a/dependencies b/dependencies index 855809a..2636300 100755 --- a/dependencies +++ b/dependencies @@ -5,6 +5,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x export DEBIAN_FRONTEND=noninteractive if ! command -v "ansible" &>/dev/null; then - echo "-----> installing ansible" + dokku_col_log_info1_quiet "installing ansible" apt install -qq -y ansible fi diff --git a/functions b/functions index 8a030f3..94d3518 100755 --- a/functions +++ b/functions @@ -7,15 +7,15 @@ function run_playbook() { local requirements="$2" if [[ ! -f "$play_path" ]]; then - echo "-----> $play_path not found or executable bit not set" + dokku_col_log_info1_quiet "$play_path not found or executable bit not set" exit 0 fi if [[ -f "$requirements" ]]; then - echo "-----> $requirements file found" + dokku_col_log_info1_quiet "$requirements file found" ansible-galaxy install -fr "$requirements" fi - echo "-----> $play_path file found" + dokku_col_log_info1_quiet "$play_path file found" ansible-playbook -i 127.0.0.1, -c local "$play_path" } diff --git a/post-deploy b/post-deploy index f0c0ca7..8b048b3 100755 --- a/post-deploy +++ b/post-deploy @@ -2,11 +2,16 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -APP="$1" -PLAYBOOK="$DOKKU_LIB_ROOT/data/ansible/$APP/post-deploy.yml" -REQUIREMENTS="$DOKKU_LIB_ROOT/data/ansible/$APP/requirements.yml" +dokku-ansible-playbook-post-deploy() { + declare APP="$1" + declare PLAYBOOK="$DOKKU_LIB_ROOT/data/ansible/$APP/post-deploy.yml" + declare REQUIREMENTS="$DOKKU_LIB_ROOT/data/ansible/$APP/requirements.yml" -. $(dirname "$0")/functions + . $(dirname "$0")/functions -echo "-----> Running post-deploy ansible playbook" -run_playbook "$PLAYBOOK" "$REQUIREMENTS" + dokku_col_log_info1_quiet "Running post-deploy ansible playbook" + + run_playbook "$PLAYBOOK" "$REQUIREMENTS" +} + +dokku-ansible-playbook-post-deploy "$@" diff --git a/post-extract b/post-extract index ba820da..5cfad5d 100755 --- a/post-extract +++ b/post-extract @@ -4,11 +4,18 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -APP="$1"; verify_app_name "$APP" -TMP_WORK_DIR="$2" +dokku-ansible-playbook-post-extract() { + declare APP="$1" TMPDIR="$2" -pushd "$TMP_WORK_DIR" >/dev/null + dokku_col_log_info1_quiet "Checking for ansible playbooks supplied in repo" -cp -r "ansible/*" "$DOKKU_LIB_ROOT/data/ansible/$APP" + if [[ -d "$TMPDIR/ansible" ]] && [[ "$(ls -A "$TMPDIR/ansible")" ]]; then + mkout=$(mkdir -p "$DOKKU_LIB_ROOT/data/ansible/$APP") + dokku_log_verbose_quiet "$mkout" -popd >/dev/null + cpout=$(cp -r "$TMPDIR/ansible/." "$DOKKU_LIB_ROOT/data/ansible/$APP") + dokku_log_verbose_quiet "$cpout" + fi +} + +dokku-ansible-playbook-post-extract "$@" diff --git a/pre-deploy b/pre-deploy index 8130eb7..6b4ef93 100755 --- a/pre-deploy +++ b/pre-deploy @@ -2,11 +2,16 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -APP="$1" -PLAYBOOK="$DOKKU_LIB_ROOT/data/ansible/$APP/pre-deploy.yml" -REQUIREMENTS="$DOKKU_LIB_ROOT/data/ansible/$APP/requirements.yml" +dokku-ansible-playbook-pre-deploy() { + declare APP="$1" + declare PLAYBOOK="$DOKKU_LIB_ROOT/data/ansible/$APP/pre-deploy.yml" + declare REQUIREMENTS="$DOKKU_LIB_ROOT/data/ansible/$APP/requirements.yml" -. $(dirname "$0")/functions + . $(dirname "$0")/functions -echo "-----> Running pre-deploy ansible playbook" -run_playbook "$PLAYBOOK" "$REQUIREMENTS" + dokku_col_log_info1_quiet "Running pre-deploy ansible playbook" + + run_playbook "$PLAYBOOK" "$REQUIREMENTS" +} + +dokku-ansible-playbook-pre-deploy "$@"