rabbitmq / chef-cookbook

Development repository for Chef cookbook RabbitMQ
https://supermarket.chef.io/cookbooks/rabbitmq
Apache License 2.0
212 stars 425 forks source link

chef-client 16: undefined method `dpkg_autostart' at early stage of the cookbook #582

Closed Romainj1 closed 2 years ago

Romainj1 commented 2 years ago

On chef-client version 16 (latest 16.17.4), the default recipe does not work. Here is the error I am getting:

==> messaging1: ================================================================================
==> messaging1: Recipe Compile Error in /var/chef/cache/cookbooks/mcs-rabbitmq-server/recipes/master.rb
==> messaging1: ================================================================================
==> messaging1: NoMethodError
==> messaging1: -------------
==> messaging1: undefined method `dpkg_autostart' for cookbook: rabbitmq, recipe: default :Chef::Recipe
==> messaging1: Cookbook Trace: (most recent call first)
==> messaging1: ----------------------------------------
==> messaging1:   /var/chef/cache/cookbooks/rabbitmq/recipes/default.rb:85:in `from_file'
==> messaging1:   /var/chef/cache/cookbooks/mcs-rabbitmq-server/definitions/rabbitmq_server.rb:103:in `block in from_file'
==> messaging1:   /var/chef/cache/cookbooks/mcs-rabbitmq-server/recipes/master.rb:3:in `from_file'
==> messaging1: Relevant File Content:
==> messaging1: ----------------------
==> messaging1: /var/chef/cache/cookbooks/rabbitmq/recipes/default.rb:
==> messaging1:  78:    # logrotate is a package dependency of rabbitmq-server
==> messaging1:  79:    package 'logrotate'
==> messaging1:  80:  
==> messaging1:  81:    # socat is a package dependency of rabbitmq-server
==> messaging1:  82:    package 'socat'
==> messaging1:  83:  
==> messaging1:  84:    # => Prevent Debian systems from automatically starting RabbitMQ after dpkg install
==> messaging1:  85>>   dpkg_autostart node['rabbitmq']['service_name'] do
==> messaging1:  86:      allow false
==> messaging1:  87:    end
==> messaging1:  88:  
==> messaging1:  89:    if node['platform_version'].to_i < 8 && !node['rabbitmq']['use_distro_version']
==> messaging1:  90:      Chef::Log.warn 'Debian 7 is too old to use the recent .deb RabbitMQ packages. Falling back to distro package!'
==> messaging1:  91:      node.normal['rabbitmq']['use_distro_version'] = true
==> messaging1:  92:    end
==> messaging1:  93:  
==> messaging1:  94:    if node['rabbitmq']['use_distro_version']
==> messaging1: System Info:
==> messaging1: ------------
==> messaging1: chef_version=16.17.4
==> messaging1: platform=debian
==> messaging1: platform_version=10
==> messaging1: ruby=ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
==> messaging1: program_name=/usr/bin/chef-client
==> messaging1: executable=/opt/chef/bin/chef-client
==> messaging1: Running handlers:
==> messaging1: [2021-11-30T10:33:59+00:00] ERROR: Running exception handlers
==> messaging1: Running handlers complete
==> messaging1: [2021-11-30T10:33:59+00:00] ERROR: Exception handlers complete
==> messaging1: Chef Infra Client failed. 0 resources updated in 06 seconds
==> messaging1: [2021-11-30T10:33:59+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> messaging1: [2021-11-30T10:33:59+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> messaging1: [2021-11-30T10:33:59+00:00] FATAL: NoMethodError: undefined method `dpkg_autostart' for cookbook: rabbitmq, recipe: default :Chef::Recipe
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

PS: if you wonder what is cookbooks/mcs-rabbitmq-server/recipes/master.rb in the log file, it's just my recipe that calls include_recipe 'rabbitmq'

The thing is... I do have dpkg_autostart installed and available in my cookbook_path.

In order for the RabbitMQ team to investigate your issue, please provide as much as possible of the following details:

I think that the problem comes with the dpkg_autostart cookbook/chef-client 16

michaelklishin commented 2 years ago

My best guess is that what used to be built-in is now a separate cookbook that must be used explicitly. A pull request would be welcome.

Romainj1 commented 2 years ago

Actually, the separate cookbook is already mentioned as a dependency: cf the depends 'dpkg_autostart' at https://github.com/rabbitmq/chef-cookbook/blob/v5.x/metadata.rb#L17

My guess is that the dpkg_autostart does not work with chef-client 16 (earlier, i used the chef-client 12, and I had no problem)

A pull request would be welcome.

I'll see what i can do

Romainj1 commented 2 years ago

So, with further attempts today to make this work, I have no more the error. Made a lot of changes in my repo, so i don't know if an upgrade fixed the issue. I'll close this ticket