Showing with 1,102 additions and 360 deletions.
  1. +24 −0 .travis.yml
  2. +9 −4 CHANGELOG.md
  3. +14 −0 REFERENCE.md
  4. +0 −22 lib/puppet/provider/sensuctl.rb
  5. +1 −1 metadata.json
  6. +33 −9 spec/acceptance/00_backend_spec.rb
  7. +11 −3 spec/acceptance/01_agent_spec.rb
  8. +40 −14 spec/acceptance/02_backend_cluster_spec.rb
  9. +22 −5 spec/acceptance/03_no_ssl_spec.rb
  10. +22 −6 spec/acceptance/04_plugins_spec.rb
  11. +11 −3 spec/acceptance/05_enterprise_spec.rb
  12. +22 −12 spec/acceptance/99_facts_spec.rb
  13. +1 −0 spec/acceptance/nodesets/centos-7-cluster.yml
  14. +1 −0 spec/acceptance/nodesets/centos-7.yml
  15. +33 −9 spec/acceptance/sensu_ad_auth_spec.rb
  16. +30 −8 spec/acceptance/sensu_asset_spec.rb
  17. +55 −15 spec/acceptance/sensu_check_spec.rb
  18. +33 −9 spec/acceptance/sensu_cluster_role_binding_spec.rb
  19. +33 −9 spec/acceptance/sensu_cluster_role_spec.rb
  20. +19 −4 spec/acceptance/sensu_config_spec.rb
  21. +33 −9 spec/acceptance/sensu_entity_spec.rb
  22. +33 −8 spec/acceptance/sensu_event_spec.rb
  23. +33 −9 spec/acceptance/sensu_filter_spec.rb
  24. +33 −9 spec/acceptance/sensu_handler_spec.rb
  25. +33 −9 spec/acceptance/sensu_hook_spec.rb
  26. +33 −9 spec/acceptance/sensu_ldap_auth_spec.rb
  27. +33 −9 spec/acceptance/sensu_mutator_spec.rb
  28. +22 −6 spec/acceptance/sensu_namespace_spec.rb
  29. +33 −9 spec/acceptance/sensu_plugin_spec.rb
  30. +33 −9 spec/acceptance/sensu_role_binding_spec.rb
  31. +33 −9 spec/acceptance/sensu_role_spec.rb
  32. +33 −9 spec/acceptance/sensu_silenced_spec.rb
  33. +49 −11 spec/acceptance/sensu_user_spec.rb
  34. +6 −3 spec/acceptance/windows_spec.rb
  35. +31 −6 spec/spec_helper_acceptance.rb
  36. +3 −0 tests/README.md
  37. +3 −0 tests/ssl/ca/inventory.txt
  38. +1 −1 tests/ssl/ca/serial
  39. +36 −0 tests/ssl/ca/signed/sensu_backend1.pem
  40. +36 −0 tests/ssl/ca/signed/sensu_backend2.pem
  41. +36 −0 tests/ssl/ca/signed/sensu_backend3.pem
  42. +34 −34 tests/ssl/certs/sensu_backend1.pem
  43. +34 −34 tests/ssl/certs/sensu_backend2.pem
  44. +34 −34 tests/ssl/certs/sensu_backend3.pem
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ matrix:
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
env: BEAKER_set="centos-7" BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_sensu_full=yes BEAKER_sensu_use_agent=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_use_agent=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.4.4
sudo: required
services: docker
Expand All @@ -76,6 +88,18 @@ matrix:
env: BEAKER_set="centos-7-cluster" BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_sensu_cluster=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.4.4
sudo: required
services: docker
env: BEAKER_set="centos-7-cluster" BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_sensu_cluster=yes BEAKER_sensu_use_agent=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_use_agent=yes
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
Expand Down
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [v3.4.1](https://github.com/sensu/sensu-puppet/tree/v3.4.1) (2019-07-19)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.4.0...v3.4.1)

**Merged pull requests:**

- Add acceptance tests that use puppetserver [\#1123](https://github.com/sensu/sensu-puppet/pull/1123) ([treydock](https://github.com/treydock))
- Fix to support Puppetserver 5 [\#1122](https://github.com/sensu/sensu-puppet/pull/1122) ([treydock](https://github.com/treydock))

## [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)

Expand All @@ -10,6 +18,7 @@
- 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))
- Support Sensu Go 5.6 [\#1105](https://github.com/sensu/sensu-puppet/pull/1105) ([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 All @@ -24,10 +33,6 @@
## [v3.2.0](https://github.com/sensu/sensu-puppet/tree/v3.2.0) (2019-05-06)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.1.0...v3.2.0)

**Merged pull requests:**

- Support Sensu Go 5.6 [\#1105](https://github.com/sensu/sensu-puppet/pull/1105) ([treydock](https://github.com/treydock))

## [v3.1.0](https://github.com/sensu/sensu-puppet/tree/v3.1.0) (2019-04-19)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.0.0...v3.1.0)

Expand Down
14 changes: 14 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ _Private Classes_
* [`sensu_user`](#sensu_user): Manages Sensu users
* [`sensuctl_config`](#sensuctl_config): Abstract type to configure other types

**Data types**

* [`Sensu::Backend_URL`](#sensubackend_url): Sensu Backend URL's require protocol of ws:// or wss://. A port is also required. There is logic in sensu::agent class to add the protocol so

## Classes

### sensu
Expand Down Expand Up @@ -2480,3 +2484,13 @@ The name of the resource.

sensuctl chunk-size

## Data types

### Sensu::Backend_URL

Sensu Backend URL's require protocol of ws:// or wss://.
A port is also required.
There is logic in sensu::agent class to add the protocol so it's optional.

Alias of `Variant[Pattern[/^[^\s:]+:\d+$/], Pattern[/^ws:\/\/[^\s:]+:\d+$/], Pattern[/^wss:\/\/[^\s:]++:\d+$/]]`

22 changes: 0 additions & 22 deletions lib/puppet/provider/sensuctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,6 @@ def sensuctl_delete(*args)
self.class.sensuctl_delete(*args)
end

def self.sensuctl_set(command, name, property, value: nil, flags: nil)
args = [command]
args << "set-" + property.gsub('_', '-')
args << name
args << value unless value.nil?
args += flags unless flags.nil?
sensuctl(args)
end
def sensuctl_set(*args)
self.class.sensuctl_set(*args)
end

def self.sensuctl_remove(command, name, property)
args = [command]
args << "remove-" + property.gsub('_', '-')
args << name
sensuctl(args)
end
def sensuctl_remove(*args)
self.class.sensuctl_remove(*args)
end

def self.sensuctl_auth_types()
output = sensuctl(['auth','list','--format','yaml'])
Puppet.debug("YAML auth list: #{output}")
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": "3.4.0",
"version": "3.4.1",
"author": "sensu",
"summary": "A module to install the Sensu monitoring framework",
"license": "MIT",
Expand Down
42 changes: 33 additions & 9 deletions spec/acceptance/00_backend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ class { '::sensu::backend':
}
EOS

# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_backend' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
end
end

describe service('sensu-backend'), :node => node do
Expand All @@ -39,9 +47,17 @@ class { '::sensu::agent':
}
EOS

# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_backend' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
end
end

describe service('sensu-backend'), :node => node do
Expand All @@ -64,9 +80,17 @@ class { '::sensu::backend':
}
EOS

# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_backend' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
end
end

describe service('sensu-backend'), :node => node do
Expand Down
14 changes: 11 additions & 3 deletions spec/acceptance/01_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ class { '::sensu::agent':
}
EOS

# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_agent' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
end
end

describe service('sensu-agent'), :node => node do
Expand Down
54 changes: 40 additions & 14 deletions spec/acceptance/02_backend_cluster_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,29 @@ class { '::sensu::backend':
}
EOS

# First run will fail to run sensuctl configure
apply_manifest_on(node1, node1_pp, :acceptable_exit_codes => [0,1])
#on node1, 'curl http://127.0.0.1:8080/info', :accept_all_exit_codes => true
apply_manifest_on(node2, node2_pp, :catch_failures => true)
# first node has to have agent started back up
#on node1, 'systemctl status sensu-agent -l', :accept_all_exit_codes => true
#on node1, 'curl http://127.0.0.1:8080/info', :accept_all_exit_codes => true
apply_manifest_on(node1, node1_pp, :catch_failures => true)
apply_manifest_on(node1, node1_pp, :catch_changes => true)
apply_manifest_on(node2, node2_pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = <<-EOS
node 'sensu_backend1' { #{node1_pp} }
node 'sensu_backend2' { #{node2_pp} }
EOS
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
# First run will fail to run sensuctl configure
on node1, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,1]
on node2, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
# first node has to have agent started back up
on node1, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on node1, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
on node2, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# First run will fail to run sensuctl configure
apply_manifest_on(node1, node1_pp, :acceptable_exit_codes => [0,1])
apply_manifest_on(node2, node2_pp, :catch_failures => true)
# first node has to have agent started back up
apply_manifest_on(node1, node1_pp, :catch_failures => true)
apply_manifest_on(node1, node1_pp, :catch_changes => true)
apply_manifest_on(node2, node2_pp, :catch_changes => true)
end
end

describe service('sensu-backend'), :node => node1 do
Expand Down Expand Up @@ -93,10 +106,23 @@ class { '::sensu::backend':
}
EOS

apply_manifest_on(node1, pp, :catch_failures => true)
apply_manifest_on(node3, node3_pp, :catch_failures => true)
apply_manifest_on(node1, pp, :catch_changes => true)
apply_manifest_on(node3, node3_pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = <<-EOS
node 'sensu_backend1' { #{pp} }
node 'sensu_backend3' { #{node3_pp} }
EOS
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on node1, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on node3, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on node1, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
on node3, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
apply_manifest_on(node1, pp, :catch_failures => true)
apply_manifest_on(node3, node3_pp, :catch_failures => true)
apply_manifest_on(node1, pp, :catch_changes => true)
apply_manifest_on(node3, node3_pp, :catch_changes => true)
end
end

describe service('sensu-backend'), :node => node3 do
Expand Down
27 changes: 22 additions & 5 deletions spec/acceptance/03_no_ssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ class { '::sensu::backend':

# Ensure agent entity doesn't get re-added
on agent, 'puppet resource service sensu-agent ensure=stopped'
apply_manifest_on(backend, pp, :catch_failures => true)
apply_manifest_on(backend, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_backend' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on backend, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on backend, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(backend, pp, :catch_failures => true)
apply_manifest_on(backend, pp, :catch_changes => true)
end
end

describe service('sensu-backend'), :node => backend do
Expand All @@ -48,9 +57,17 @@ class { '::sensu::agent':
}
EOS

# Run it twice and test for idempotency
apply_manifest_on(agent, pp, :catch_failures => true)
apply_manifest_on(agent, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_agent' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on agent, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on agent, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(agent, pp, :catch_failures => true)
apply_manifest_on(agent, pp, :catch_changes => true)
end
end

describe service('sensu-agent'), :node => agent do
Expand Down
28 changes: 22 additions & 6 deletions spec/acceptance/04_plugins_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ class { '::sensu::plugins':
}
EOS

# Run it twice and test for idempotency
apply_manifest_on(agent, pp, :catch_failures => true)
apply_manifest_on(agent, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_agent' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on agent, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on agent, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(agent, pp, :catch_failures => true)
apply_manifest_on(agent, pp, :catch_changes => true)
end
end

describe package('sensu-plugins-ruby'), :node => agent do
Expand Down Expand Up @@ -59,9 +67,17 @@ class { '::sensu::plugins':
}
EOS

# Run it twice and test for idempotency
apply_manifest_on(backend, pp, :catch_failures => true)
apply_manifest_on(backend, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_backend' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on backend, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on backend, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(backend, pp, :catch_failures => true)
apply_manifest_on(backend, pp, :catch_changes => true)
end
end

describe package('sensu-plugins-ruby'), :node => backend do
Expand Down
14 changes: 11 additions & 3 deletions spec/acceptance/05_enterprise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ class { '::sensu::backend':
}
EOS

# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu_backend' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0,2]
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [0]
else
# Run it twice and test for idempotency
apply_manifest_on(node, pp, :catch_failures => true)
apply_manifest_on(node, pp, :catch_changes => true)
end
end

describe command('sensuctl license info'), :node => node do
Expand Down
Loading