Copy/Pasta supply-config setup

This commit is contained in:
Luke Murphy 2020-03-19 23:42:53 +01:00
parent 608fc38114
commit 50b2c86429
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
5 changed files with 38 additions and 21 deletions

View File

@ -5,6 +5,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
if ! command -v "ansible" &>/dev/null; then if ! command -v "ansible" &>/dev/null; then
echo "-----> installing ansible" dokku_col_log_info1_quiet "installing ansible"
apt install -qq -y ansible apt install -qq -y ansible
fi fi

View File

@ -7,15 +7,15 @@ function run_playbook() {
local requirements="$2" local requirements="$2"
if [[ ! -f "$play_path" ]]; then 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 exit 0
fi fi
if [[ -f "$requirements" ]]; then if [[ -f "$requirements" ]]; then
echo "-----> $requirements file found" dokku_col_log_info1_quiet "$requirements file found"
ansible-galaxy install -fr "$requirements" ansible-galaxy install -fr "$requirements"
fi 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" ansible-playbook -i 127.0.0.1, -c local "$play_path"
} }

View File

@ -2,11 +2,16 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1" dokku-ansible-playbook-post-deploy() {
PLAYBOOK="$DOKKU_LIB_ROOT/data/ansible/$APP/post-deploy.yml" declare APP="$1"
REQUIREMENTS="$DOKKU_LIB_ROOT/data/ansible/$APP/requirements.yml" 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" dokku_col_log_info1_quiet "Running post-deploy ansible playbook"
run_playbook "$PLAYBOOK" "$REQUIREMENTS"
run_playbook "$PLAYBOOK" "$REQUIREMENTS"
}
dokku-ansible-playbook-post-deploy "$@"

View File

@ -4,11 +4,18 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; verify_app_name "$APP" dokku-ansible-playbook-post-extract() {
TMP_WORK_DIR="$2" 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 "$@"

View File

@ -2,11 +2,16 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1" dokku-ansible-playbook-pre-deploy() {
PLAYBOOK="$DOKKU_LIB_ROOT/data/ansible/$APP/pre-deploy.yml" declare APP="$1"
REQUIREMENTS="$DOKKU_LIB_ROOT/data/ansible/$APP/requirements.yml" 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" dokku_col_log_info1_quiet "Running pre-deploy ansible playbook"
run_playbook "$PLAYBOOK" "$REQUIREMENTS"
run_playbook "$PLAYBOOK" "$REQUIREMENTS"
}
dokku-ansible-playbook-pre-deploy "$@"