Showing with 1,208 additions and 16 deletions.
  1. +9 −0 .fixtures-latest.yml
  2. +12 −0 .fixtures.yml
  3. +14 −0 .travis.yml
  4. +11 −0 CHANGELOG.md
  5. +40 −3 README.md
  6. +86 −0 REFERENCE.md
  7. +9 −0 Vagrantfile
  8. +16 −0 lib/puppet/provider/sensuctl.rb
  9. +1 −0 lib/puppet/type/sensu_asset.rb
  10. +1 −0 lib/puppet/type/sensu_check.rb
  11. +1 −0 lib/puppet/type/sensu_entity.rb
  12. +19 −0 lib/puppet/type/sensu_event.rb
  13. +1 −0 lib/puppet/type/sensu_filter.rb
  14. +1 −0 lib/puppet/type/sensu_handler.rb
  15. +1 −0 lib/puppet/type/sensu_hook.rb
  16. +1 −0 lib/puppet/type/sensu_mutator.rb
  17. +1 −0 lib/puppet/type/sensu_role.rb
  18. +1 −0 lib/puppet/type/sensu_role_binding.rb
  19. +3 −0 lib/puppet/type/sensu_silenced.rb
  20. +13 −0 lib/puppet_x/sensu/type.rb
  21. +34 −0 manifests/backend.pp
  22. +61 −0 manifests/backend/datastore/postgresql.pp
  23. +4 −3 metadata.json
  24. +93 −0 spec/acceptance/06_postgresql_spec.rb
  25. +1 −1 spec/acceptance/nodesets/centos-7.yml
  26. +44 −0 spec/acceptance/nodesets/debian-10.yml
  27. +61 −7 spec/acceptance/sensu_check_spec.rb
  28. +1 −0 spec/acceptance/sensu_event_spec.rb
  29. +109 −0 spec/classes/backend_datastore_postgresql_spec.rb
  30. +11 −0 spec/classes/backend_spec.rb
  31. +476 −0 spec/fixtures/facts/debian-10-x86_64.facts
  32. +27 −0 spec/shared_examples/namespace.rb
  33. +5 −2 spec/spec_helper_acceptance.rb
  34. +4 −0 spec/unit/sensu_asset_spec.rb
  35. +4 −0 spec/unit/sensu_check_spec.rb
  36. +4 −0 spec/unit/sensu_entity_spec.rb
  37. +4 −0 spec/unit/sensu_filter_spec.rb
  38. +4 −0 spec/unit/sensu_handler_spec.rb
  39. +4 −0 spec/unit/sensu_hook_spec.rb
  40. +4 −0 spec/unit/sensu_mutator_spec.rb
  41. +4 −0 spec/unit/sensu_role_binding_spec.rb
  42. +4 −0 spec/unit/sensu_role_spec.rb
  43. +4 −0 spec/unit/sensu_silenced_spec.rb
9 changes: 9 additions & 0 deletions .fixtures-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ fixtures:
yumrepo_core:
repo: git://github.com/puppetlabs/puppetlabs-yumrepo_core
puppet_version: ">= 6.0.0"
# Need by postgresql
augeas_core:
repo: git://github.com/puppetlabs/puppetlabs-augeas_core
puppet_version: ">= 6.0.0"
# Need by postgresql
concat:
repo: git://github.com/puppetlabs/puppetlabs-concat.git
postgresql:
repo: git://github.com/puppetlabs/puppetlabs-postgresql.git
archive:
repo: git://github.com/voxpupuli/puppet-archive.git
symlinks:
Expand Down
12 changes: 12 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ fixtures:
repo: git://github.com/puppetlabs/puppetlabs-yumrepo_core
ref: 1.0.1
puppet_version: ">= 6.0.0"
# Need by postgresql
augeas_core:
repo: git://github.com/puppetlabs/puppetlabs-augeas_core
ref: 1.0.4
puppet_version: ">= 6.0.0"
# Need by postgresql
concat:
repo: git://github.com/puppetlabs/puppetlabs-concat.git
ref: v6.0.0
postgresql:
repo: git://github.com/puppetlabs/puppetlabs-postgresql.git
ref: v6.0.0
archive:
repo: git://github.com/voxpupuli/puppet-archive.git
ref: 'v3.0.0'
Expand Down
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ matrix:
env: BEAKER_set="debian-9" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="debian-10" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="debian-10" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.4.4
sudo: required
services: docker
Expand Down Expand Up @@ -227,6 +239,8 @@ matrix:
env: BEAKER_set="centos-7-cluster" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_cluster=yes BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
env: BEAKER_set="debian-9" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
env: BEAKER_set="debian-10" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
env: BEAKER_set="ubuntu-1604" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## [v3.7.0](https://github.com/sensu/sensu-puppet/tree/v3.7.0) (2019-08-25)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.6.0...v3.7.0)

