diff --git a/tasks/config.yml b/tasks/config.yml index 93a1958..9cb9943 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -23,10 +23,14 @@ with_fileglob: - 'templates/init/*.sql' -- name: 'Create compose file' +- name: Install PostgreSQL client + apt: + name: 'postgresql-client' + +- name: Create Admin wrapper script template: - src: 'docker-compose.yml.j2' - dest: '{{ postgres_ha_compose_file }}' - owner: 'dockremap' + src: 'scripts/admin.sh.j2' + dest: '{{ postgres_ha_service_path }}/admin.sh' + owner: 'root' group: 'docker' - mode: 0644 + mode: 0750 diff --git a/tasks/start.yml b/tasks/start.yml index a54dd27..fa465df 100644 --- a/tasks/start.yml +++ b/tasks/start.yml @@ -1,4 +1,12 @@ --- +- name: 'Create compose file' + template: + src: 'docker-compose.yml.j2' + dest: '{{ postgres_ha_compose_file }}' + owner: 'dockremap' + group: 'docker' + mode: 0644 + - name: 'Create database container' docker_compose: project_src: '{{ postgres_ha_service_path }}' diff --git a/templates/scripts/admin.sh.j2 b/templates/scripts/admin.sh.j2 new file mode 100644 index 0000000..ab03790 --- /dev/null +++ b/templates/scripts/admin.sh.j2 @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# vim: set ft=sh: +set -Eeo pipefail +export PGPASSWORD='{{ postgres_ha_admin_pass }}' +exec psql \ + --host='127.0.0.1' \ + --port='{{ postgres_ha_cont_port }}' \ + --username='{{ postgres_ha_admin_user }}' \ + --dbname='{{ postgres_ha_db_name }}' \ + ${@}