sensu-plugins / sensu-plugins-chef

This plugin provides native instrumentation for monitoring Chef, including service health checks (via chef-server-ctl) and chef node status, and a Sensu handler for removing stale Sensu clients.

Home Page:http://sensu-plugins.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chef 12 support

majormoses opened this issue · comments

Wondering id anyone can think of a way to keep chef 11 support while enabling people using chef 12.

@eheydrick thoughts on this? I almost think we need to fork this for 2 different version unless we use some sort of version schema to separate them (could get very messy)...I have no good solution maybe I am missing something.

The Chef 12 client is supposed to be backwards compatible with Chef 11 servers so there's a chance it'll just work if we bumped the dependency to Chef 12. Would need to test it out.

@tas50 can you offer any insight?

@majormoses Are we talking about all the plugins or a particular plugin? Do you have a particular example of what doesn't work? I can certainly carve off some time to see what we could do if something is broken.

@tas50 as soon as I install this gem it installs the gem for chef 12 and my $PATH shows that the gem binary of chef-client will be run instead of the local chef client install which the leads to issues running chef 11 as we are running all chef 12 at my org. I can get you more info hopefully tomorrow as I will be returning to the office tomorrow.

@majormoses How do you have chef and sensu installed? If you are using the omnibus installs the gems installed inside of sensu won't impact anything else. If you are using system ruby YMMV.

@eheydrick
in my packer image I have a script that does this to install chef client:
curl -L https://www.chef.io/chef/install.sh | sudo bash -s -- -v 12.4.3

I am using my orgs sensu wrapper which uses: https://github.com/sensu/sensu-chef to install.

Things that may be of interest config wise are:

gem_package 'sensu-plugins-consul' do
  version '0.0.3'
end

which in the case of chef plugin it pulls in chef gem (version 11) and then whenever I call chef-client it calls the version for 11 instead of my local install.

@tas50 sorry been a while before I could carve any time for this. I checked and I know why its causing me headache in my $PATH it has the gem paths before /usr/bin which is where the chef-client executable gets installed to.

root@ip-172-16-141-249:~# echo $PATH
/opt/rbenv/shims:/opt/rbenv/bin:/opt/rbenv/plugins/ruby_build/bin:/opt/rbenv/shims:/opt/rbenv/bin:/opt/rbenv/plugins/ruby_build/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
root@ip-172-16-141-249:~# which chef-client 
/usr/bin/chef-client

I will have to overwrite this I suppose: https://github.com/RiotGamesCookbooks/rbenv-cookbook/blob/a7ae0eedbf678a8ac93456c325f9d69a8ac9d6f3/templates/default/rbenv.sh.erb#L2

when I get a minute I will work on a fix in my wrapper for rbenv. Even if this solves the issue for me I think there is still value in testing a bump to chef 12 which if I can figure this out I can test (though I dont have any chef 11 servers lying around).

I would strongly recommend installing the sensu gems into the embedded ruby install using the sensu_gem resource. That way you keep your sensu gems separate from your other ruby installs and they won't conflict.

@eheydrick the default of the sensu cookbook is to not use embedded ruby: https://github.com/sensu/sensu-chef/blob/master/attributes/default.rb#L23 so I assumed that this was a sane way to go about this. Is there some doc I have yet to find that outlines some good practices on this?

As of Sensu 0.21 it's recommended to use embedded ruby. From the release notes:

Using the Sensu embedded Ruby for Sensu checks, mutators, and handlers has become a common practice. The Sensu 0.21 packages changed the default value of EMBEDDED_RUBY from false to true, allowing Sensu plugins to use the embedded Ruby by default. This change makes it easier to get started with Sensu.

I think the cookbook is defaulting to false for historical reasons that may not matter anymore. The monitor wrapper cookbook also sets it to true.

@eheydrick I will switch my stuff over and see if this is a moot point, I haven't upgraded all my envs yet to 0.21. I will read the release notes and then go about upgrading my envs to 0.21 and using embedded ruby

@eheydrick sorry been a busy couple of days I got my envs updated and should be able to carve out some time in the next day or so to see if this warrants further attention.

@eheydrick sorry for the delay...looks like does it for me im able to run the plugin.

Awesome, glad to hear it's working.

Chef gem version is still in 11.18.x, any chance to upgrade to 12.x ?