sensu / sensu-chef

Sensu Chef cookbook.
https://supermarket.chef.io/cookbooks/sensu
Apache License 2.0
221 stars 280 forks source link

Sensu 0.27 should be the default version #533

Closed cwjohnston closed 7 years ago

cwjohnston commented 7 years ago

Expected Behavior

The cookbook should install the latest version of Sensu Core (0.27 as of this writing).

Current Behavior

Because installing Sensu Core 0.27 requires changes to the package repository configuration, the cookbook currently cannot install versions newer than 0.26.5.

Possible Solution

  1. Update default version to 0.27.0-2 or newer
  2. Remove support for init_style on sensu_service resources (see #530 , breaking change).

Your Environment

betorvs commented 7 years ago

Hi, I try to update the sensu package on CentOS 7, but I received this error:

   Recipe: sensu::client_service
     * sensu_service[sensu-client] action enable
       * service[sensu-client] action enable
         * service[sensu-client]: Service is not known to chkconfig.
         * service[sensu-client]: Service is not known to chkconfig.
         * service[sensu-client]: Service is not known to chkconfig.
         * service[sensu-client]: Service is not known to chkconfig.
         ================================================================================
         Error executing action enable on resource 'service[sensu-client]'
         ================================================================================

         Chef::Exceptions::Service
         -------------------------
         service[sensu-client]: Service is not known to chkconfig.

         Cookbook Trace:
         ---------------
         /tmp/kitchen/cache/cookbooks/sensu/providers/service.rb:73:in block in class_from_file'
         /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in run_action'
         /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in block (2 levels) in converge'
         /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in each'
         /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in block in converge'
         /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in converge'

         Resource Declaration:
         ---------------------
         # In /tmp/kitchen/cache/cookbooks/sensu/providers/service.rb

   47:     service new_resource.service do
   48:       provider service_provider
   49:       supports :status => true, :restart => true
   50:       retries 3
   51:       retry_delay 5
   52:       action :nothing
   53:       subscribes :restart, resources("ruby_block[sensu_service_trigger]"), :delayed
   54:     end
   55:   when "runit"

         Compiled Resource:
         ------------------
         # Declared in /tmp/kitchen/cache/cookbooks/sensu/providers/service.rb:47:in load_current_resource'

         service("sensu-client") do
    provider Chef::Provider::Service::Redhat
    action [:nothing]
    supports {:status=>true, :restart=>true}
    retries 3
    retry_delay 5
    default_guard_interpreter :default
    service_name "sensu-client"
    pattern "sensu-client"
    declared_type :service
    cookbook_name "sensu"
         end

         Platform:
         ---------
         x86_64-linux

       ================================================================================
       Error executing action enable on resource 'sensu_service[sensu-client]'
       ================================================================================

       Chef::Exceptions::Service
       -------------------------
       service[sensu-client] (/tmp/kitchen/cache/cookbooks/sensu/providers/service.rb line 47) had an error: Chef::Exceptions::Service: service[sensu-client]: Service is not known to chkconfig.

       Cookbook Trace:
       ---------------
       /tmp/kitchen/cache/cookbooks/sensu/providers/service.rb:73:in block in class_from_file'
       /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in run_action'
       /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in block (2 levels) in converge'
       /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in each'
       /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in block in converge'
       /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in converge'

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cache/cookbooks/sensu/recipes/client_service.rb

        20: sensu_service "sensu-client" do
        21:   init_style node["sensu"]["init_style"]
        22:   action [:enable, :start]
        23: end

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cache/cookbooks/sensu/recipes/client_service.rb:20:in from_file'

       sensu_service("sensu-client") do
         action [:enable, :start]
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         declared_type :sensu_service
         cookbook_name "sensu"
         recipe_name "client_service"
         init_style "sysv"
         service "sensu-client"
       end

       Platform:
       ---------
       x86_64-linux

In CentOS 6 it's ok. Any idea how to solve this problem?

cwjohnston commented 7 years ago

Hi @betorvs,

I think you're encountering this because we now ship systemd unit files in the packages for Centos 7, but the cookbook is still trying to use the Chef::Provider::Service::Redhat provider to manage the service.

We've merged a change in #534 which addresses this condition, and we're planning to include that change in the upcoming 4.0 release of this cookbook.

in4mer commented 6 years ago

Ah, so this breaks amazon linux support, then. Amazon linux does not use systemd, yet does self-identify as EL7.