Skip to content

Commit a923a71

Browse files
authored
Merge pull request ANXS#554 from fidelio33b/development
RHEL 9+, additional repos and packages feature
2 parents e821f82 + 3239401 commit a923a71

10 files changed

+112
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ An example how to include this role as a task:
6565
| Ubuntu 18.04.x | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: |
6666
| Ubuntu 20.04.x | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: |
6767
| Ubuntu 22.04.x | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |:grey_question: | :white_check_mark: |
68+
| Rockylinux 9.x | :grey_question: | :grey_question: | :grey_question: | :grey_question: |:white_check_mark: | :white_check_mark: |
6869
| Fedora 37 | :grey_question: | :grey_question: | :grey_question: | :grey_question: |:grey_question: | :grey_question: |
6970

7071
- :white_check_mark: - tested, works fine

defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ postgresql_database_owner: "{{ postgresql_admin_user }}"
3939
postgresql_ext_install_contrib: no
4040
postgresql_ext_install_dev_headers: no
4141
postgresql_ext_install_postgis: no
42+
postgresql_ext_install_extra_packages: no
4243

4344
# PostGIS
4445
postgresql_postgis_release_compatibility:

tasks/extensions.yml

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
when: postgresql_ext_install_dev_headers
77
- import_tasks: extensions/postgis.yml
88
when: postgresql_ext_install_postgis
9+
- import_tasks: extensions/extra_packages.yml
10+
when: postgresql_ext_install_extra_packages

tasks/extensions/extra_packages.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# file: postgresql/tasks/extensions/extra_packages.yml
2+
3+
- include_vars: "../../vars/extra_packages.yml"
4+
5+
# keys
6+
- name: PostgreSQL | Extensions | Add repo keys | apt
7+
apt_key:
8+
id: "{{ item.value.id }}"
9+
url: "{{ item.value.url }}"
10+
state: present
11+
keyring: /etc/apt/trusted.gpg.d/{{ item.value.id }}.gpg
12+
loop: "{{ postgresql_ext_extra_packages.apt_keys | default({}) | dict2items }}"
13+
when:
14+
- postgresql_ext_extra_packages is defined
15+
- ansible_os_family == "Debian"
16+
17+
# repositories
18+
- name: PostgreSQL | Extensions | Add repos | apt
19+
apt_repository:
20+
repo: "{{ item.value }}"
21+
state: present
22+
loop: "{{ postgresql_ext_extra_packages.apt_repositories | default({}) | dict2items }}"
23+
when:
24+
- postgresql_ext_extra_packages is defined
25+
- ansible_os_family == "Debian"
26+
- name: PostgreSQL | Extensions | Add repos | RHEL
27+
yum_repository:
28+
name: "{{ item.value.name }}"
29+
description: "{{ item.value.description }}"
30+
baseurl: "{{ item.value.url }}"
31+
gpgkey: "{{ item.value.gpgkey }}"
32+
enabled: yes
33+
loop: "{{ postgresql_ext_extra_packages.yum_repositories | default({}) | dict2items }}"
34+
when:
35+
- postgresql_ext_extra_packages is defined
36+
- ansible_os_family == "RedHat"
37+
38+
# packages
39+
- name: PostgreSQL | Extensions | Add packages | apt
40+
apt:
41+
name: "{{ postgresql_ext_extra_packages.names }}"
42+
state: present
43+
update_cache: yes
44+
cache_valid_time: "{{ apt_cache_valid_time | default (3600) }}"
45+
when:
46+
- postgresql_ext_extra_packages is defined
47+
- ansible_os_family == "Debian"
48+
- name: PostgreSQL | Extensions | Add packages | RHEL
49+
yum:
50+
name: "{{ postgresql_ext_extra_packages.names }}"
51+
state: present
52+
update_cache: yes
53+
when:
54+
- postgresql_ext_extra_packages is defined
55+
- ansible_os_family == "RedHat"

