2016-09-29 12:59:22 -04:00
|
|
|
---
|
2016-09-29 13:36:57 -04:00
|
|
|
- name: Set PGDATA environment variable.
|
|
|
|
template:
|
|
|
|
src: postgres.sh.j2
|
|
|
|
dest: /etc/profile.d/postgres.sh
|
|
|
|
mode: 0644
|
|
|
|
|
2016-09-29 12:59:22 -04:00
|
|
|
- name: Ensure PostgreSQL data directory exists.
|
|
|
|
file:
|
|
|
|
path: "{{ postgresql_data_dir }}"
|
|
|
|
owner: "{{ postgresql_user }}"
|
|
|
|
group: "{{ postgresql_group }}"
|
|
|
|
state: directory
|
|
|
|
mode: 0700
|
|
|
|
|
|
|
|
- name: Check if PostgreSQL database is initialized.
|
|
|
|
stat:
|
|
|
|
path: "{{ postgresql_data_dir }}/PG_VERSION"
|
|
|
|
register: pgdata_dir_version
|
|
|
|
|
|
|
|
- name: Ensure PostgreSQL database is initialized.
|
|
|
|
command: "initdb -D {{ postgresql_data_dir }}"
|
2016-09-29 13:36:57 -04:00
|
|
|
when: not pgdata_dir_version.stat.exists
|
2016-09-29 12:59:22 -04:00
|
|
|
become: yes
|
|
|
|
become_user: "{{ postgresql_user }}"
|