Skip to content
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

subdue should be optional for sensu check definition #548

Closed
cabecada opened this issue Sep 9, 2016 · 7 comments
Closed

subdue should be optional for sensu check definition #548

cabecada opened this issue Sep 9, 2016 · 7 comments
Milestone

Comments

@cabecada
Copy link

cabecada commented Sep 9, 2016

because of this
https://github.com/sensu/sensu-settings/blob/37d22949f586015075de65881b61b5004bde9b55/spec/validator_spec.rb#L260

this
https://github.com/sensu/sensu-puppet/blob/master/manifests/check.pp#L180
would break.

we need to manage the hash to sensu_check { } that would filter out subdue attribute if not defined or empty hash

@ttarczynski
Copy link
Contributor

@cabecada is what you need the same as described in:

@jaxxstorm
Copy link
Contributor

I think we need to completely rework the sensu subdue stuff for 0.26. I'd love someone to take a bash at this.

@jaxxstorm jaxxstorm added this to the 2.2.0 milestone Sep 15, 2016
@jaxxstorm jaxxstorm mentioned this issue Sep 15, 2016
3 tasks
@cabecada
Copy link
Author

cabecada commented Sep 16, 2016

root@sensu-server:~# cat /etc/puppet/modules/sensu/lib/facter/sensu_version.rb
require 'puppet'
Facter.add("sensu_version") do
  setcode do
    if Facter::Util::Resolution.which('dpkg-query')
      sensu_version = Facter::Util::Resolution.exec('dpkg-query --showformat=\'${Version}\' --show sensu')
    elsif Facter::Util::Resolution.which('rpm')
      sensu_version = Facter::Util::Resolution.exec('rpm -q sensu --qf \'%{VERSION}\'')
    end
  end
end

root@sensu-server:~# puppet apply -e 'notify {"${::sensu_version}": } '
Notice: Compiled catalog for sensu-server.example.com in environment production in 0.01 seconds
Notice: 0.26.1-1
Notice: /Stage[main]/Main/Notify[0.26.1-1]/message: defined 'message' as '0.26.1-1'
Notice: Finished catalog run in 0.04 seconds

a facter variable will help us take care of backward compatibity too :)

@cabecada
Copy link
Author

something like this

root@sensu-server:~# cat  /tmp/foo.pp


notify { "${::sensu_version}": }

if "${::sensu_version}" < "0.26.1-1" {
  $subdue = {}
} else {
  $subdue = {
    'days' => {
      'all' => [
        {
          'begin' => '00:00',
          'end'   => '00:00',
        },
      ]
    }
  }
}

notify { "${subdue}": }
root@sensu-server:~# FACTER_sensu_version='0.25.5-1' puppet apply --modulepath /etc/puppet/modules /tmp/foo.pp
Notice: Compiled catalog for sensu-server.example.com in environment production in 0.02 seconds
Notice: 0.25.5-1
Notice: /Stage[main]/Main/Notify[0.25.5-1]/message: defined 'message' as '0.25.5-1'
Notice: {}
Notice: /Stage[main]/Main/Notify[{}]/message: defined 'message' as '{}'
Notice: Finished catalog run in 0.01 seconds
root@sensu-server:~# FACTER_sensu_version='0.26.1-1' puppet apply --modulepath /etc/puppet/modules /tmp/foo.pp
Notice: Compiled catalog for sensu-server.example.com in environment production in 0.02 seconds
Notice: 0.26.1-1
Notice: /Stage[main]/Main/Notify[0.26.1-1]/message: defined 'message' as '0.26.1-1'
Notice: {"days"=>{"all"=>[{"begin"=>"00:00", "end"=>"00:00"}]}}
Notice: /Stage[main]/Main/Notify[{"days"=>{"all"=>[{"begin"=>"00:00", "end"=>"00:00"}]}}]/message: defined 'message' as '{"days"=>{"all"=>[{"begin"=>"00:00", "end"=>"00:00"}]}}'
Notice: Finished catalog run in 0.01 seconds

@ttarczynski
Copy link
Contributor

@cabecada there's a plan to handle compatibility with information in module docs: #568

Removing subdue property is now possible with syntax described here: #565

@cabecada
Copy link
Author

+1

“absent” really makes sense over the default values :), and is really helpful too.
good work on this.

On Oct 31, 2016, at 11:53 AM, Tomasz Tarczynski <notifications@github.commailto:notifications@github.com> wrote:

@cabecadahttps://github.com/cabecada there's a plan to handle compatibility with information in module docs: #568#568

Removing subdue property is now possible with syntax described here: #565#565


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//issues/548#issuecomment-257221775, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ATSKkAOJ1KOuq1jiuggouD_6ZsWt8fG0ks5q5YlbgaJpZM4J5aBM.

@jaxxstorm
Copy link
Contributor

This is resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants