-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(#597) Add sensu::contact type (Enterprise Only) #728
(#597) Add sensu::contact type (Enterprise Only) #728
Conversation
Tested in Vagrant using sensu-server-enterprise |
lib/puppet/type/sensu_check.rb
Outdated
@@ -69,6 +69,15 @@ def insync?(is) | |||
end | |||
end | |||
|
|||
newproperty(:contacts, :array_matching => :all, :parent => SensuCheckArrayProperty) do | |||
desc "Contact names to override handler configuration via Contact Routing" | |||
newvalues(/.*/, :absent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex for valid contact name - https://sensuapp.org/docs/0.29/enterprise/contact-routing.html#contact-names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regex has been added both to sensu_check's contacts
property and sensu_contact's name
parameter. Spec tests have been updated to exercise the expected behavior of invalid names throwing Puppet::ResourceError's.
before => Sensu_contact[$name], | ||
} | ||
|
||
sensu_contact { $name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of a type/provider, what about using sensu_sorted_json() as is done in sensu::write_json? The current layout is to used defined types that then call custom type/providers. What about still calling defined types, but then replacing the type/provider code with sensu_sorted_json()? If possible, I think that would greatly simplify things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we still use resources {}
to purge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look. This also reminds me, self.instances
needs to be implemented in the type if we don't implement this using sensu_sorted_json().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #729 to track this independently of this PR and related enhancement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this documentation to the sensu::contact
defined type:
Note: If the
sensu::purge_config
class parameter istrue
, unmanagedsensu::contact
resources located in /etc/sensu/conf.d/contacts will be purged.
tests/sensu-server-enterprise.pp
Outdated
ensure => 'present', | ||
config => { 'email' => { 'to' => 'ops@example.com' } }, | ||
} | ||
sensu::contact { 'hacker': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest using another name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to “departed"
2cd45f6
to
3cfe2a8
Compare
@@ -144,7 +144,7 @@ | |||
} | |||
} | |||
|
|||
file { [ $::sensu::conf_dir, "${sensu::conf_dir}/handlers", "${sensu::conf_dir}/checks", "${sensu::conf_dir}/filters", "${sensu::conf_dir}/extensions", "${sensu::conf_dir}/mutators" ]: | |||
file { [ $::sensu::conf_dir, "${sensu::conf_dir}/handlers", "${sensu::conf_dir}/checks", "${sensu::conf_dir}/filters", "${sensu::conf_dir}/extensions", "${sensu::conf_dir}/mutators", "${sensu::conf_dir}/contacts" ]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
purge is there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, added documentation to sensu::contact to note this purge behavior.
ensure => $ensure, | ||
config => $config, | ||
base_path => $base_path, | ||
require => File['/etc/sensu/conf.d/contacts'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this notify the service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see it is in the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
Please add the example usage to the README. Besides that, else I think it's ready. |
3cfe2a8
to
89e7918
Compare
89e7918
to
fae56f7
Compare
README updated with a similar example to the vagrant manifest in |
manifests/contact.pp
Outdated
# = Define: sensu::routing | ||
# | ||
# Manage [Contact | ||
# Routing](https://sensuapp.org/docs/0.26/enterprise/contact-routing.html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're on 0.29. Best to use latest here though
https://sensuapp.org/docs/latest/enterprise/contact-routing.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to latest.
Without this patch the Puppet module doesn't provide an affordance for [contact routing](https://sensuapp.org/docs/0.29/enterprise/contact-routing.html) This patch addresses the problem by adding a new defined type, sensu::contact backed by a custom type and provider for sensu_contact. Example usage: sensu::contact { 'support': config => { 'email' => { 'to' => 'support@example.com' } }, } sensu::contact { 'ops': config => { 'email' => { 'to' => 'ops@example.com' } }, } sensu::check { 'check_ntp': command => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60', handlers => 'email', contacts => ['ops', 'support'], } Resolves sensu#597
fae56f7
to
4d767b2
Compare
Released in v2.20.0 |
Without this patch the Puppet module doesn't provide an affordance for contact
routing This
patch addresses the problem by adding a new defined type, sensu::contact backed
by a custom type and provider for sensu_contact.
Example usage:
Resolves #597