Shuffle functions into place
This commit is contained in:
parent
be6a9a1a73
commit
a7e0a2a1bf
4
commands
4
commands
@ -31,6 +31,10 @@ help_desc
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
vault-pass)
|
||||||
|
dokku-ansible-playbook-vault-pass-cmd "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||||
;;
|
;;
|
||||||
|
26
functions
26
functions
@ -4,19 +4,19 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|||||||
|
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
|
||||||
validate_dependencies() {
|
dokku-ansible-playbook-validate-dependencies() {
|
||||||
if ! command -v "ansible-playbook" &>/dev/null; then
|
if ! command -v "ansible-playbook" &>/dev/null; then
|
||||||
log-fail "Missing ansible-playbook, run dokku plugin:install-dependencies"
|
log-fail "Missing ansible-playbook, run dokku plugin:install-dependencies"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_playbook() {
|
dokku-ansible-playbook-run() {
|
||||||
local app="$1"
|
local app="$1"
|
||||||
local play_path="$2"
|
local play_path="$2"
|
||||||
local requirements="$3"
|
local requirements="$3"
|
||||||
local vault_file="$DOKKU_LIB/ansible/$app/.vault.sh"
|
local vault_file="$DOKKU_LIB/ansible/$app/.vault.sh"
|
||||||
|
|
||||||
validate_dependencies
|
dokku-ansible-playbook-validate-dependencies
|
||||||
|
|
||||||
if [[ ! -f "$play_path" ]]; then
|
if [[ ! -f "$play_path" ]]; then
|
||||||
dokku_col_log_info1_quiet "$play_path not found or executable bit not set"
|
dokku_col_log_info1_quiet "$play_path not found or executable bit not set"
|
||||||
@ -43,3 +43,23 @@ function run_playbook() {
|
|||||||
dokku_col_log_info1_quiet "running ansible-playbook with $args"
|
dokku_col_log_info1_quiet "running ansible-playbook with $args"
|
||||||
ansible-playbook "$args" "$play_path"
|
ansible-playbook "$args" "$play_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dokku-ansible-playbook-vault-pass-cmd() {
|
||||||
|
#shellcheck disable=SC2034
|
||||||
|
declare desc="insert new vault password for encrypt/decrypt of passwords"
|
||||||
|
|
||||||
|
if [[ -f "$DOKKU_LIB/data/ansible/.vault-pass" ]]; then
|
||||||
|
dokku_col_log_info1_quiet "Vault password already in place"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -srp "Vault password", vault_password
|
||||||
|
|
||||||
|
if [[ -d "$DOKKU_LIB/data/ansible" ]]; then
|
||||||
|
dokku_col_log_info1_quiet "Creating $DOKKU_LIB/data/ansible"
|
||||||
|
mkdir -p "$DOKKU_LIB/data/ansible"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dokku_col_log_info1_quiet "Generating $DOKKU_LIB/data/ansible/.vault-pass"
|
||||||
|
echo "$vault_password" > "$DOKKU_LIB/data/ansible/.vault-pass"
|
||||||
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|
||||||
|
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
||||||
|
|
||||||
cmd-ansible-default() {
|
|
||||||
declare desc="Run ansible playbooks during deployment"
|
|
||||||
local cmd="ansible"
|
|
||||||
dokku_log_fail "Missing command, please run 'dokku ansible:help'"
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd-ansible-default "$@"
|
|
@ -2,27 +2,6 @@
|
|||||||
|
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_AVAILABLE_PATH/ansible-playbook/functions"
|
||||||
|
|
||||||
cmd-ansible-vault-pass() {
|
dokku-ansible-playbook-vault-pass-cmd "$@"
|
||||||
#shellcheck disable=SC2034
|
|
||||||
declare desc="insert new vault password for encrypt/decrypt of passwords"
|
|
||||||
|
|
||||||
if [[ -f "$DOKKU_LIB/data/ansible/.vault-pass" ]]; then
|
|
||||||
dokku_col_log_info1_quiet "Vault password already in place"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -srp "Vault password", vault_password
|
|
||||||
|
|
||||||
if [[ -d "$DOKKU_LIB/data/ansible" ]]; then
|
|
||||||
dokku_col_log_info1_quiet "Creating $DOKKU_LIB/data/ansible"
|
|
||||||
mkdir -p "$DOKKU_LIB/data/ansible"
|
|
||||||
fi
|
|
||||||
|
|
||||||
dokku_col_log_info1_quiet "Generating $DOKKU_LIB/data/ansible/.vault-pass"
|
|
||||||
echo "$vault_password" > "$DOKKU_LIB/data/ansible/.vault-pass"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd-ansible-vault-pass "$@"
|
|
||||||
|
Reference in New Issue
Block a user