Skip to content

Commit 3499751

Browse files
exileedAdam
authored andcommitted
Support Debian 13 And migrate to deb822
1 parent cb081ea commit 3499751

9 files changed

Lines changed: 64 additions & 44 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ jobs:
4949
# - distro: rockylinux9
5050
- distro: debian11
5151
- distro: debian12
52+
- distro: debian13
53+
- distro: ubuntu2004
5254
- distro: ubuntu2204
5355
- distro: ubuntu2404
5456

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Ansible role which installs and configures PostgreSQL, extensions, databases and
1010

1111
#### Installation
1212

13-
This has been tested on Ansible 2.4.0 and higher.
13+
This has been tested on Ansible 2.5.0 and higher.
1414

1515
To install:
1616

@@ -54,14 +54,17 @@ An example how to include this role as a task:
5454

5555
#### Compatibility matrix
5656

57-
| Distribution / PostgreSQL | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
58-
| ------------------------- | :--------: | :--------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
59-
| Debian 11.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
60-
| Debian 12.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
61-
| Rockylinux 8.x | :no_entry: | :no_entry: | :warning: | :warning: | :warning: | :warning: | :warning: |
62-
| Rockylinux 9.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :warning: |
63-
| Ubuntu 22.04.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
64-
| Ubuntu 24.04.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
57+
58+
| Distribution / PostgreSQL | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
59+
| ------------------------ | :--------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
60+
| Debian 11.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
61+
| Debian 12.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
62+
| Debian 13.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
63+
| Rockylinux 8.x | :no_entry: | :warning: | :warning: | :warning: | :warning: | :warning: | :warning: |
64+
| Rockylinux 9.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :warning: |
65+
| Ubuntu 20.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
66+
| Ubuntu 22.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
67+
| Ubuntu 24.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
6568

6669

6770
- :white_check_mark: - works fine

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ postgresql_install_repository: true
838838
# APT settings
839839
postgresql_apt_key_id: "ACCC4CF8"
840840
postgresql_apt_key_url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc"
841+
postgresql_apt_repository_url: "https://apt.postgresql.org/pub/repos/apt"
841842
# postgresql_apt_keyring: "/usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg"
842843

843844
# repsoitory base

molecule/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ The default distribution is ubuntu2204. You can override th with setting the env
1414
* fedora40
1515
* debian11
1616
* debian12
17+
=======
18+
* debian13
19+
* ubuntu2004
1720
* ubuntu2204
1821
* ubuntu2404
1922

@@ -45,6 +48,7 @@ The playbooks read variables from two files. One common vars file, and one with
4548
$ ls -1 tests/ | grep vars
4649
vars.Debian.11.yml
4750
vars.Debian.12.yml
51+
vars.Debian.13.yml
4852
vars.Fedora.40.yml
4953
vars.Ubuntu.22.yml
5054
vars.Ubuntu.24.yml

tasks/install_apt.yml

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,48 @@
1515
- curl
1616
- gnupg
1717
- lsb-release
18+
- python3-debian
1819
state: present
1920
update_cache: true
2021
when: ansible_facts['pkg_mgr'] == 'apt'
2122

22-
# --- Derive the PGDG suite from the host codename ---
23-
# Examples: bookworm -> bookworm-pgdg, bullseye -> bullseye-pgdg, jammy -> jammy-pgdg, noble -> noble-pgdg
24-
- name: Compute PGDG suite from distribution codename
25-
ansible.builtin.set_fact:
26-
postgresql_apt_suite: "{{ ansible_facts['distribution_release'] }}-pgdg"
27-
when: ansible_facts['pkg_mgr'] == 'apt'
23+
- name: PostgreSQL | Add PostgreSQL repository (deb822)
24+
ansible.builtin.deb822_repository:
25+
name: postgresql
26+
types: ["deb"]
27+
uris: ["{{ postgresql_apt_repository_url }}"]
28+
suites: ["{{ ansible_distribution_release }}-pgdg"]
29+
components: ["main", "{{ postgresql_version }}"]
30+
signed_by: "{{ postgresql_apt_key_url }}"
31+
state: present
32+
when:
33+
- postgresql_install_repository
34+
- ansible_facts.packages.apt is defined
35+
- ansible_facts.packages.apt[0].version is version('2.4', '>=')
2836