tasks/install_rhel.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- name: PostgreSQL | Disable postgresql module (necessary for RHEL8+)
2323
command:
2424
cmd: dnf module disable postgresql -y
25-
when: "ansible_distribution_major_version == '8'"
25+
when: "ansible_distribution_major_version == '8' or ansible_distribution_major_version == '9'"
2626
register: disable_postgresql_module
2727
changed_when:
2828
- "disable_postgresql_module.rc == 0"

tasks/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
tags: [postgresql, postgresql-install]
2222

2323
- import_tasks: install_rhel.yml
24-
when: (ansible_pkg_mgr == "yum" or ansible_pkg_mgr == "dnf") and (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "OracleLinux")
24+
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")
2525
tags: [postgresql, postgresql-install]
2626

2727
- import_tasks: install_fedora.yml

templates/postgresql.conf-14.j2

+3
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,11 @@ jit_provider = '{{ postgresql_jit_provider }}' # JIT library to use
731731
# - Other Defaults -
732732

733733
dynamic_library_path = '{{ postgresql_dynamic_library_path }}'
734+
{% if postgresql_extension_destdir is defined and ansible_os_family == 'Debian' %}
734735
extension_destdir = '{{ postgresql_extension_destdir }}' # prepend path when loading extensions
735736
# and shared objects (added by Debian)
737+
{% endif %}
738+
736739
gin_fuzzy_search_limit = {{ postgresql_gin_fuzzy_search_limit }}
737740

738741

templates/postgresql.conf-15.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ jit_provider = '{{ postgresql_jit_provider }}' # JIT library to use
746746
# - Other Defaults -
747747

748748
dynamic_library_path = '{{ postgresql_dynamic_library_path }}'
749-
{% if postgresql_extension_destdir is defined %}
749+
{% if postgresql_extension_destdir is defined and ansible_os_family == 'Debian' %}
750750
extension_destdir = '{{ postgresql_extension_destdir }}' # prepend path when loading extensions
751751
# and shared objects (added by Debian)
752752
{% endif %}

vars/RedHat_9.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# PostgreSQL vars for RedHat 9+ based distributions
3+
#
4+
# Using a different cluster name could cause problems with SELinux.
5+
# See /usr/lib/systemd/system/postgresql-*.service
6+
postgresql_cluster_name: "data"
7+
postgresql_service_name: "postgresql-{{ postgresql_version }}"
8+
9+
postgresql_varlib_directory_name: "pgsql"
10+
11+
# Used to execute initdb
12+
postgresql_bin_directory: "/usr/pgsql-{{postgresql_version}}/bin"
13+
14+
postgresql_unix_socket_directories:
15+
- "{{ postgresql_pid_directory }}"
16+
- /tmp
17+
18+
postgresql_fdw_mysql_packages: "mysql_fdw_{{ postgresql_version_terse }}"
19+
postgresql_fdw_ogr_packages: "ogr_fdw{{ postgresql_version_terse }}"
20+
21+
postgresql_packages:
22+
- ca-certificates
23+
- python3-psycopg2
24+
- python3-pycurl
25+
- glibc-common
26+
- epel-release
27+
- python3-libselinux
28+
- glibc-locale-source
29+
- glibc-langpack-en

vars/extra_packages.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
# This file defines (optional) repos and packages - uncomment necessary lines
3+
4+
# postgresql_ext_extra_packages:
5+
# names:
6+
# - pgadmin4-server
7+
# apt_repositories:
8+
# depot-pgadmin: "deb [signed-by=/etc/apt/trusted.gpg.d/8881B2A8210976F2.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4 main"
9+
# apt_keys:
10+
# depot-pgadmin:
11+
# id: "8881B2A8210976F2"
12+
# url: "https://www.pgadmin.org/static/packages_pgadmin_org.pub"
13+
# yum_repositories:
14+
# depot-pgadmin:
15+
# name: pgadmin
16+
# description: the most popular and feature rich Open Source administration and development platform for PostgreSQL
17+
# url: "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/redhat/rhel-9-x86_64"
18+
# gpgkey: "https://www.pgadmin.org/static/packages_pgadmin_org.pub"

0 commit comments

Comments
 (0)