xoxys.postgres/tasks/install.yml

49 lines
1.4 KiB
YAML
Raw Normal View History

2018-10-14 22:11:01 +00:00
---
- block:
2019-01-09 20:00:55 +00:00
- name: Install PostgreSQL
package:
name: "{{ item }}"
state: present
2019-08-27 20:55:28 +00:00
loop: "{{ __postgres_packages }}"
2018-10-15 22:07:17 +00:00
2019-01-09 20:00:55 +00:00
- name: Ensure data directory exists
file:
path: "{{ __postgres_data_dir }}"
owner: "{{ postgres_user }}"
group: "{{ postgres_group }}"
state: directory
mode: 0700
2018-10-15 22:07:17 +00:00
2019-01-09 20:00:55 +00:00
- name: Setup custom systemd service
template:
src: etc/systemd/system/postgresql.service.j2
dest: "/etc/systemd/system/{{ __postgres_daemon }}.service"
mode: 0644
notify: __postgres_restart
register: __postgres_systemd
2018-10-15 22:23:42 +00:00
2019-01-09 20:00:55 +00:00
- name: Force systemd to re-read configs
systemd:
daemon_reload: True
when: __postgres_systemd.changed
2019-01-09 20:00:55 +00:00
- name: Check if database is initialized
stat:
path: "{{ __postgres_data_dir }}/PG_VERSION"
register: __pgdata_dir_version
2019-01-09 20:00:55 +00:00
- name: Ensure database is initialized
command: "/usr/pgsql-{{ __postgres_version }}/bin/postgresql-{{ __postgres_version }}-setup initdb"
when: not __pgdata_dir_version.stat.exists
2019-10-26 13:09:33 +00:00
- name: Override default pg_hba.conf with a clean one
template:
src: templates/postgresql/data/pg_hba.conf.j2
dest: "{{ __postgres_config_path }}/pg_hba.conf"
mode: 0644
when:
- not __pgdata_dir_version.stat.exists
- postgres_clean_hba_file | bool
2018-10-14 22:11:01 +00:00
become: True
become_user: root