[chef] Error running package and template resoource in ruby block


Chronological Thread 
  • From: < >
  • To:
  • Subject: [chef] Error running package and template resoource in ruby block
  • Date: Thu, 18 Dec 2014 09:05:31 -0800 (PST)

My code

ruby_block "install pg" do
 block do

   if !node[:installed][:postgres]

     package "postgres" do
      version "9.3"
      action :install
      provider Chef::Provider::Package::Apt
     end

    template "/etc/postgresql/9.3/main/pg_hba.conf" do
     source "pg_hba.conf.erb"
      mode 0660
     user "postgres"
     group "postgres"
   end

    execute "createdb ucmsdb" do
      user "postgres"
      not_if "psql --list | grep -v grep | grep ucmsdb", :user => "postgres"
    end

   node.set[:installed][:postgres] = true
end

end


   
============================================================================
====
    Error executing action `run` on resource 'ruby_block[install postgres]'
   
============================================================================
====

    NoMethodError
    -------------
    undefined method `apt_package' for Chef::Resource::RubyBlock

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/pgdb/recipes/default.rb:48:in `block (2 levels)
in
 from_file'


    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/pgdb/recipes/default.rb:44:in
`from_
file'

    ruby_block("install postgres") do
      action "run"
      retries 0
      retry_delay 2
      guard_interpreter :default
      block_name "install postgres"
      cookbook_name "pgdb"
      recipe_name "default"
      block
#<Proc:0x000000030f6650@/var/chef/cache/cookbooks/pgdb/recipes/defau
lt.rb:45>
    end


Running handlers:
Running handlers complete
Chef Client failed. 0 resources updated in 8.434211777 seconds

Please help

Thanx



Archive powered by MHonArc 2.6.16.

§