Showing with 757 additions and 202 deletions.
  1. +2 −0 .gitignore
  2. +78 −2 .travis.yml
  3. +11 −0 CHANGELOG.md
  4. +11 −0 README.md
  5. +42 −2 REFERENCE.md
  6. +8 −0 lib/puppet/provider/sensuctl.rb
  7. +5 −1 lib/puppet/type/sensu_asset.rb
  8. +1 −1 lib/puppet/type/sensu_filter.rb
  9. +35 −0 lib/puppet/type/sensuctl_config.rb
  10. +7 −0 manifests/backend.pp
  11. +7 −1 manifests/plugins.pp
  12. +1 −1 metadata.json
  13. +2 −2 spec/acceptance/nodesets/amazonlinux-2.yml
  14. +2 −2 spec/acceptance/nodesets/amazonlinux-201803.yml
  15. +2 −2 spec/acceptance/nodesets/centos-6.yml
  16. +3 −3 spec/acceptance/nodesets/centos-7-cluster.yml
  17. +2 −2 spec/acceptance/nodesets/centos-7.yml
  18. +2 −1 spec/acceptance/nodesets/debian-8.yml
  19. +2 −1 spec/acceptance/nodesets/debian-9.yml
  20. +2 −1 spec/acceptance/nodesets/ubuntu-1604.yml
  21. +2 −1 spec/acceptance/nodesets/ubuntu-1804.yml
  22. +15 −4 spec/acceptance/sensu_asset_spec.rb
  23. +26 −0 spec/acceptance/sensu_check_spec.rb
  24. +4 −4 spec/acceptance/sensu_filter_spec.rb
  25. +4 −0 spec/fixtures/unit/provider/sensu_asset/sensuctl/asset_list.json
  26. +1 −1 spec/fixtures/unit/provider/sensu_filter/sensuctl/filter_list.json
  27. +12 −0 spec/spec_helper.rb
  28. +35 −0 spec/spec_helper_acceptance.rb
  29. +6 −6 spec/unit/provider/sensu_asset/sensuctl_spec.rb
  30. +3 −3 spec/unit/provider/sensu_filter/sensuctl_spec.rb
  31. +7 −0 spec/unit/provider/sensuctl_spec.rb
  32. +1 −0 spec/unit/sensu_asset_spec.rb
  33. +1 −1 spec/unit/sensu_filter_spec.rb
  34. +172 −0 spec/unit/sensuctl_config_spec.rb
  35. +42 −0 tests/README.md
  36. +15 −0 tests/ci_build.sh
  37. +10 −0 tests/decrypt-secrets.sh
  38. +15 −0 tests/encrypt-secrets.sh
  39. BIN tests/secrets.tar.enc
  40. BIN tests/sensu_license.json.enc
  41. +15 −15 tests/ssl/ca/ca_crl.pem
  42. +1 −0 tests/ssl/ca/inventory.txt
  43. +1 −1 tests/ssl/ca/serial
  44. +34 −34 tests/ssl/ca/signed/sensu_backend.pem
  45. +34 −34 tests/ssl/certs/sensu_backend.pem
  46. +15 −15 tests/ssl/crl.pem
  47. +49 −49 tests/ssl/private_keys/sensu_backend.pem
  48. +12 −12 tests/ssl/public_keys/sensu_backend.pem
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ doc/**

# secrets
tests/sensu_license.json
tests/secrets
tests/secrets.tar
80 changes: 78 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ before_install:
- gem update bundler
- gem --version
- bundle -v
- 'if [ -n "$encrypted_5de82e653bde_key" -a -n "$encrypted_5de82e653bde_iv" ]; then openssl aes-256-cbc -K $encrypted_5de82e653bde_key -iv $encrypted_5de82e653bde_iv -in tests/sensu_license.json.enc -out tests/sensu_license.json -d; fi'

- 'if [ -n "$encrypted_f942601034d6_key" -a -n "$encrypted_f942601034d6_iv" ]; then openssl aes-256-cbc -K $encrypted_f942601034d6_key -iv $encrypted_f942601034d6_iv -in tests/secrets.tar.enc -out tests/secrets.tar -d; cd tests && tar xvf secrets.tar ; fi'
sudo: false

script: 'SPEC_OPTS="--format documentation" bundle exec rake validate lint spec strings:generate reference'
Expand Down Expand Up @@ -41,6 +40,12 @@ matrix:
env: BEAKER_set="centos-6" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="centos-6" 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 All @@ -53,6 +58,12 @@ matrix:
env: BEAKER_set="centos-7" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_full=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="centos-7" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_full=yes BEAKER_sensu_ci_build=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.4.4
sudo: required
services: docker
Expand All @@ -65,6 +76,12 @@ matrix:
env: BEAKER_set="centos-7-cluster" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_cluster=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="centos-7-cluster" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_cluster=yes BEAKER_sensu_ci_build=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.4.4
sudo: required
services: docker
Expand All @@ -77,6 +94,12 @@ matrix:
env: BEAKER_set="debian-9" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="debian-9" 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 All @@ -89,6 +112,12 @@ matrix:
env: BEAKER_set="ubuntu-1604" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="ubuntu-1604" 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 All @@ -101,6 +130,12 @@ matrix:
env: BEAKER_set="debian-8" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="debian-8" 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 All @@ -113,6 +148,12 @@ matrix:
env: BEAKER_set="ubuntu-1804" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="ubuntu-1804" 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 All @@ -125,6 +166,12 @@ matrix:
env: BEAKER_set="amazonlinux-2" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="amazonlinux-2" 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 All @@ -137,14 +184,43 @@ matrix:
env: BEAKER_set="amazonlinux-201803" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="amazonlinux-201803" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
bundler_args:
script: bundle exec rake beaker
allow_failures:
- rvm: 2.4.4
env: PUPPET_GEM_VERSION="~> 5" FIXTURES_YML=".fixtures-latest.yml"
- rvm: 2.5.3
env: PUPPET_GEM_VERSION="~> 6" FIXTURES_YML=".fixtures-latest.yml"
- rvm: 2.5.3
env: BEAKER_set="centos-6" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
env: BEAKER_set="centos-7" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_full=yes BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
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="ubuntu-1604" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
env: BEAKER_set="debian-8" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
env: BEAKER_set="ubuntu-1804" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
env: BEAKER_set="amazonlinux-2" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
- rvm: 2.5.3
env: BEAKER_set="amazonlinux-201803" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_ci_build=yes
branches:
only:
- master
- /^v\d/
notifications:
email: false
slack:
rooms:
- secure: R1ThBe5UcmcX5UqnMAWEl5e0JpO1MjsCJDvsDfgTZQ7Nb7gYzj6T9lls11HxxoALffkdMbi7g7qlrwQ9ajblIZlS27aMbucwaMbWt6uiepVITHTub6+ZhM1yAcgFgRk2HsfaZnaB0LERW4SIfTTe/hGFIMgHGDYSf+NYqM3ikhY=
on_success: change
on_failure: always
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.4.0](https://github.com/sensu/sensu-puppet/tree/v3.4.0) (2019-07-11)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.3.0...v3.4.0)

**Merged pull requests:**

- Add headers property to sensu\_assets [\#1119](https://github.com/sensu/sensu-puppet/pull/1119) ([treydock](https://github.com/treydock))
- Update several usage examples to match Sensu Go docs [\#1117](https://github.com/sensu/sensu-puppet/pull/1117) ([treydock](https://github.com/treydock))
- Add ability to run acceptance tests against Sensu-Go CI builds [\#1115](https://github.com/sensu/sensu-puppet/pull/1115) ([treydock](https://github.com/treydock))
- Support listing sensuctl resources using chunk-size [\#1114](https://github.com/sensu/sensu-puppet/pull/1114) ([treydock](https://github.com/treydock))
- Regenerate backend test cert to include additional SANs [\#1113](https://github.com/sensu/sensu-puppet/pull/1113) ([treydock](https://github.com/treydock))

## [v3.3.0](https://github.com/sensu/sensu-puppet/tree/v3.3.0) (2019-05-18)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.2.0...v3.3.0)

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* [Resource purging](#resource-purging)
* [Sensu backend cluster](#sensu-backend-cluster)
* [Adding backend members to an existing cluster](#adding-backend-members-to-an-existing-cluster)
* [Large Environment Considerations](#large-environment-considerations)
4. [Reference](#reference)
* [Facts](#facts)
5. [Limitations - OS compatibility, etc.](#limitations)
Expand Down Expand Up @@ -471,6 +472,16 @@ sensu::backend::config_hash:

The first step will not fully add the node to the cluster until the second step is performed.

### Large Environment Considerations

If the backend system has a large number of resources it may be necessary to query resources using chunk size added in Sensu Go 5.8.

```
class { '::sensu::backend':
sensuctl_chunk_size => 100,
}
```
## Reference
### Facts
Expand Down
44 changes: 42 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ _Private Classes_
* [`sensu_role_binding`](#sensu_role_binding): Manages Sensu role bindings
* [`sensu_silenced`](#sensu_silenced): Manages Sensu silencing
* [`sensu_user`](#sensu_user): Manages Sensu users
* [`sensuctl_config`](#sensuctl_config): Abstract type to configure other types

## Classes

Expand Down Expand Up @@ -607,6 +608,14 @@ Hash of sensu_user resources

Default value: {}

##### `sensuctl_chunk_size`

Data type: `Optional[Integer]`

Chunk size to use when listing sensuctl resources

Default value: `undef`

### sensu::plugins

Class to manage the Sensu plugins.
Expand Down Expand Up @@ -639,6 +648,15 @@ class { 'sensu::plugins':

The following parameters are available in the `sensu::plugins` class.

##### `manage_repo`

Data type: `Optional[Boolean]`

Determines if plugin repo should be managed.
Defaults to value for `sensu::manage_repo`.

Default value: `undef`

##### `package_ensure`

Data type: `String`
Expand Down Expand Up @@ -872,7 +890,7 @@ sensu_asset { 'test':
ensure => 'present',
url => 'http://example.com/asset/example.tar',
sha512 => '4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b',
filters => ['System.OS==linux'],
filters => ["entity.system.os == 'linux'"],
}
```

Expand Down Expand Up @@ -902,6 +920,10 @@ Valid values: /.*/, absent

