Showing with 63 additions and 19 deletions.
  1. +14 −8 CHANGELOG.md
  2. +8 −0 README.md
  3. +7 −3 lib/puppet/provider/sensu_api.rb
  4. +4 −1 lib/puppet/provider/sensuctl.rb
  5. +1 −1 metadata.json
  6. +18 −3 spec/unit/provider/sensu_api_spec.rb
  7. +11 −3 spec/unit/provider/sensuctl_spec.rb
22 changes: 14 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [v5.2.1](https://github.com/sensu/sensu-puppet/tree/v5.2.1) (2020-10-17)

[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v5.2.0...v5.2.1)

### Fixed

- Fix for when version query returns malformed version [\#1279](https://github.com/sensu/sensu-puppet/pull/1279) ([treydock](https://github.com/treydock))
- Document breaking changes upgrading to 5.x [\#1277](https://github.com/sensu/sensu-puppet/pull/1277) ([treydock](https://github.com/treydock))

## [v5.2.0](https://github.com/sensu/sensu-puppet/tree/v5.2.0) (2020-10-12)

[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v5.1.0...v5.2.0)
Expand Down Expand Up @@ -192,15 +201,18 @@

[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v4.2.1...v4.3.0)

### Added

- Support Sensu Go secrets features [\#1203](https://github.com/sensu/sensu-puppet/pull/1203) ([treydock](https://github.com/treydock))
- Better support for Sensu Go upgrades [\#1201](https://github.com/sensu/sensu-puppet/pull/1201) ([treydock](https://github.com/treydock))

## [v4.2.1](https://github.com/sensu/sensu-puppet/tree/v4.2.1) (2020-01-29)

[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v4.2.0...v4.2.1)

### Added

- Remove workaround for sensuctl command json formatting [\#1204](https://github.com/sensu/sensu-puppet/pull/1204) ([treydock](https://github.com/treydock))
- Support Sensu Go secrets features [\#1203](https://github.com/sensu/sensu-puppet/pull/1203) ([treydock](https://github.com/treydock))
- Better support for Sensu Go upgrades [\#1201](https://github.com/sensu/sensu-puppet/pull/1201) ([treydock](https://github.com/treydock))

### Fixed

Expand Down Expand Up @@ -258,7 +270,6 @@
- Support PDK [\#1184](https://github.com/sensu/sensu-puppet/pull/1184) ([treydock](https://github.com/treydock))
- Update default resources to match Sensu Go defaults [\#1181](https://github.com/sensu/sensu-puppet/pull/1181) ([treydock](https://github.com/treydock))
- Move PostgresConfig to a type [\#1176](https://github.com/sensu/sensu-puppet/pull/1176) ([treydock](https://github.com/treydock))
- Add support for Sensu etcd replicator [\#1175](https://github.com/sensu/sensu-puppet/pull/1175) ([treydock](https://github.com/treydock))

### Fixed

Expand All @@ -268,14 +279,9 @@

[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.11.0...v3.12.0)

### Added

- Improve name validations to match Sensu Go [\#1173](https://github.com/sensu/sensu-puppet/pull/1173) ([treydock](https://github.com/treydock))

### Fixed

- Add lint plugin [\#1177](https://github.com/sensu/sensu-puppet/pull/1177) ([ghoneycutt](https://github.com/ghoneycutt))
- Update steps to release software [\#1172](https://github.com/sensu/sensu-puppet/pull/1172) ([ghoneycutt](https://github.com/ghoneycutt))

## [v3.11.0](https://github.com/sensu/sensu-puppet/tree/v3.11.0) (2019-11-12)

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ This module begins supporting Sensu Go 6 with version >= 5.0.0

**NOTE** Upgrading to support Sensu Go 6 requires backends have Puppet applied before agents will begin to work as there is an agent specifc Sensu user and role added to support modifying agent entities via the API.

Class parameter changes:

* Remove deprecated `sensu::old_password` and `sensu::old_agent_password`, these parameters are no longer needed and were removed

Type property changes:

* Remove deprecated `url`, `sha512` and `filters` properties from `sensu_asset`, use `builds` property instead

#### Changes for backend

There is a manual step to perform to upgrade the sensu-backend after upgrading the backend to 6.x.
Expand Down
10 changes: 7 additions & 3 deletions lib/puppet/provider/sensu_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,10 @@ def auth_test(*args)

def self.version
data = api_request('/version', nil, {:failonfail => false})
data.fetch('sensu_backend', nil)
rescue Exception => e
Puppet.notice "Unable to query Sensu API version: #{e.message}"
return nil
else
return data.fetch('sensu_backend', nil)
end
def version
self.class.version
Expand All @@ -260,7 +259,12 @@ def self.version_cmp(v)
@current_version = version
end
return true if @current_version.nil?
return Gem::Version.new(@current_version) >= Gem::Version.new(v)
Gem::Version.new(@current_version) >= Gem::Version.new(v)
# Rescue in case version is not numeric such as well Sensu Go is built from source, the version may be "(devel)"
# See https://github.com/sensu/sensu-puppet/issues/1278
rescue ArgumentError => e
Puppet.debug "Unable to compare version #{@current_version} with needed version #{v}: #{e}"
return true
end
def version_cmp(*args)
self.class.version_cmp(*args)
Expand Down
5 changes: 4 additions & 1 deletion lib/puppet/provider/sensuctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ def self.version_cmp(v)
@current_version = version
end
return true if @current_version.nil?
return Gem::Version.new(@current_version) >= Gem::Version.new(v)
Gem::Version.new(@current_version) >= Gem::Version.new(v)
rescue ArgumentError => e
Puppet.debug "Unable to compare version #{@current_version} with needed version #{v}: #{e}"
return true
end
def version_cmp(*args)
self.class.version_cmp(*args)
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sensu-sensu",
"version": "5.2.0",
"version": "5.2.1",
"author": "sensu",
"summary": "A module to install the Sensu monitoring framework",
"license": "MIT",
Expand Down
21 changes: 18 additions & 3 deletions spec/unit/provider/sensu_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@
describe Puppet::Provider::SensuAPI do
subject { Puppet::Provider::SensuAPI }

describe 'version' do
it 'returns version' do
allow(described_class).to receive(:api_request).with('/version', nil, {:failonfail => false}).and_return({'sensu_backend' => '6.1.0'})
expect(described_class.version).to eq('6.1.0')
end
it 'returns nil if no version' do
allow(described_class).to receive(:api_request).with('/version', nil, {:failonfail => false}).and_return({})
expect(described_class.version).to eq(nil)
end
end

describe 'version_cmp' do
it 'returns true' do
allow(described_class).to receive(:api_request).with('/version').and_return('6.1.0')
described_class.instance_variable_set('@current_version', '6.1.0')
expect(described_class.version_cmp('6.1.0')).to eq(true)
end
it 'returns false' do
allow(described_class).to receive(:api_request).with('/version').and_return('6.0.0')
it 'returns true when malformed version' do
described_class.instance_variable_set('@current_version', '(devel)')
expect(described_class.version_cmp('6.1.0')).to eq(true)
end
it 'returns false' do
described_class.instance_variable_set('@current_version', '6.0.0')
expect(described_class.version_cmp('6.1.0')).to eq(false)
end
end
end
14 changes: 11 additions & 3 deletions spec/unit/provider/sensuctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,24 @@
allow(subject).to receive(:sensuctl).with(['version'], {:failonfail => false}).and_return('sensuctl version 6.1.0+ee, enterprise edition, build be1e65933de5be15a65066227f007ae369af1449, built 2020-10-02T01:15:38Z, built with go1.13.15')
expect(subject.version).to eq('6.1.0')
end
it 'returns nil without version match' do
allow(subject).to receive(:sensuctl).with(['version'], {:failonfail => false}).and_return('foobar')
expect(subject.version).to eq(nil)
end
end

describe 'version_cmp' do
it 'returns true' do
allow(subject).to receive(:version).and_return('6.1.0')
described_class.instance_variable_set('@current_version', '6.1.0')
expect(subject.version_cmp('6.1.0')).to eq(true)
end
it 'returns false' do
allow(subject).to receive(:version).and_return('6.0.0')
it 'returns true with malformed version' do
described_class.instance_variable_set('@current_version', '(devel)')
expect(subject.version_cmp('6.1.0')).to eq(true)
end
it 'returns false' do
described_class.instance_variable_set('@current_version', '6.0.0')
expect(subject.version_cmp('6.1.0')).to eq(false)
end
end
end