ansible-role-postgresql/tasks/postgresql-packages.yml

87 lines
3.0 KiB
YAML

---
- name: postgresql-packages | Manage the postgresql packages installation
when:
- ansible_distribution_file_variety == "Debian"
- not postgresql_client_only
tags: ['postgresql', 'postgres']
block:
- name: postgresql-packages | Install the postgresql server packages on Deb systems
ansible.builtin.apt:
pkg: "{{ postgresql_pkgs }}"
state: present
cache_valid_time: 3600
notify: Restart postgresql
- name: postgresql-packages | Manage the postgresql client installation
when:
- ansible_distribution_file_variety == "Debian"
- postgresql_client_only
tags: ['postgresql', 'postgres']
block:
- name: postgresql-packages | Install the postgresql server packages on Deb systems
ansible.builtin.apt:
pkg: postgresql-client
state: present
cache_valid_time: 3600
- name: postgresql-packages | EL server packages
when:
- not psql_el_install_scl_version
- not postgresql_client_only
- ansible_distribution_file_variety == "RedHat"
tags: ['postgresql', 'postgres']
block:
- name: postgresql-packages | Install the postgresql packages from the pgdg repository
ansible.builtin.yum:
pkg: "{{ psql_el_pgdg_packages }}"
state: present
- name: postgresql-packages | Init the db if needed
ansible.builtin.command: /usr/pgsql-{{ psql_version }}/bin/postgresql-{{ psql_version }}-setup initdb
args:
creates: '{{ psql_el_data_dir }}/postgresql.conf'
- name: postgresql-packages | EL server packagesx from SCL
when:
- psql_el_install_scl_version
- ansible_distribution_file_variety == "RedHat"
- not postgresql_client_only
tags: ['scl', 'postgresql', 'postgres']
block:
- name: postgresql-packages | Install the postgresql scl packages
ansible.builtin.yum:
pkg: "{{ psql_el_scl_packages }}"
state: present
- name: postgresql-packages | Init the db if needed
ansible.builtin.command: /opt/rh/rh-postgresql{{ psql_version }}/root/usr/bin/postgresql-setup --initdb
args:
creates: '{{ psql_el_data_dir }}/postgresql.conf'
- name: postgresql-packages | EL client packages
when:
- not psql_el_install_scl_version
- postgresql_client_only
- ansible_distribution_file_variety == "RedHat"
tags: ['postgresql', 'postgres']
block:
- name: postgresql-packages | Install the postgresql client from the pgdg repository
ansible.builtin.yum:
pkg: "postgresql{{ psql_version }}"
state: present
- name: postgresql-packages | EL server packagesx from SCL
when:
- psql_el_install_scl_version
- ansible_distribution_file_variety == "RedHat"
- postgresql_client_only
tags: ['scl', 'postgresql', 'postgres']
block:
- name: postgresql-packages | Install the postgresql scl client package
ansible.builtin.yum:
pkg: "{{ item }}"
state: present
loop:
- "rh-postgresql{{ psql_version }}-runtime"
- "rh-postgresql{{ psql_version }}-postgresql"