29-
# --- Install the PGDG key into a keyring file ---
30-
# This avoids deprecated apt_key usage and works with newer apt-secure expectations.
31-
- name: Install PGDG keyring (dearmor GPG key into a file)
32-
ansible.builtin.shell: |
33-
install -d -m 0755 /usr/share/postgresql-common/pgdg
34-
curl -fsSL {{ postgresql_apt_key_url }} \
35-
| gpg --dearmor -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg
36-
args:
37-
creates: /usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg
38-
when: ansible_facts['pkg_mgr'] == 'apt'
37+
- name: PostgreSQL | Add PostgreSQL repository apt-key | apt
38+
apt_key:
39+
id: "{{ postgresql_apt_key_id }}"
40+
url: "{{ postgresql_apt_key_url }}"
41+
state: present
42+
keyring: /etc/apt/trusted.gpg.d/postgresql.gpg
43+
when:
44+
- postgresql_apt_key_url is defined and postgresql_apt_key_url | length > 0
45+
- postgresql_apt_key_id is defined and postgresql_apt_key_id | length > 0
46+
- postgresql_install_repository
47+
- ansible_facts.packages.apt[0].version is version('2.4', '<')
3948

40-
# --- Add the PGDG APT repository (HTTPS + signed-by) ---
41-
# We explicitly build the repo line to ensure the correct suite and signed-by usage.
42-
- name: Add PGDG APT repository
43-
ansible.builtin.apt_repository:
44-
repo: >-
45-
deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg]
46-
{{ postgresql_apt_repo_base }}
47-
{{ postgresql_apt_suite }} main
48-
filename: pgdg
49+
- name: PostgreSQL | Add PostgreSQL repository | apt
50+
apt_repository:
51+
repo: "{{ postgresql_apt_repository }}"
4952
state: present
5053
when:
51-
- ansible_facts['pkg_mgr'] == 'apt'
52-
- (postgresql_install_repository | default(true)) | bool
54+
- postgresql_apt_repository | default('') != ''
55+
- postgresql_install_repository
56+
- ansible_facts.packages.apt[0].version is version('2.4', '<')
5357

54-
# --- Optional pinning (preferences) ---
55-
- name: Add APT preferences for PGDG (pinning)
56-
ansible.builtin.template:
58+
- name: PostgreSQL | Add PostgreSQL repository preferences | apt
59+
template:
5760
src: etc_apt_preferences.d_apt_postgresql_org_pub_repos_apt.pref.j2
5861
dest: /etc/apt/preferences.d/apt_postgresql_org_pub_repos_apt.pref
5962
when:
@@ -74,7 +77,6 @@
7477
- (postgresql_apt_dependencies | default([])) | length > 0
7578

7679
# --- Install PostgreSQL packages from PGDG ---
77-
# Use default_release only if we know the suite; this avoids "invalid APT::Default-Release" errors.
7880
- name: Install PostgreSQL server/client/contrib
7981
ansible.builtin.apt:
8082
name:
@@ -84,9 +86,6 @@
8486
state: present
8587
update_cache: true
8688
cache_valid_time: "{{ apt_cache_valid_time | default(3600) }}"
87-
default_release: >-
88-
{{ postgresql_default_release
89-
| default(postgresql_apt_suite | default(omit)) }}
9089
environment: "{{ postgresql_env | default({}) }}"
9190
when: ansible_facts['pkg_mgr'] == 'apt'
9291

tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
- "{{ role_path }}/vars"
3131
tags: [always]
3232

33+
- name: Gather package facts
34+
ansible.builtin.package_facts:
35+
manager: apt
36+
3337
# --- Installers par famille/distro ---
3438
- name: Install on APT-based systems
3539
ansible.builtin.import_tasks: install_apt.yml

tests/vars.Debian.13.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---

vars/Debian_22.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
postgresql_service_name: "postgresql"
55

6-
postgresql_apt_repository: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main {{ postgresql_version }}"
6+
postgresql_apt_repository: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/postgresql.gpg] {{ postgresql_apt_repository_url }}/ {{ ansible_distribution_release }}-pgdg main {{ postgresql_version }}"

vars/trixie.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
# PostgreSQL vars for Debian Trixie (13)
3+
4+
postgresql_ext_postgis_deps:
5+
- "postgresql-{{postgresql_version}}-postgis-3"
6+
- "postgresql-{{postgresql_version}}-postgis-3-scripts"

0 commit comments

Comments
 (0)