diff --git a/README.md b/README.md index 22abfe837..282321ea9 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ An example how to include this role as a task: | Ubuntu 18.04.x | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | | Ubuntu 20.04.x | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | | Ubuntu 22.04.x | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |:grey_question: | :white_check_mark: | +| Rockylinux 9.x | :grey_question: | :grey_question: | :grey_question: | :grey_question: |:white_check_mark: | :white_check_mark: | | Fedora 37 | :grey_question: | :grey_question: | :grey_question: | :grey_question: |:grey_question: | :grey_question: | - :white_check_mark: - tested, works fine diff --git a/defaults/main.yml b/defaults/main.yml index dece318b2..f113ebb7a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -39,6 +39,7 @@ postgresql_database_owner: "{{ postgresql_admin_user }}" postgresql_ext_install_contrib: no postgresql_ext_install_dev_headers: no postgresql_ext_install_postgis: no +postgresql_ext_install_extra_packages: no # PostGIS postgresql_postgis_release_compatibility: diff --git a/tasks/extensions.yml b/tasks/extensions.yml index e7baac77c..fb7ad8864 100644 --- a/tasks/extensions.yml +++ b/tasks/extensions.yml @@ -6,3 +6,5 @@ when: postgresql_ext_install_dev_headers - import_tasks: extensions/postgis.yml when: postgresql_ext_install_postgis +- import_tasks: extensions/extra_packages.yml + when: postgresql_ext_install_extra_packages diff --git a/tasks/extensions/extra_packages.yml b/tasks/extensions/extra_packages.yml new file mode 100644 index 000000000..efa59cf2a --- /dev/null +++ b/tasks/extensions/extra_packages.yml @@ -0,0 +1,55 @@ +# file: postgresql/tasks/extensions/extra_packages.yml + +- include_vars: "../../vars/extra_packages.yml" + +# keys +- name: PostgreSQL | Extensions | Add repo keys | apt + apt_key: + id: "{{ item.value.id }}" + url: "{{ item.value.url }}" + state: present + keyring: /etc/apt/trusted.gpg.d/{{ item.value.id }}.gpg + loop: "{{ postgresql_ext_extra_packages.apt_keys | default({}) | dict2items }}" + when: + - postgresql_ext_extra_packages is defined + - ansible_os_family == "Debian" + +# repositories +- name: PostgreSQL | Extensions | Add repos | apt + apt_repository: + repo: "{{ item.value }}" + state: present + loop: "{{ postgresql_ext_extra_packages.apt_repositories | default({}) | dict2items }}" + when: + - postgresql_ext_extra_packages is defined + - ansible_os_family == "Debian" +- name: PostgreSQL | Extensions | Add repos | RHEL + yum_repository: + name: "{{ item.value.name }}" + description: "{{ item.value.description }}" + baseurl: "{{ item.value.url }}" + gpgkey: "{{ item.value.gpgkey }}" + enabled: yes + loop: "{{ postgresql_ext_extra_packages.yum_repositories | default({}) | dict2items }}" + when: + - postgresql_ext_extra_packages is defined + - ansible_os_family == "RedHat" + +# packages +- name: PostgreSQL | Extensions | Add packages | apt + apt: + name: "{{ postgresql_ext_extra_packages.names }}" + state: present + update_cache: yes + cache_valid_time: "{{ apt_cache_valid_time | default (3600) }}" + when: + - postgresql_ext_extra_packages is defined + - ansible_os_family == "Debian" +- name: PostgreSQL | Extensions | Add packages | RHEL + yum: + name: "{{ postgresql_ext_extra_packages.names }}" + state: present + update_cache: yes + when: + - postgresql_ext_extra_packages is defined + - ansible_os_family == "RedHat" diff --git a/tasks/install_rhel.yml b/tasks/install_rhel.yml index f8a755bf4..40860ed2e 100644 --- a/tasks/install_rhel.yml +++ b/tasks/install_rhel.yml @@ -22,7 +22,7 @@ - name: PostgreSQL | Disable postgresql module (necessary for RHEL8+) command: cmd: dnf module disable postgresql -y - when: "ansible_distribution_major_version == '8'" + when: "ansible_distribution_major_version == '8' or ansible_distribution_major_version == '9'" register: disable_postgresql_module changed_when: - "disable_postgresql_module.rc == 0" diff --git a/tasks/main.yml b/tasks/main.yml index 9eedb0616..d932f3acb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -21,7 +21,7 @@ tags: [postgresql, postgresql-install] - import_tasks: install_rhel.yml - when: (ansible_pkg_mgr == "yum" or ansible_pkg_mgr == "dnf") and (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "OracleLinux") + when: (ansible_pkg_mgr == "yum" or ansible_pkg_mgr == "dnf") and (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "OracleLinux" or ansible_distribution == "Rocky") tags: [postgresql, postgresql-install] - import_tasks: install_fedora.yml diff --git a/templates/postgresql.conf-14.j2 b/templates/postgresql.conf-14.j2 index a7512ef06..511d34093 100644 --- a/templates/postgresql.conf-14.j2 +++ b/templates/postgresql.conf-14.j2 @@ -731,8 +731,11 @@ jit_provider = '{{ postgresql_jit_provider }}' # JIT library to use # - Other Defaults - dynamic_library_path = '{{ postgresql_dynamic_library_path }}' +{% if postgresql_extension_destdir is defined and ansible_os_family == 'Debian' %} extension_destdir = '{{ postgresql_extension_destdir }}' # prepend path when loading extensions # and shared objects (added by Debian) +{% endif %} + gin_fuzzy_search_limit = {{ postgresql_gin_fuzzy_search_limit }} diff --git a/templates/postgresql.conf-15.j2 b/templates/postgresql.conf-15.j2 index 2cae19e0a..7f4d61bc8 100644 --- a/templates/postgresql.conf-15.j2 +++ b/templates/postgresql.conf-15.j2 @@ -746,7 +746,7 @@ jit_provider = '{{ postgresql_jit_provider }}' # JIT library to use # - Other Defaults - dynamic_library_path = '{{ postgresql_dynamic_library_path }}' -{% if postgresql_extension_destdir is defined %} +{% if postgresql_extension_destdir is defined and ansible_os_family == 'Debian' %} extension_destdir = '{{ postgresql_extension_destdir }}' # prepend path when loading extensions # and shared objects (added by Debian) {% endif %} diff --git a/vars/RedHat_9.yml b/vars/RedHat_9.yml new file mode 100644 index 000000000..6555c04fb --- /dev/null +++ b/vars/RedHat_9.yml @@ -0,0 +1,29 @@ +--- +# PostgreSQL vars for RedHat 9+ based distributions +# +# Using a different cluster name could cause problems with SELinux. +# See /usr/lib/systemd/system/postgresql-*.service +postgresql_cluster_name: "data" +postgresql_service_name: "postgresql-{{ postgresql_version }}" + +postgresql_varlib_directory_name: "pgsql" + +# Used to execute initdb +postgresql_bin_directory: "/usr/pgsql-{{postgresql_version}}/bin" + +postgresql_unix_socket_directories: + - "{{ postgresql_pid_directory }}" + - /tmp + +postgresql_fdw_mysql_packages: "mysql_fdw_{{ postgresql_version_terse }}" +postgresql_fdw_ogr_packages: "ogr_fdw{{ postgresql_version_terse }}" + +postgresql_packages: + - ca-certificates + - python3-psycopg2 + - python3-pycurl + - glibc-common + - epel-release + - python3-libselinux + - glibc-locale-source + - glibc-langpack-en diff --git a/vars/extra_packages.yml b/vars/extra_packages.yml new file mode 100644 index 000000000..1feb5a132 --- /dev/null +++ b/vars/extra_packages.yml @@ -0,0 +1,18 @@ +--- +# This file defines (optional) repos and packages - uncomment necessary lines + +# postgresql_ext_extra_packages: +# names: +# - pgadmin4-server +# apt_repositories: +# depot-pgadmin: "deb [signed-by=/etc/apt/trusted.gpg.d/8881B2A8210976F2.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4 main" +# apt_keys: +# depot-pgadmin: +# id: "8881B2A8210976F2" +# url: "https://www.pgadmin.org/static/packages_pgadmin_org.pub" +# yum_repositories: +# depot-pgadmin: +# name: pgadmin +# description: the most popular and feature rich Open Source administration and development platform for PostgreSQL +# url: "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/redhat/rhel-9-x86_64" +# gpgkey: "https://www.pgadmin.org/static/packages_pgadmin_org.pub"