diff --git a/functions b/functions index 766a747..0a573e7 100755 --- a/functions +++ b/functions @@ -2,21 +2,20 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -REQUIREMENTS=".ansible/requirements.yml" - function run_playbook() { local play_path="$1" + local requirements="$2" if [[ ! -f "$play_path" ]]; then - echo " $play_path not found or executable bit not set. Skipping ..." + echo " $play_path not found or executable bit not set" exit 0 fi - if [[ -f "$REQUIREMENTS" ]]; then - echo " $REQUIREMENTS file found. Running it ..." - ansible-galaxy install -fvf "$REQUIREMENTS" + if [[ -f "$requirements" ]]; then + echo " $requirements file found" + ansible-galaxy install -fvf "$requirements" fi - echo " $play_path file found. Running it ..." - ansible-playbook -i 127.0.0.1, --connection local -v "$play_path" + echo " $play_path file found" + ansible-playbook -i 127.0.0.1, -c local -v "$play_path" } diff --git a/post-deploy b/post-deploy index 07971d0..01cfa71 100755 --- a/post-deploy +++ b/post-deploy @@ -2,8 +2,10 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -PLAYBBOOK=".ansible/post-deploy.yml" +APP="$1" +PLAYBOOK="$DOKKU_ROOT/$APP/ansible/post-deploy.yml" +REQUIREMENTS="$DOKKU_ROOT/$APP/ansible/requirements.yml" echo "-----> Running post-deploy ansible playbook" . $(dirname "$0")/functions -run_playbook "$PLAYBOOK" +run_playbook "$PLAYBOOK" "$REQUIREMENTS" diff --git a/pre-deploy b/pre-deploy index 3ec5ccd..ee44478 100755 --- a/pre-deploy +++ b/pre-deploy @@ -2,8 +2,10 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -PLAYBBOOK=".ansible/pre-deploy.yml" +APP="$1" +PLAYBOOK="$DOKKU_ROOT/$APP/ansible/post-deploy.yml" +REQUIREMENTS="$DOKKU_ROOT/$APP/ansible/requirements.yml" echo "-----> Running pre-deploy ansible playbook" . $(dirname "$0")/functions -run_playbook "$PLAYBOOK" +run_playbook "$PLAYBOOK" "$REQUIREMENTS"