Fix the data directory setup on EL systems.

This commit is contained in:
Andrea Dell'Amico 2024-08-09 16:28:41 +02:00
parent 3aeea4004a
commit 488253a708
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
2 changed files with 23 additions and 3 deletions

View File

@ -35,6 +35,9 @@
ansible.builtin.yum:
pkg: "{{ psql_el_pgdg_packages }}"
state: present
- name: postgresql-packages | Print the DATA directory
ansible.builtin.debug:
msg: "Postgresql data directory: {{ psql_el_data_dir }}"
- name: postgresql-packages | Create the postgresql data directory if it is not in the default place
ansible.builtin.file:
@ -43,9 +46,25 @@
group: postgres
mode: "700"
state: directory
when:
- psql_use_alternate_data_dir
- ansible_distribution_file_variety == "RedHat"
when: psql_use_alternate_data_dir
- name: postgresql-packages | Crate a systemd directory to customize the postgresql startup unit
ansible.builtin.file:
dest: "/etc/systemd/system/postgresql-{{ psql_version }}.service.d"
owner: root
group: root
mode: "755"
state: directory
when: psql_use_alternate_data_dir
- name: postgresql-packages | Crate a postgresql systemd unit environment file
ansible.builtin.template:
src: postgresql-service-environment.conf.j2
dest: "/etc/systemd/system/postgresql-{{ psql_version }}.service.d/environment.conf"
owner: root
group: root
mode: "644"
when: psql_use_alternate_data_dir
- name: postgresql-packages | Init the db if needed on EL systems
ansible.builtin.command: /usr/pgsql-{{ psql_version }}/bin/postgresql-{{ psql_version }}-setup initdb

View File

@ -0,0 +1 @@
Environment=PGDATA="{{ psql_el_data_dir }}"