Skip to content

Commit

Permalink
Fix GPG keys
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Webb <[email protected]>
  • Loading branch information
damacus committed Nov 4, 2024
1 parent bf02970 commit f700c1e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
16 changes: 5 additions & 11 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,12 @@ def default_client_packages(version: nil, source: :os)
end

def default_yum_gpg_key_uri
case node['platform_family']
when 'rhel', 'amazon'
case node['platform_version'].to_i
when 7
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL7'
else
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL'
end
when 'fedora'
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-Fedora'
if platform_family?('rhel') && node['platform_version'].to_i == 7
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL7'
elsif platform_family?('fedora')
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-KEY-fedora'
else
'https://download.postgresql.org/pub/repos/yum/keys/RPM-GPG-KEY-PGDG'
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL'
end
end

Expand Down
8 changes: 4 additions & 4 deletions resources/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ def install_method_repo?
def do_repository_action(repo_action)
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
dnf_module 'postgresql' do
action :disable
end if dnf_module_platform?

remote_file '/etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY' do
source new_resource.yum_gpg_key_uri
sensitive new_resource.sensitive
end

dnf_module 'postgresql' do
action :disable
end if dnf_module_platform?

yum_repository "PostgreSQL #{new_resource.version}" do
repositoryid "pgdg#{new_resource.version}"
description "PostgreSQL.org #{new_resource.version}"
Expand Down
8 changes: 4 additions & 4 deletions test/cookbooks/test/recipes/client_install.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Import PostgreSQL GPG key
# execute 'import_pgdg_key' do
# command 'rpm --import https://download.postgresql.org/pub/repos/yum/keys/RPM-GPG-KEY-PGDG'
# not_if 'rpm -q gpg-pubkey-08b40d20-*'
# end
execute 'import_pgdg_key' do
command 'rpm --import https://download.postgresql.org/pub/repos/yum/keys/RPM-GPG-KEY-PGDG'
not_if 'rpm -q gpg-pubkey-08b40d20-*'
end

include_recipe 'test::dokken'

Expand Down

0 comments on commit f700c1e

Please sign in to comment.