Skip to content

Commit

Permalink
Merge pull request #554 from fidelio33b/development
Browse files Browse the repository at this point in the history
RHEL 9+, additional repos and packages feature
  • Loading branch information
fidelio33b authored Dec 11, 2023
2 parents e821f82 + 3239401 commit a923a71
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tasks/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
55 changes: 55 additions & 0 deletions tasks/extensions/extra_packages.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion tasks/install_rhel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions templates/postgresql.conf-14.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}


Expand Down
2 changes: 1 addition & 1 deletion templates/postgresql.conf-15.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
29 changes: 29 additions & 0 deletions vars/RedHat_9.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions vars/extra_packages.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit a923a71

Please sign in to comment.