diff --git a/libraries/helpers.rb b/libraries/helpers.rb index b8794933..2202f6db 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -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 diff --git a/resources/install.rb b/resources/install.rb index 08c64596..4d2ceacc 100644 --- a/resources/install.rb +++ b/resources/install.rb @@ -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}" diff --git a/test/cookbooks/test/recipes/client_install.rb b/test/cookbooks/test/recipes/client_install.rb index 5d18a105..37c439b4 100644 --- a/test/cookbooks/test/recipes/client_install.rb +++ b/test/cookbooks/test/recipes/client_install.rb @@ -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'