17 changes: 12 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

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

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

### Added

- Add examples for Slack and InfluxDB [\#1199](https://github.com/sensu/sensu-puppet/pull/1199) ([treydock](https://github.com/treydock))
- Allow SSL files to be defined via content parameters [\#1198](https://github.com/sensu/sensu-puppet/pull/1198) ([treydock](https://github.com/treydock))

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

[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v4.0.0...v4.1.0)
Expand Down Expand Up @@ -162,9 +171,9 @@

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

### Added
### Fixed

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

Expand All @@ -178,7 +187,6 @@

### Fixed

- Fix to support Puppetserver 5 [\#1122](https://github.com/sensu/sensu-puppet/pull/1122) ([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))
- Regenerate backend test cert to include additional SANs [\#1113](https://github.com/sensu/sensu-puppet/pull/1113) ([treydock](https://github.com/treydock))

Expand All @@ -188,6 +196,7 @@

### Added

- Add acceptance tests that use puppetserver [\#1123](https://github.com/sensu/sensu-puppet/pull/1123) ([treydock](https://github.com/treydock))
- \(GH-1111\) Remove Ubuntu 14.04 LTS as it is end of life \(EOL\) [\#1112](https://github.com/sensu/sensu-puppet/pull/1112) ([ghoneycutt](https://github.com/ghoneycutt))
- Add Windows support for Sensu Go agent [\#1108](https://github.com/sensu/sensu-puppet/pull/1108) ([treydock](https://github.com/treydock))

Expand All @@ -212,12 +221,10 @@

- Prep 3.1.0 release [\#1103](https://github.com/sensu/sensu-puppet/pull/1103) ([treydock](https://github.com/treydock))
- Support opting out of tessen phone home [\#1101](https://github.com/sensu/sensu-puppet/pull/1101) ([treydock](https://github.com/treydock))
- Hiera resources [\#1097](https://github.com/sensu/sensu-puppet/pull/1097) ([treydock](https://github.com/treydock))

### Fixed

- Do not raise errors if custom puppet facts are undefined [\#1100](https://github.com/sensu/sensu-puppet/pull/1100) ([treydock](https://github.com/treydock))
- Fix Puppet Strings documentation URL [\#1096](https://github.com/sensu/sensu-puppet/pull/1096) ([treydock](https://github.com/treydock))



Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2013 James Turnbull, Jeremy Carroll, Justin Lambert, Tim Sharpe
Copyright (C) 2017-2019 Garrett Honeycutt <code@garretthoneycutt.com>
Copyright (C) 2017-2020 Garrett Honeycutt <code@garretthoneycutt.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
30 changes: 30 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,19 @@ Default value: `true`
Data type: `Optional[String]`

Source of SSL CA used by sensu services
This parameter is mutually exclusive with ssl_ca_content

Default value: $facts['puppet_localcacert']

##### `ssl_ca_content`

Data type: `Optional[String]`

Content of SSL CA used by sensu services
This parameter is mutually exclusive with ssl_ca_source

Default value: `undef`

##### `api_host`

Data type: `String`
Expand Down Expand Up @@ -527,17 +537,37 @@ Default value: {}
Data type: `Optional[String]`

The SSL certificate source
This parameter is mutually exclusive with ssl_cert_content

Default value: $facts['puppet_hostcert']

##### `ssl_cert_content`

Data type: `Optional[String]`

The SSL certificate content
This parameter is mutually exclusive with ssl_cert_source

Default value: `undef`

##### `ssl_key_source`

Data type: `Optional[String]`

The SSL private key source
This parameter is mutually exclusive with ssl_key_content

Default value: $facts['puppet_hostprivkey']

##### `ssl_key_content`

Data type: `Optional[String]`

The SSL private key content
This parameter is mutually exclusive with ssl_key_source

Default value: `undef`

##### `include_default_resources`

Data type: `Boolean`
Expand Down
59 changes: 59 additions & 0 deletions examples/contact_routing.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
include sensu::backend

sensu_bonsai_asset { 'sensu/sensu-go-has-contact-filter':
ensure => 'present',
version => 'latest',
}

sensu_filter { 'contact_dev':
ensure => 'present',
action => 'allow',
runtime_assets => ['sensu/sensu-go-has-contact-filter'],
expressions => ['has_contact(event, "dev")'],
}
sensu_filter { 'contact_ops':
ensure => 'present',
action => 'allow',
runtime_assets => ['sensu/sensu-go-has-contact-filter'],
expressions => ['has_contact(event, "ops")'],
}

sensu_bonsai_asset { 'sensu/sensu-email-handler':
ensure => 'present',
version => 'latest',
}

sensu_handler { 'email_dev':
ensure => 'present',
type => 'pipe',
command => 'sensu-email-handler -f root@localhost -t dev@example.com -s localhost -i',
timeout => 10,
runtime_assets => ['sensu/sensu-email-handler'],
filters => ['is_incident','not_silenced','contact_dev'],
}
sensu_handler { 'email_ops':
ensure => 'present',
type => 'pipe',
command => 'sensu-email-handler -f root@localhost -t ops@example.com -s localhost -i',
timeout => 10,
runtime_assets => ['sensu/sensu-email-handler'],
filters => ['is_incident','not_silenced','contact_ops'],
}
sensu_handler { 'email':
ensure => 'present',
type => 'set',
handlers => ['email_dev','email_ops'],
}

sensu_check { 'check_cpu':
ensure => 'present',
labels => {
'contacts' => 'dev, ops',
},
command => 'check-cpu.rb -w 75 -c 90',
handlers => ['email'],
interval => 30,
publish => true,
subscriptions => ['linux'],
runtime_assets => ['sensu-plugins-cpu-checks','sensu-ruby-runtime'],
}
31 changes: 31 additions & 0 deletions examples/influxdb_handler.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$addr = 'http://influxdb.default.svc.cluster.local:8086'
$db_name = 'sensu'
$user = 'sensu'
$password = 'password'

include sensu::backend

sensu_bonsai_asset { 'sensu/sensu-influxdb-handler':
ensure => 'present',
version => 'latest',
}

sensu_handler { 'influx-db':
type => 'pipe',
env_vars => [
"INFLUXDB_ADDR=${addr}",
"INFLUXDB_USER=${user}",
"INFLUXDB_PASS=${password}",
],
command => "sensu-influxdb-handler -d ${db_name}",
runtime_assets => ['sensu/sensu-influxdb-handler'],
}

sensu_check { 'collect-metrics':
command => 'collect_metrics.sh',
output_metric_format => 'influxdb_line',
output_metric_handlers => ['influx-db'],
interval => 60,
publish => true,
subscriptions => ['linux'],
}
26 changes: 26 additions & 0 deletions examples/slack_alerts.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$webhook_url = 'https://hooks.slack.com/services/T0000/B000/XXXXXXXX'
$channel = '#monitor'

include sensu::backend

sensu_bonsai_asset { 'sensu/sensu-slack-handler':
ensure => 'present',
version => 'latest',
}

sensu_handler { 'slack':
type => 'pipe',
env_vars => ["SLACK_WEBHOOK_URL=${webhook_url}"],
command => "sensu-slack-handler --channel '${channel}'",
runtime_assets => ['sensu/sensu-slack-handler'],
}

sensu_check { 'check_cpu':
ensure => 'present',
command => 'check-cpu.rb -w 75 -c 90',
handlers => ['slack'],
interval => 30,
publish => true,
subscriptions => ['linux'],
runtime_assets => ['sensu-plugins-cpu-checks','sensu-ruby-runtime'],
}
34 changes: 28 additions & 6 deletions manifests/backend.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@
# Sensu backend configuration hash used to define backend.yml.
# @param ssl_cert_source
# The SSL certificate source
# This parameter is mutually exclusive with ssl_cert_content
# @param ssl_cert_content
# The SSL certificate content
# This parameter is mutually exclusive with ssl_cert_source
# @param ssl_key_source
# The SSL private key source
# This parameter is mutually exclusive with ssl_key_content
# @param ssl_key_content
# The SSL private key content
# This parameter is mutually exclusive with ssl_key_source
# @param include_default_resources
# Sets if default sensu resources should be included
# @param show_diff
Expand Down Expand Up @@ -78,7 +86,9 @@
Stdlib::Absolutepath $state_dir = '/var/lib/sensu/sensu-backend',
Hash $config_hash = {},
Optional[String] $ssl_cert_source = $facts['puppet_hostcert'],
Optional[String] $ssl_cert_content = undef,
Optional[String] $ssl_key_source = $facts['puppet_hostprivkey'],
Optional[String] $ssl_key_content = undef,
Boolean $include_default_resources = true,
Boolean $show_diff = true,
Optional[String] $license_source = undef,
Expand Down Expand Up @@ -118,14 +128,24 @@
$api_protocol = $sensu::api_protocol
$password = $sensu::password

if $use_ssl and ! $ssl_cert_source {
fail('sensu::backend: ssl_cert_source must be defined when sensu::use_ssl is true')
if $ssl_cert_content {
$_ssl_cert_source = undef
} else {
$_ssl_cert_source = $ssl_cert_source
}
if $use_ssl and ! $ssl_key_source {
fail('sensu::backend: ssl_key_source must be defined when sensu::use_ssl is true')
if $ssl_key_content {
$_ssl_key_source = undef
} else {
$_ssl_key_source = $ssl_key_source
}

if $use_ssl {
if !($_ssl_cert_source or $ssl_cert_content) {
fail('sensu::backend: ssl_cert_source or ssl_cert_content must be defined when sensu::use_ssl is true')
}
if !($_ssl_key_source or $ssl_key_content) {
fail('sensu::backend: ssl_key_source or ssl_key_content must be defined when sensu::use_ssl is true')
}
$trusted_ca_file = "${ssl_dir}/ca.crt"
$ssl_config = {
'cert-file' => "${ssl_dir}/cert.pem",
Expand Down Expand Up @@ -202,7 +222,8 @@
file { 'sensu_ssl_cert':
ensure => 'file',
path => "${ssl_dir}/cert.pem",
source => $ssl_cert_source,
source => $_ssl_cert_source,
content => $ssl_cert_content,
owner => $sensu::user,
group => $sensu::group,
mode => '0644',
Expand All @@ -212,7 +233,8 @@
file { 'sensu_ssl_key':
ensure => 'file',
path => "${ssl_dir}/key.pem",
source => $ssl_key_source,
source => $_ssl_key_source,
content => $ssl_key_content,
owner => $sensu::user,
group => $sensu::group,
mode => '0600',
Expand Down
15 changes: 13 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
#
# @param ssl_ca_source
# Source of SSL CA used by sensu services
# This parameter is mutually exclusive with ssl_ca_content
#
# @param ssl_ca_content
# Content of SSL CA used by sensu services
# This parameter is mutually exclusive with ssl_ca_source
#
# @param api_host
# Sensu backend host used to configure sensuctl and verify API access.
Expand All @@ -67,6 +72,7 @@
Boolean $manage_repo = true,
Boolean $use_ssl = true,
Optional[String] $ssl_ca_source = $facts['puppet_localcacert'],
Optional[String] $ssl_ca_content = undef,
String $api_host = $trusted['certname'],
Stdlib::Port $api_port = 8080,
String $password = 'P@ssw0rd!',
Expand All @@ -75,8 +81,13 @@
Optional[String] $agent_old_password = undef,
) {

if $use_ssl and ! $ssl_ca_source {
fail('sensu: ssl_ca_source must be defined when use_ssl is true')
if $ssl_ca_content {
$_ssl_ca_source = undef
} else {
$_ssl_ca_source = $ssl_ca_source
}
if $use_ssl and !($_ssl_ca_source or $ssl_ca_content) {
fail('sensu: ssl_ca_source or ssl_ca_content must be defined when use_ssl is true')
}

if $facts['os']['family'] == 'windows' {
Expand Down
3 changes: 2 additions & 1 deletion manifests/ssl.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
group => $sensu::sensu_group,
mode => $file_mode,
show_diff => false,
source => $sensu::ssl_ca_source,
source => $sensu::_ssl_ca_source,
content => $sensu::ssl_ca_content,
}
}
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": "4.1.0",
"version": "4.2.0",
"author": "sensu",
"summary": "A module to install the Sensu monitoring framework",
"license": "MIT",
Expand Down
Loading