Skip to content

Commit

Permalink
sensu_gem can now optionally specify gem_package
Browse files Browse the repository at this point in the history
This is helpful when you need multiple versions of the same plugin (or any gemfor that matter) by allowing the resource name and package name to differ.

Signed-off-by: Ben Abrams <[email protected]>
  • Loading branch information
majormoses committed Sep 14, 2018
1 parent c75f28a commit 2611952
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ suites:
run_list:
- recipe[sensu-test::ensure_group]
- recipe[sensu::default]
- recipe[sensu-test::gem_lwrp]
- recipe[sensu-test::good_checks]
attributes:
sensu:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ cookbook. Please see HISTORY.md for changes from older versions of this project.

## [Unreleased]

### Added
- exposed `package_name` as an optional parameter to the `sensu_gem` resource in case you need to install multiple versions of a gem. (@majormoses)

## [5.3.0] - 2018-08-19
### Added
- First class support for defining checks via cron syntax (@vbichov)
Expand Down
3 changes: 3 additions & 0 deletions providers/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
version new_resource.version
source new_resource.source
options new_resource.options
package_name new_resource.package_name unless new_resource.package_name.nil?
end

new_resource.updated_by_last_action(g.updated_by_last_action?)
Expand All @@ -15,6 +16,7 @@
version new_resource.version
source new_resource.source
options new_resource.options
package_name new_resource.package_name unless new_resource.package_name.nil?
action :upgrade
end

Expand All @@ -25,6 +27,7 @@
g = gem_package new_resource.name do
gem_binary Sensu::Helpers.gem_binary
version new_resource.version
package_name new_resource.package_name unless new_resource.package_name.nil?
action :remove
end

Expand Down
1 change: 1 addition & 0 deletions resources/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
attribute :version, :kind_of => String
attribute :source, :kind_of => String
attribute :options, :kind_of => [String, Hash]
attribute :package_name, :kind_of => [String, NilClass], :default => nil
7 changes: 7 additions & 0 deletions test/cookbooks/sensu-test/recipes/gem_lwrp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
action :install
end

# for testing the package proprty
sensu_gem 'sensu-plugins-disk-checks-newer' do
action :install
version '3.1.0'
package_name 'sensu-plugins-disk-checks'
end

# for testing upgrade action with source
sensu_gem 'sensu-plugins-memory-checks' do
source mem_checks
Expand Down
6 changes: 6 additions & 0 deletions test/integration/default/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

sensu_pkg_name = windows? ? 'Sensu' : 'sensu'

sensu_gem_bin = '/opt/sensu/embedded/bin/gem'

describe package(sensu_pkg_name) do
it { should be_installed }
end
Expand All @@ -11,3 +13,7 @@
its(:content) { should_not match /"id": / }
# it { should be_grouped_into('nogroup') } unless windows?
end

describe command("#{sensu_gem_bin} list | grep sensu-plugins-disk-checks") do
its('stdout') { should match(/3\.(\d+).\d+/)}
end

0 comments on commit 2611952

Please sign in to comment.