diff --git a/.travis.yml b/.travis.yml index 0aa29ef..f5a1318 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,5 +45,10 @@ script: # Check PostgreSQL status. - 'docker exec -u postgres "$(cat ${container_id})" pg_ctl -D /var/lib/pgsql/data status' +after_failure: + # Check what happened on systemd systems. + - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm systemctl -l status postgresql.service' + - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm journalctl -xe --no-pager' + notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/tasks/initialize.yml b/tasks/initialize.yml index 2d044df..6df7a87 100644 --- a/tasks/initialize.yml +++ b/tasks/initialize.yml @@ -1,4 +1,10 @@ --- +- name: Set PGDATA environment variable. + template: + src: postgres.sh.j2 + dest: /etc/profile.d/postgres.sh + mode: 0644 + - name: Ensure PostgreSQL data directory exists. file: path: "{{ postgresql_data_dir }}" @@ -14,6 +20,6 @@ - name: Ensure PostgreSQL database is initialized. command: "initdb -D {{ postgresql_data_dir }}" - when: pgdata_dir_version.stat.exists + when: not pgdata_dir_version.stat.exists become: yes become_user: "{{ postgresql_user }}" diff --git a/templates/postgres.sh.j2 b/templates/postgres.sh.j2 new file mode 100644 index 0000000..4a2ad5b --- /dev/null +++ b/templates/postgres.sh.j2 @@ -0,0 +1 @@ +export PGDATA={{ postgresql_data_dir }}