Add vault support

This commit is contained in:
Luke Murphy 2020-03-21 01:22:21 +01:00
parent 76f4e61c09
commit a5f6e53539
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 22 additions and 3 deletions

View File

@ -14,6 +14,7 @@ function run_playbook() {
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"
validate_dependencies validate_dependencies
@ -31,6 +32,19 @@ function run_playbook() {
mkdir -p $DOKKU_ROOT/.ansible/{roles,plugins/modules} mkdir -p $DOKKU_ROOT/.ansible/{roles,plugins/modules}
cp -R $DOKKU_ROOT/.ansible/roles/*/library/* $DOKKU_ROOT/.ansible/plugins/modules cp -R $DOKKU_ROOT/.ansible/roles/*/library/* $DOKKU_ROOT/.ansible/plugins/modules
if [[ -f "$vault_file" ]]; then
dokku_col_log_info1_quiet "$play_path file found" dokku_col_log_info1_quiet "$play_path file found"
ansible-playbook --inventory "$(hostname)", --connection local "$play_path" dokku_col_log_info1_quiet "$vault_file file found"
ansible-playbook \
--inventory "$(hostname)", \
--connection local \
--vault-password-file "$vault_file"
"$play_path"
else
dokku_col_log_info1_quiet "$play_path file found"
ansible-playbook \
--inventory "$(hostname)", \
--connection local \
"$play_path"
fi
} }

View File

@ -10,7 +10,12 @@ dokku-ansible-playbook-post-extract() {
dokku_col_log_info1_quiet "Checking for ansible playbooks supplied in repo" dokku_col_log_info1_quiet "Checking for ansible playbooks supplied in repo"
if [[ -d "$TMPDIR/ansible" ]] && [[ "$(ls -A "$TMPDIR/ansible")" ]]; then if [[ -d "$TMPDIR/ansible" ]] && [[ "$(ls -A "$TMPDIR/ansible")" ]]; then
mkdir -p "$DOKKU_LIB_ROOT/data/ansible/$APP" mkdir -p "$DOKKU_LIB_ROOT/data/ansible/$APP"
cp -r "$TMPDIR/ansible/." "$DOKKU_LIB_ROOT/data/ansible/$APP" cp -r "$TMPDIR/ansible/*.yml" "$DOKKU_LIB_ROOT/data/ansible/$APP"
if [[ -f "$TMPDIR/ansible/.vault.sh" ]]; then
dokku_col_log_info1_quiet "Moving vault password file into place"
cp -r "$TMPDIR/ansible/.vault.sh" "$DOKKU_LIB_ROOT/data/ansible/$APP"
chmod 600 "$DOKKU_LIB_ROOT/data/ansible/$APP/.vault.sh"
fi
fi fi
} }