Skip to content

Commit

Permalink
Merge pull request #835 from alvagante/834
Browse files Browse the repository at this point in the history
Set a defauly empty array for redact #834
  • Loading branch information
ghoneycutt authored Nov 2, 2017
2 parents 66845f1 + 8dab658 commit ce82fca
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/puppet/type/sensu_client_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ def initialize(*args)

newproperty(:subscriptions, :array_matching => :all) do
desc ""
newvalues(/.*/, :absent)
def insync?(is)
is.sort == should.sort
return is.sort == should.sort if is.is_a?(Array) && should.is_a?(Array)
is == should
end
end

newproperty(:redact, :array_matching => :all) do
desc "An array of strings that should be redacted in the sensu client config"
newvalues(/.*/, :absent)
def insync?(is)
is.sort == should.sort
return is.sort == should.sort if is.is_a?(Array) && should.is_a?(Array)
is == should
end
end

Expand Down
105 changes: 105 additions & 0 deletions tests/sensu-834.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
node 'sensu-server' {
$deregistration = { 'handler' => 'deregister_client' }

class { '::sensu':
install_repo => true,
server => true,
manage_services => true,
manage_user => true,
rabbitmq_password => 'correct-horse-battery-staple',
rabbitmq_vhost => '/sensu',
spawn_limit => 16,
api => true,
api_user => 'admin',
api_password => 'secret',
client_address => $::ipaddress_eth1,
subscriptions => ['all', 'roundrobin:poller'],
client_deregister => true,
client_deregistration => $deregistration,
redact => ["password", "passwd", "pass", "api_key", "api_token", "access_key", "secret_key", "private_key", "secret", "ec2_access_key", "ec2_secret_key"],
}

sensu::handler { 'default':
command => 'mail -s \'sensu alert\' ops@example.com',
}

# Example handler which operates in silenced checks
#
# This should create a file in /etc/sensu/conf.d/handlers/handle_silenced.json, containing the following:
#
# {
# "handlers": {
# "mail_handle_silenced": {
# "command": "mail -s 'sensu alert' ops@example.com",
# "type": "pipe",
# "filters": [
#
# ],
# "severities": [
# "ok",
# "warning",
# "critical",
# "unknown"
# ],
# "handle_flapping": false,
# "handle_silenced": true
# }
# }
# }
sensu::handler { 'mail_handle_silenced':
command => 'mail -s \'sensu alert\' ops@example.com',
handle_silenced => true,
}

sensu::check { 'check_ntp':
command => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
handlers => 'default',
subscribers => 'sensu-test',
}

$proxy_requests_ntp = {
'client_attributes' => {
'subscriptions' => 'eval: value.include?("ntp")',
},
}

# Example check using the cron schedule.
sensu::check { 'remote_check_ntp':
command => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H :::address::: -w 30 -c 60',
standalone => false,
handlers => 'default',
subscribers => 'roundrobin:poller',
cron => '*/5 * * * *',
proxy_requests => $proxy_requests_ntp,
}

# A client defined in the Dashboard with a subscription of "http" will
# automatically have this check associated with it. Check Google with the
# following API call to create a proxy client definition:
#
# curl -s -i -X POST -H 'Content-Type: application/json' \
# -d '{"name":"google.com","address":"google.com","subscriptions":["http"]}' \
# http://admin:secret@127.0.0.1:4567/clients
#
# Then, trigger the check with:
#
# curl -s -i -X POST -H 'Content-Type: application/json' \
# -d '{"check": "remote_http"}' \
# http://admin:secret@127.0.0.1:4567/request
$proxy_requests_http = {
'client_attributes' => {
'subscriptions' => 'eval: value.include?("http")',
},
}
sensu::check { 'remote_http':
command => '/opt/sensu/embedded/bin/check-http.rb -u http://:::address:::',
occurrences => 2,
interval => 300,
refresh => 600,
low_flap_threshold => 20,
high_flap_threshold => 60,
standalone => false,
subscribers => 'roundrobin:poller',
proxy_requests => $proxy_requests_http,
}
}

0 comments on commit ce82fca

Please sign in to comment.