Skip to content

Commit

Permalink
Fix Amazon package names
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Webb <dan.webb@damacus.io>
  • Loading branch information
damacus committed Nov 4, 2024
1 parent 3a41121 commit 259bc83
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 27 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- "rockylinux-9"
- "oraclelinux-9"
- "centos-stream-9"
- "amazonlinux-2"
- "amazonlinux-2023"
- "debian-11"
- "debian-12"
- "fedora-latest"
Expand All @@ -45,14 +45,46 @@ jobs:
- "ident-15"
- "ident-16"
- "ident-17"
- "initdb-locale-17"
- "server-install-15"
- "server-install-16"
- "server-install-17"
- "initdb-locale-17"
- "server-install-os"
exclude:
- os: "centos-7"
suite: "server-install-os"
- os: "amazonlinux-2023"
suite: "access-15"
- os: "amazonlinux-2023"
suite: "access-16"
- os: "amazonlinux-2023"
suite: "access-17"
- os: "amazonlinux-2023"
suite: "client-install-15"
- os: "amazonlinux-2023"
suite: "client-install-16"
- os: "amazonlinux-2023"
suite: "client-install-17"
- os: "amazonlinux-2023"
suite: "extension-15"
- os: "amazonlinux-2023"
suite: "extension-16"
- os: "amazonlinux-2023"
suite: "extension-17"
- os: "amazonlinux-2023"
suite: "ident-15"
- os: "amazonlinux-2023"
suite: "ident-16"
- os: "amazonlinux-2023"
suite: "ident-17"
- os: "amazonlinux-2023"
suite: "server-install-15"
- os: "amazonlinux-2023"
suite: "server-install-16"
- os: "amazonlinux-2023"
suite: "server-install-17"
- os: "amazonlinux-2023"
suite: "initdb-locale-17"
fail-fast: false

steps:
Expand Down
2 changes: 1 addition & 1 deletion kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ platforms:
- name: rockylinux-9
- name: oraclelinux-9
- name: centos-stream-9
- name: amazonlinux-2
- name: amazonlinux-2023
- name: debian-11
- name: debian-12
- name: fedora-latest
Expand Down
20 changes: 15 additions & 5 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,16 @@ def secure_random

def default_server_packages(version: nil, source: :os)
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
when 'rhel', 'fedora'
{
os: %w(libpq postgresql-contrib postgresql-server),
repo: %W(postgresql#{version.delete('.')}-contrib postgresql#{version.delete('.')}-server),
}.fetch(source, nil)
when 'amazon'
{
os: %W(postgresql#{version.delete('.')}-contrib postgresql#{version.delete('.')}-server),
repo: %W(postgresql#{version.delete('.')}-contrib postgresql#{version.delete('.')}-server),
}.fetch(source, nil)
when 'debian'
{
os: %w(libpq5 postgresql postgresql-common),
Expand All @@ -125,11 +130,16 @@ def default_server_packages(version: nil, source: :os)

def default_client_packages(version: nil, source: :os)
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
when 'rhel', 'fedora'
{
os: %w(postgresql),
repo: %W(postgresql#{version.delete('.')}),
}.fetch(source, nil)
when 'amazon'
{
os: %W(postgresql#{version.delete('.')}),
repo: %W(postgresql#{version.delete('.')}),
}.fetch(source, nil)
when 'debian'
{
os: %w(postgresql-client),
Expand Down Expand Up @@ -182,13 +192,13 @@ def yum_repo_platform_family_string
# Build the platform string that makes up the final component of the yum repo URL
def yum_repo_platform_string
platform = platform?('fedora') ? 'fedora' : 'rhel'
release = platform?('amazon') ? '7' : '$releasever'
release = platform?('amazon') ? '8' : '$releasever'
"#{platform}-#{release}-$basearch"
end

# On Amazon use the RHEL 7 packages. Otherwise use the releasever yum variable
# On Amazon use the RHEL 8 packages. Otherwise use the releasever yum variable
def yum_releasever
platform?('amazon') ? '7' : '$releasever'
platform?('amazon') ? '8' : '$releasever'
end

# Fedora doesn't seem to know the right symbols for psql
Expand Down
4 changes: 3 additions & 1 deletion libraries/sql/_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ module Connection

def postgresql_devel_pkg_name(version: installed_postgresql_major_version, source: installed_postgresql_package_source)
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
when 'rhel', 'fedora'
source.eql?(:repo) ? "postgresql#{version}-devel" : 'postgresql-devel'
when 'debian'
'libpq-dev'
when 'amazon'
'libpq-devel'
end
end

Expand Down
7 changes: 1 addition & 6 deletions resources/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
default: true

property :version, [String, Integer],
default: '15',
default: '17',
coerce: proc { |p| p.to_s },
description: 'Version to install'

Expand Down Expand Up @@ -178,11 +178,6 @@ def do_repository_action(repo_action)
end

def do_client_package_action(package_action)
if platform_family?('rhel') && node['platform_version'].to_i.eql?(7)
package 'epel-release'
package 'centos-release-scl'
end

package 'postgresql-client' do
package_name new_resource.client_packages
action package_action
Expand Down
15 changes: 3 additions & 12 deletions test/cookbooks/test/recipes/server_install_os.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# STDERR: Importing GPG key 0x08B40D20:
# Userid : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
# Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
# From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY
# Public key for postgresql17-17.0-2PGDG.rhel9.aarch64.rpm is not installed. Failing package is: postgresql17-17.0-2PGDG.rhel9.aarch64
# GPG Keys are configured as: file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY
# Public key for postgresql17-libs-17.0-2PGDG.rhel9.aarch64.rpm is not installed. Failing package is: postgresql17-libs-17.0-2PGDG.rhel9.aarch64
# GPG Keys are configured as: file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY
# Error: GPG check FAILED
# ---- End output of ["dnf", "-y", "install", "postgresql17-0:17.0-2PGDG.rhel9.aarch64"] ----
# Ran ["dnf", "-y", "install", "postgresql17-0:17.0-2PGDG.rhel9.aarch64"] returned 1

postgresql_install 'postgresql' do
source :os
version '15'
action %i(install init_server)
end

package 'libpq-devel' if platform_family?('amazon')

postgresql_config 'postgresql-server' do
server_config({
'max_connections' => 110,
Expand Down

0 comments on commit 259bc83

Please sign in to comment.