xoxys.postgres/tasks/install.yml

36 lines
983 B
YAML
Raw Normal View History

2018-10-14 22:11:01 +00:00
---
- block:
- name: Install PostgreSQL
package:
name: "{{ item }}"
state: present
2018-10-15 22:07:17 +00:00
with_items: "{{ __postgres_packages }}"
- name: Ensure data directory exists
file:
path: "{{ __postgres_data_dir }}"
owner: "{{ postgres_user }}"
group: "{{ postgres_group }}"
state: directory
mode: 0700
- name: Setup custom systemd unit
template:
src: etc/systemd/system/postgresql.service.j2
2018-10-15 22:13:13 +00:00
dest: "/etc/systemd/system/{{ __postgres_daemon }}.service"
2018-10-15 22:07:17 +00:00
mode: 0644
notify: __postgres_restart
- name: Check if database is initialized
stat:
path: "{{ postgresql_data_dir }}/PG_VERSION"
register: pgdata_dir_version
- name: Ensure database is initialized
command: "/usr/pgsql-{{ __postgres_version }}/bin/postgresql-{{ __postgres_version }}-setup initdb"
when: not pgdata_dir_version.stat.exists
become: true
become_user: "{{ postgres_user }}"
2018-10-14 22:11:01 +00:00
become: True
become_user: root