1
0
Fork 0
mirror of https://github.com/geerlingguy/ansible-role-postgresql.git synced 2024-11-11 13:50:50 -05:00
postgresql/tasks/initialize.yml

30 lines
856 B
YAML
Raw Normal View History

---
2016-09-29 15:33:39 -04:00
- name: Set PostgreSQL environment variables.
2016-09-29 13:36:57 -04:00
template:
src: postgres.sh.j2
dest: /etc/profile.d/postgres.sh
mode: 0644
2016-09-29 21:01:39 -04:00
notify: restart postgresql
2016-09-29 13:36:57 -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.
2016-09-29 15:33:39 -04:00
command: "{{ postgresql_bin_path }}/initdb -D {{ postgresql_data_dir }}"
2016-09-29 13:36:57 -04:00
when: not pgdata_dir_version.stat.exists
become: yes
become_user: "{{ postgresql_user }}"
2016-09-29 21:01:39 -04:00
# See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509
vars:
ansible_ssh_pipelining: true