安装 Postgresql 时 AWS Opsworks Chef 配方失败

AWS Opsworks Chef recipe fails when installing Postgresql

我在 AWS Opsworks 中 运行 这个脚本。它以前有效,但现在失败并在脚本下方显示错误消息。 该脚本创建 linux-2 服务器实例,然后立即运行该脚本。 有些人建议设置 pgpcheck=0,但我不知道在哪里添加它。我也不知道这是否是解决方案。

template '/etc/sysconfig/clock' do
  source "timezone.erb"
  owner 'root'
  group 'root'
end

link '/etc/localtime' do
  to '/usr/share/zoneinfo/Australia/Sydney'
end

# execute 'enable epel' do
  # command 'yum-config-manager --enable epel'
  # sensitive true
# end

# package "barman" do
    # action :install
# end

packages = %w{tmux wget curl htop deltarpm vim-enhanced perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA.x86_64}

for p in packages do
    package p do
      action :install
    end
end

remote_file "/root/postgres.rpm" do
    source "https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm"
    action :create_if_missing
end

remote_file "/tmp/wal-g.tar.gz" do
    source "https://github.com/wal-g/wal-g/releases/download/v0.2.14/wal-g.linux-amd64.tar.gz"
    action :create_if_missing
end

execute 'extract wal-g' do
  command 'tar xzvf /tmp/wal-g.tar.gz'
  cwd '/usr/local/sbin'
  creates '/usr/local/sbin/wal-g'
end

rpm_package "pgdg-redhat12" do
    source "/root/postgres.rpm"
    action :install
    options " --nodeps "
end

ruby_block "fix repo release path" do
  block do
    fe = Chef::Util::FileEdit.new("/etc/yum.repos.d/pgdg-redhat-all.repo")
    fe.search_file_replace(/rhel-$releasever-$basearch/,
                               "rhel-7.5-x86_64")
    fe.write_file
  end
end

package "postgresql12-server" do
    action :install
end

package "postgresql12-contrib" do
    action :install
end

为简洁起见,删除了脚本的其余部分。

================================================================================
Error executing action `install` on resource 'yum_package[postgresql12-server]'
================================================================================
 
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 ----
STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel) installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
STDERR: yum-dump Repository Error: failure: repodata/repomd.xml from pgdg-common: [Errno 256] No more mirrors to try.
https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-7.5-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for pgdg-common
---- End output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 ----
Ran /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 returned 1
 
Resource Declaration:
---------------------
# In /var/chef/runs/4af4db66-94d5-43ff-89ca-1002521b8d4a/local-mode-cache/cache/cookbooks/pw_hosting/recipes/db_setup_al.rb
 
59: package "postgresql12-server" do
60:     action :install
61: end
62: 
 
Compiled Resource:
------------------
# Declared in /var/chef/runs/4af4db66-94d5-43ff-89ca-1002521b8d4a/local-mode-cache/cache/cookbooks/pw_hosting/recipes/db_setup_al.rb:59:in `from_file'
 
yum_package("postgresql12-server") do
package_name "postgresql12-server"
action [:install]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :package
cookbook_name "pw_hosting"
recipe_name "db_setup_al"
flush_cache {:before=>false, :after=>false}
end
 
Platform:
---------
x86_64-linux
 
[2021-08-21T15:38:39+10:00] INFO: Running queued delayed notifications before re-raising exception
[2021-08-21T15:38:39+10:00] ERROR: Running exception handlers
[2021-08-21T15:38:39+10:00] ERROR: Exception handlers complete
[2021-08-21T15:38:39+10:00] FATAL: Stacktrace dumped to /var/chef/runs/4af4db66-94d5-43ff-89ca-1002521b8d4a/local-mode-cache/cache/chef-stacktrace.out
[2021-08-21T15:38:39+10:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2021-08-21T15:38:39+10:00] ERROR: yum_package[postgresql12-server] (pw_hosting::db_setup_al line 59) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 ----
STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel) installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
STDERR: yum-dump Repository Error: failure: repodata/repomd.xml from pgdg-common: [Errno 256] No more mirrors to try.
https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-7.5-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for pgdg-common
---- End output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 ----
Ran /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 returned 1
[2021-08-21T15:38:39+10:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Feedback

根据搜索此问题的结果,这可能是暂时的。但是目前您可以更改为 /etc/yum.repos.d/pgdg-redhat-all.repo.

中的存储库禁用 GPG 检查

错误表明 [pgdg-common] 存储库的 GPG 验证问题,但这可能是 pgdg-redhat-all.repo 文件中的其他存储库。这通常通过 gpgcheck=1.

启用

将此更改为 gpgcheck=0,以便所有使用 Chef::Util::FileEdit 之类的东西同时生效。