A set of filters used by the agent to determine of the asset should be installed.

##### `headers`

HTTP headers to appy to asset retrieval requests.

##### `namespace`

The Sensu RBAC namespace that this asset belongs to.
Expand Down Expand Up @@ -1553,7 +1575,7 @@ Default value: default
sensu_filter { 'test':
ensure => 'present',
action => 'allow',
expressions => ["event.Entity.Environment == 'production'"],
expressions => ["event.entity.labels.environment == 'production'"],
}
```

Expand Down Expand Up @@ -2440,3 +2462,21 @@ URL to use with 'sensuctl configure'

Default value: http://127.0.0.1:8080

### sensuctl_config

Abstract type to configure other types

#### Parameters

The following parameters are available in the `sensuctl_config` type.

##### `name`

namevar

The name of the resource.

##### `chunk_size`

sensuctl chunk-size

8 changes: 8 additions & 0 deletions lib/puppet/provider/sensuctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class Puppet::Provider::Sensuctl < Puppet::Provider

commands :sensuctl => 'sensuctl'

class << self
attr_accessor :chunk_size
end

def self.config_path
# https://github.com/sensu/sensu-puppet/issues/1072
# since $HOME is not set in systemd service File.expand_path('~') won't work
Expand Down Expand Up @@ -51,6 +55,10 @@ def self.sensuctl_list(command, namespaces = true)
end
args << '--format'
args << 'json'
if ! chunk_size.nil?
args << '--chunk-size'
args << chunk_size.to_s
end
data = []
output = sensuctl(args)
Puppet.debug("sensuctl #{args.join(' ')}: #{output}")
Expand Down
6 changes: 5 additions & 1 deletion lib/puppet/type/sensu_asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ensure => 'present',
url => 'http://example.com/asset/example.tar',
sha512 => '4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b',
filters => ['System.OS==linux'],
filters => ["entity.system.os == 'linux'"],
}
**Autorequires**:
Expand Down Expand Up @@ -57,6 +57,10 @@
newvalues(/.*/, :absent)
end

newproperty(:headers, :parent => PuppetX::Sensu::HashProperty) do
desc "HTTP headers to appy to asset retrieval requests."
end

newproperty(:namespace) do
desc "The Sensu RBAC namespace that this asset belongs to."
defaultto 'default'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/type/sensu_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
sensu_filter { 'test':
ensure => 'present',
action => 'allow',
expressions => ["event.Entity.Environment == 'production'"],
expressions => ["event.entity.labels.environment == 'production'"],
}
**Autorequires**:
Expand Down
35 changes: 35 additions & 0 deletions lib/puppet/type/sensuctl_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require_relative '../../puppet_x/sensu/type'
require_relative '../../puppet_x/sensu/array_property'
require_relative '../../puppet_x/sensu/hash_property'
require_relative '../../puppet_x/sensu/integer_property'

Puppet::Type.newtype(:sensuctl_config) do
desc <<-DESC
@summary Abstract type to configure other types
DESC

newparam(:name, :namevar => true) do
desc "The name of the resource."
end

newparam(:chunk_size, :parent => PuppetX::Sensu::IntegerProperty) do
desc "sensuctl chunk-size"
end

# First collect all types with sensuctl provider that come from this module
# For each sensuctl type, set the class variable 'chunk_size' used by
# each provider to list resources
# Return empty array since we are not actually generating resources
def generate
sensuctl_types = []
Dir[File.join(File.dirname(__FILE__), '../provider/sensu_*/sensuctl.rb')].each do |file|
type = File.basename(File.dirname(file))
sensuctl_types << type.to_sym
end
sensuctl_types.each do |type|
provider_class = Puppet::Type.type(type).provider(:sensuctl)
provider_class.chunk_size = self[:chunk_size]
end
[]
end
end
Loading