1

I'm trying to deploy postgresql 9.4 on CentOS 7

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

I'm getting the following error:

[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)

What am I doing wrong?

3
  • Hi. That indeed seems complex. I've been trying with chef-shell. When I define such resource and query the resource collection by calling resources, I get ["package[[\"postgresql94-server\", \"postgresql94-contrib\"]]"]. I was not able to supply that or any combination of quotes and backslashes to resources(), i.e. as resources("package[[\"postgresql94-server\", \"postgresql94-contrib\"]]"). Think that equals your problem. Dec 30, 2015 at 16:45
  • It's quite weird since I tried to replicate whats provided in the docs(docs.chef.io/resource_yum.html) under the "multiple packages" section.
    – Joe
    Dec 30, 2015 at 16:55
  • While searching for it, I just stumbled across this bug report. I assume you're the author.. Dec 30, 2015 at 18:58

1 Answer 1

0

While this is being worked out in that bug report, here is a workaround:

p = package ['postgresql94-server', 'postgresql94-contrib'] do
    action :nothing
end
# ...
notifies :install, p, :immediately

You can always pass an explicit resource object for notifications.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .