我正在尝试在 CentOS 7 上部署 postgresql 9.4
package ['postgresql94-server', 'postgresql94-contrib'] do
action :nothing
end
execute "yum check-update" do
command "yum check-update"
action :nothing
end
package 'Install Postgres Repo' do
package_name 'pgdg-redhat94'
source '/tmp/pgdg-redhat94-9.4-2.noarch.rpm'
notifies :run, 'execute[yum check-update]', :immediately
notifies :install, 'package[postgresql94-server, postgresql94-contrib]', :immediately
action :nothing
end
execute 'Download Postgres repo RPM' do
command 'curl http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-2.noarch.rpm -o /tmp/pgdg-redhat94-9.4-2.noarch.rpm'
notifies :install, 'package[Install Postgres Repo]', :immediately
end
我收到以下错误:
[root@db01 ~]# chef-client
Starting Chef Client, version 12.6.0
resolving cookbooks for run list: ["postgres94"]
Synchronizing Cookbooks:
- postgres94 (0.1.0)
Compiling Cookbooks...
Converging 4 resources
Running handlers:
[2015-12-30T15:32:16+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-12-30T15:32:16+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2015-12-30T15:32:16+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-12-30T15:32:16+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2015-12-30T15:32:16+00:00] ERROR: resource yum_package[Install Postgres Repo] is configured to notify resource package[postgresql94-server, postgresql94-contrib] with action install, but package[postgresql94-server, postgresql94-contrib] cannot be found in the resource collection. yum_package[Install Postgres Repo] is defined in /var/chef/cache/cookbooks/postgres94/recipes/default.rb:19:in `from_file'
[2015-12-30T15:32:16+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
[root@db01 ~]# chef-client
Starting Chef Client, version 12.6.0
resolving cookbooks for run list: ["postgres94"]
Synchronizing Cookbooks:
- postgres94 (0.1.0)
Compiling Cookbooks...
Converging 4 resources
Running handlers:
[2015-12-30T15:32:30+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-12-30T15:32:30+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2015-12-30T15:32:30+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-12-30T15:32:30+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2015-12-30T15:32:30+00:00] ERROR: resource yum_package[Install Postgres Repo] is configured to notify resource package[postgresql94-server, postgresql94-contrib] with action install, but package[postgresql94-server, postgresql94-contrib] cannot be found in the resource collection. yum_package[Install Postgres Repo] is defined in /var/chef/cache/cookbooks/postgres94/recipes/default.rb:19:in `from_file'
[2015-12-30T15:32:30+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
我究竟做错了什么?
答案1
虽然该错误报告正在解决这个问题,但这里有一个解决方法:
p = package ['postgresql94-server', 'postgresql94-contrib'] do
action :nothing
end
# ...
notifies :install, p, :immediately
您始终可以传递一个明确的资源对象来进行通知。