**Merged pull requests:**

- Support PostgreSQL datastore [\#1136](https://github.com/sensu/sensu-puppet/pull/1136) ([treydock](https://github.com/treydock))
- Increase upper bound of module dependencies [\#1134](https://github.com/sensu/sensu-puppet/pull/1134) ([treydock](https://github.com/treydock))
- Improved Validations [\#1132](https://github.com/sensu/sensu-puppet/pull/1132) ([treydock](https://github.com/treydock))
- Do not resolve absent sensu\_events [\#1129](https://github.com/sensu/sensu-puppet/pull/1129) ([treydock](https://github.com/treydock))
- Support Debian 10 [\#1128](https://github.com/sensu/sensu-puppet/pull/1128) ([treydock](https://github.com/treydock))

## [v3.6.0](https://github.com/sensu/sensu-puppet/tree/v3.6.0) (2019-08-16)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.5.0...v3.6.0)

Expand Down
43 changes: 40 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [Advanced agent](#advanced-agent)
* [Advanced SSL](#advanced-ssl)
* [Enterprise support](#enterprise-support)
* [PostgreSQL datastore support](#postgresql-datastore-support)
* [Installing Plugins](#installing-plugins)
* [Installing Extensions](#installing-extensions)
* [Exported resources](#exported-resources)
Expand Down Expand Up @@ -64,11 +65,13 @@ This module will install packages, create configuration and start services neces

Plugin sync is required if the custom sensu types and providers are used.

This module has a soft dependency on the [puppetlabs/apt](https://forge.puppet.com/puppetlabs/apt) module (`>= 5.0.1 < 7.0.0`) for systems using `apt`.
This module has a soft dependency on the [puppetlabs/apt](https://forge.puppet.com/puppetlabs/apt) module (`>= 5.0.1 < 8.0.0`) for systems using `apt`.

If using Puppet >= 6.0.0 there is a soft dependency on the [puppetlabs/yumrepo_core](https://forge.puppet.com/puppetlabs/yumrepo_core) module (`>= 1.0.1 < 2.0.0`) for systems using `yum`.

If managing Windows there is a soft dependency on the [puppet/archive](https://forge.puppet.com/puppet/archive) module (`>= 3.0.0 < 4.0.0`).
If managing Windows there is a soft dependency on the [puppet/archive](https://forge.puppet.com/puppet/archive) module (`>= 3.0.0 < 5.0.0`).

For PostgreSQL datastore support there is a soft dependency on [puppetlabs/postgresql](https://forge.puppet.com/puppetlabs/postgresql) module (`>= 6.0.0 < 7.0.0`).

### Beginning with sensu

Expand Down Expand Up @@ -219,7 +222,40 @@ class { 'sensu::backend':
}
```

The type `sensu_ldap_auth` requires a valid enterprise license.
The types `sensu_ad_auth` and `sensu_ldap_auth` require a valid enterprise license.

### PostgreSQL datastore support

**NOTE**: This features require a valid Sensu Go enterprise license.

The following example will add a PostgreSQL server and database to the sensu-backend host and configure Sensu Go to use PostgreSQL as the event datastore.

```puppet
class { 'postgresql::globals':
manage_package_repo => true,
version => '9.6',
}
class { 'postgresql::server': }
class { '::sensu::backend':
license_source => 'puppet:///modules/profile/sensu/license.json',
datastore => 'postgresql',
postgresql_password => 'secret',
}
```

Refer to the [puppetlabs/postgresql](https://forge.puppet.com/puppetlabs/postgresql) module documentation for details on how to manage PostgreSQL with Puppet.

The following example uses an external PostgreSQL server.

```puppet
class { '::sensu::backend':
license_source => 'puppet:///modules/profile/sensu/license.json',
datastore => 'postgresql',
postgresql_password => 'secret',
postgresql_host => 'postgresql.example.com',
manage_postgresql_db => false,
}
```

### Installing Plugins

Expand Down Expand Up @@ -588,6 +624,7 @@ Linux.
* EL 7
* Debian 8
* Debian 9
* Debian 10 (Puppet 6 only)
* Ubuntu 16.04 LTS
* Ubuntu 18.04 LTS
* Amazon 2018.03
Expand Down
86 changes: 86 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _Public Classes_
* [`sensu`](#sensu): Base Sensu class
* [`sensu::agent`](#sensuagent): Manage Sensu agent
* [`sensu::backend`](#sensubackend): Manage Sensu backend
* [`sensu::backend::datastore::postgresql`](#sensubackenddatastorepostgresql):
* [`sensu::plugins`](#sensuplugins): Manage Sensu plugins

_Private Classes_
Expand Down Expand Up @@ -620,6 +621,91 @@ Chunk size to use when listing sensuctl resources

Default value: `undef`

##### `datastore`

Data type: `Optional[Enum['postgresql']]`

Datastore to configure for sensu events

Default value: `undef`

##### `datastore_ensure`

Data type: `Enum['present','absent']`

The datastore ensure property. If set to `absent` all
datastore parameters must still be defined.

Default value: 'present'

##### `manage_postgresql_db`

Data type: `Boolean`

Boolean that sets of postgresql database should be managed

Default value: `true`

##### `postgresql_name`

Data type: `String`

Name of PostgresConfig that is configured with sensuctl

Default value: 'postgresql'

##### `postgresql_user`

Data type: `String`

The PostgreSQL database user

Default value: 'sensu'

##### `postgresql_password`

Data type: `String`

The PostgreSQL database password

Default value: 'changeme'

##### `postgresql_host`

Data type: `Stdlib::Host`

The PostgreSQL host

Default value: 'localhost'

##### `postgresql_port`

Data type: `Stdlib::Port`

The PostgreSQL port

Default value: 5432

##### `postgresql_dbname`

Data type: `String`

The name of the PostgreSQL database

Default value: 'sensu'

##### `postgresql_pool_size`

Data type: `Integer`

The PostgreSQL pool size

Default value: 20

### sensu::backend::datastore::postgresql

The sensu::backend::datastore::postgresql class.

### sensu::plugins

Class to manage the Sensu plugins.
Expand Down
9 changes: 9 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
agent.vm.provision :shell, :inline => "facter --custom-dir=/vagrant/lib/facter sensu_agent"
end

config.vm.define "debian10-agent", autostart: false do |agent|
agent.vm.box = "debian/buster64"
agent.vm.hostname = 'debian10-agent.example.com'
agent.vm.network :private_network, ip: "192.168.52.27"
agent.vm.provision :shell, :path => "tests/provision_basic_debian.sh"
agent.vm.provision :shell, :inline => "puppet apply /vagrant/tests/sensu-agent.pp"
agent.vm.provision :shell, :inline => "facter --custom-dir=/vagrant/lib/facter sensu_agent"
end

config.vm.define "debian9-agent", autostart: false do |agent|
agent.vm.box = "debian/stretch64"
agent.vm.hostname = 'debian9-agent.example.com'
Expand Down
16 changes: 16 additions & 0 deletions lib/puppet/provider/sensuctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,21 @@ def self.sensuctl_auth_types()
Puppet.debug("auth_types: #{auth_types}")
auth_types
end

def self.namespaces()
begin
data = self.sensuctl_list('namespace', false)
namespaces = []
data.each do |d|
namespaces << d['name']
end
rescue Exception
return []
end
namespaces
end
def namespaces()
self.class.namespaces()
end
end

1 change: 1 addition & 0 deletions lib/puppet/type/sensu_asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@ def pre_run_check
fail "You must provide a #{property}"
end
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
1 change: 1 addition & 0 deletions lib/puppet/type/sensu_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,6 @@ def pre_run_check
end
end
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
1 change: 1 addition & 0 deletions lib/puppet/type/sensu_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def pre_run_check
fail "You must provide a #{property}"
end
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end

19 changes: 19 additions & 0 deletions lib/puppet/type/sensu_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@
def retrieve
@resource.provider.state || :absent
end

def insync?(is)
if is.is_a?(Array)
is = is[0]
end
if @should.is_a?(Array)
should = @should[0]
else
should = @should
end
if is.to_sym == :absent && should.to_sym == :resolve
true
else
super
end
end
end

newparam(:name, :namevar => true) do
Expand Down Expand Up @@ -86,5 +102,8 @@ def self.title_patterns
end
end

def pre_run_check
PuppetX::Sensu::Type.validate_namespace(self)
end
end

1 change: 1 addition & 0 deletions lib/puppet/type/sensu_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,6 @@ def pre_run_check
fail "You must provide a #{property}"
end
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
1 change: 1 addition & 0 deletions lib/puppet/type/sensu_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,6 @@ def pre_run_check
if self[:type] == :set && !self[:handlers]
fail "handlers must be defined for type set"
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
1 change: 1 addition & 0 deletions lib/puppet/type/sensu_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@ def pre_run_check
fail "You must provide a #{property}"
end
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
1 change: 1 addition & 0 deletions lib/puppet/type/sensu_mutator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@ def pre_run_check
fail "You must provide a #{property}"
end
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
1 change: 1 addition & 0 deletions lib/puppet/type/sensu_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,6 @@ def pre_run_check
fail "You must provide a #{property}"
end
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
1 change: 1 addition & 0 deletions lib/puppet/type/sensu_role_binding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,6 @@ def pre_run_check
fail "You must provide a #{property}"
end
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
3 changes: 3 additions & 0 deletions lib/puppet/type/sensu_silenced.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,8 @@ def self.title_patterns
end
end

def pre_run_check
PuppetX::Sensu::Type.validate_namespace(self)
end
end

Loading