2023-02-07 23:13:12 +00:00
|
|
|
- name: Disable PostgreSQL module
|
|
|
|
shell: dnf module disable -y postgresql
|
|
|
|
register: disable_postgresql_module
|
|
|
|
changed_when: "'Nothing to do' not in disable_postgresql_module.stdout"
|
2023-02-09 21:49:13 +00:00
|
|
|
when:
|
|
|
|
- ansible_facts['distribution_major_version'] == '8'
|
2023-02-07 23:13:12 +00:00
|
|
|
|
|
|
|
- name: Add PostgreSQL repository
|
|
|
|
dnf:
|
|
|
|
name: "{{ postgresql_repo_package }}"
|
|
|
|
disable_gpg_check: yes
|
|
|
|
state: present
|
2023-03-29 20:47:01 +00:00
|
|
|
when: postgresql_install_official_repo
|
2023-02-07 23:13:12 +00:00
|
|
|
|
|
|
|
- name: "Install {{ postgresql_package_name }} {{ postgresql_version }}"
|
|
|
|
dnf:
|
|
|
|
name: "{{ postgresql_package }}"
|
|
|
|
state: present
|
|
|
|
disable_gpg_check: yes
|
|
|
|
register: postgresql_setup
|
|
|
|
|
2023-04-18 21:10:38 +00:00
|
|
|
- name: Install deps packages
|
|
|
|
dnf:
|
|
|
|
name: "{{ postgresql_deps_packages }}"
|
|
|
|
state: present
|
|
|
|
|
2023-02-17 15:13:08 +00:00
|
|
|
- name: Include data direcory
|
|
|
|
include_tasks: data_dir.yaml
|
|
|
|
|
2023-07-21 14:14:47 +00:00
|
|
|
- name: "Manage TLS/SSL certificates"
|
2024-03-19 11:05:41 +00:00
|
|
|
#include_tasks: cacert.yaml
|
|
|
|
include_tasks: ssl/main.yaml
|
2023-07-21 14:14:47 +00:00
|
|
|
when: postgresql_ssl
|
|
|
|
|
2023-02-17 15:13:08 +00:00
|
|
|
- name: Include WAL-G role
|
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: wal-g
|
|
|
|
vars:
|
|
|
|
wal_g_pg: yes
|
2023-02-21 13:14:02 +00:00
|
|
|
wal_g_pg_home_dir: "{{ postgresql_home_dir }}"
|
2023-02-17 15:13:08 +00:00
|
|
|
wal_g_pg_data_dir: "{{ postgresql_data_dir }}"
|
|
|
|
wal_g_restore: "{{ postgresql_wal_g_restore }}"
|
|
|
|
when: postgresql_wal_g_install
|
|
|
|
|
|
|
|
- name: Include PostgreSQL restore
|
|
|
|
include_tasks: restore.yaml
|
2023-07-21 14:14:47 +00:00
|
|
|
when: postgresql_wal_g_restore_from_backup
|
2023-02-17 15:13:08 +00:00
|
|
|
|
2023-02-07 23:13:12 +00:00
|
|
|
- name: PostgreSQL Initdb
|
2023-08-10 15:36:37 +00:00
|
|
|
shell: "PGSETUP_INITDB_OPTIONS='--username {{ postgresql_superuser_username }} --auth-host {{ postgresql_password_encryption_algorithm }}' /usr/pgsql-{{ postgresql_major_version }}/bin/postgresql-{{ postgresql_major_version }}-setup initdb"
|
2023-02-07 23:13:12 +00:00
|
|
|
register: initdb
|
|
|
|
changed_when: "'Data directory is not empty!' not in initdb.stdout"
|
|
|
|
failed_when: false
|
|
|
|
|
2023-02-09 21:49:13 +00:00
|
|
|
- name: "Configure PostgreSQL"
|
|
|
|
include_tasks: config.yaml
|
|
|
|
tags: postgresql_configuration
|