Option to install the client only.

This commit is contained in:
Andrea Dell'Amico 2023-12-18 13:00:20 +01:00
parent 1fc4a4527d
commit 96d172ce67
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
4 changed files with 104 additions and 42 deletions

View File

@ -10,6 +10,7 @@ postgresql_deb_repo_key: /etc/apt/keyrings/postgresql.asc
postgresql_deb_repository_url: "http://apt.postgresql.org/pub/repos/apt/"
postgresql_deb_repository_rel: "{{ ansible_lsb.codename }}-pgdg"
psql_postgresql_install: true
postgresql_client_only: false
psql_pkg_state: present
postgresql_enabled: true
psql_version: 16

View File

@ -2,7 +2,7 @@
- name: Postgresql external repository
ansible.builtin.import_tasks: postgresql_org_repo.yml
- name: Manage the postgresql packages
ansible.builtin.import_tasks: packages.yml
ansible.builtin.import_tasks: postgresql-packages.yml
when: psql_postgresql_install
- name: Manage the postgis packages
ansible.builtin.import_tasks: postgis.yml
@ -11,41 +11,54 @@
ansible.builtin.import_tasks: postgresql-config-deb.yml
when:
- psql_postgresql_install
- not postgresql_client_only
- ansible_distribution_file_variety == "Debian"
- name: PostgreSQL configuration of EL systems
ansible.builtin.import_tasks: postgresql-config-el.yml
when:
- psql_postgresql_install
- not postgresql_client_only
- ansible_distribution_file_variety == "RedHat"
- name: TLS setup
ansible.builtin.import_tasks: postgresql-ssl-config.yml
when: psql_postgresql_install
when:
- psql_postgresql_install
- not postgresql_client_only
- name: Kernel sysctl parameters
ansible.builtin.import_tasks: psql-kernel-sharedmem.yml
when:
- psql_postgresql_install
- psql_set_shared_memory
- not postgresql_client_only
- name: Configure access to the databases
ansible.builtin.import_tasks: configure-access.yml
when:
- psql_postgresql_install
- psql_db_data is defined
- not postgresql_client_only
- name: Service management
ansible.builtin.import_tasks: postgresql-service-status.yml
when: psql_postgresql_install
when:
- psql_postgresql_install
- not postgresql_client_only
- name: Manage the databases
ansible.builtin.import_tasks: manage_pg_db.yml
when:
- psql_postgresql_install
- psql_db_data is defined
- not postgresql_client_only
- name: Streaming replication setup
ansible.builtin.import_tasks: postgresql-streaming-replication.yml
when:
- postgresql_streaming_replication
- not postgresql_client_only
- name: Local backups
ansible.builtin.import_tasks: postgresql-backup.yml
when: psql_postgresql_install
when:
- psql_postgresql_install
- not postgresql_client_only
- name: Letsencrypt hook
ansible.builtin.import_tasks: postgresql-letsencrypt-acmetool.yml
when:
- postgresql_letsencrypt_managed
- not postgresql_client_only

View File

@ -1,38 +0,0 @@
---
- block:
- name: install the postgresql packages
apt: pkg={{ postgresql_pkgs }} state={{ psql_pkg_state }} cache_valid_time=3600
notify: Restart postgresql
when: ansible_distribution_file_variety == "Debian"
tags: [ 'postgresql', 'postgres' ]
- name: EL
block:
- name: install the postgresql packages from the pgdg repository
yum: pkg={{ psql_el_pgdg_packages }} state={{ psql_pkg_state }}
- name: Init the db if needed
command: /usr/pgsql-{{ psql_version }}/bin/postgresql-{{ psql_version }}-setup initdb
args:
creates: '{{ psql_el_data_dir }}/postgresql.conf'
when:
- not psql_el_install_scl_version
- ansible_distribution_file_variety == "RedHat"
tags: [ 'postgresql', 'postgres' ]
- name: EL from SCL
block:
- name: install the postgresql scl packages
yum: pkg={{ psql_el_scl_packages }} state={{ psql_pkg_state }}
- name: Init the db if needed
command: /opt/rh/rh-postgresql{{ psql_version }}/root/usr/bin/postgresql-setup --initdb
args:
creates: '{{ psql_el_data_dir }}/postgresql.conf'
when:
- psql_el_install_scl_version
- ansible_distribution_file_variety == "RedHat"
tags: [ 'scl', 'postgresql', 'postgres' ]

View File

@ -0,0 +1,86 @@
---
- 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"