melezhik / cookbooks

perl chef cookbooks
https://github.com/melezhik/cookbooks
21 stars 27 forks source link

undefined method `cpan_client' after update to Chef 13 #29

Closed abadelt closed 7 years ago

abadelt commented 7 years ago

Hi,

I'm getting the error "undefined method `cpan_client' for #" in cpan/attributes/default.rb from a kitchen run. This only happens with Chef 13. It works when I switch back to Chef 12 - which of course is not a long-term workaround.

My metadata.rb states a dependency on instantclient: depends 'oracle-instantclient', '~> 1.1' which in turn states: depends 'cpan'

The full error message is: Installing Cookbook Gems: Compiling Cookbooks...

  =======================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/cpan/attributes/default.rb
 =======================================================================

   NoMethodError
   -------------
   undefined method `cpan_client' for #<Chef::Node::VividMash:0x00000003e686f8>

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/cpan/attributes/default.rb:1:in `from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/cpan/attributes/default.rb:

     1>> default.cpan_client.bootstrap.packages = ['curl']
     2:  
     3:  case platform
     4:  when 'centos'
     5:      default.cpan_client.bootstrap.packages << 'perl-devel'
     6:      default.cpan_client.bootstrap.packages << 'perl-CPAN'
     7:  end
     8:  
     9:  default.cpan_client.bootstrap.cpan_packages = ['Time::HiRes', 'CPAN::Meta', 'CPAN', 'local::lib', 'App::pmuninstall']
    10:  

   System Info:
   ------------
   chef_version=13.0.118
   platform=centos
   platform_version=6.8
   ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
   program_name=chef-client worker: ppid=86;start=12:52:54;
   executable=/opt/chef/bin/chef-client

Any idea why this happens with the new Chef version?

Thanks and regards, Andreas

melezhik commented 7 years ago

Hi! A first guess - looks like chef13 has changed syntax about attributes setters. Probably not a big deal, need to try out something like that:

default['cpan_client']['bootstrap']['packages'] = ...

So on ...

abadelt commented 7 years ago

Hi! Thanks for the super-fast reply. That solves the issue. Do you want me to create a pull request?

Thanks and regards, Andreas

melezhik commented 7 years ago

Hi Andreas! It would be great , as I dont't have much time for the moment.

melezhik commented 7 years ago

uploaded to supermarket - https://supermarket.chef.io/cookbooks/cpan/versions/0.0.35