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

Question about overriding check command #459

Closed
jsfrerot opened this issue Dec 23, 2015 · 3 comments
Closed

Question about overriding check command #459

jsfrerot opened this issue Dec 23, 2015 · 3 comments

Comments

@jsfrerot
Copy link

Hi,
I'm trying to override a check command on a specific node. This check is defined in my base class which is included on all my nodes. Then I would like to change some parameters on the check command on specific servers which are exceptions.

This is in my base module
sensu::check {'check_openmanage':
command => '/usr/lib64/nagios/plugins/check_openmanage -b ctrl_fw=0',
handlers => 'default',
standalone => false,
subscribers => 'dell',
}

for specific servers with no supported controller I need to add "--no-storage" param to my check command. I am using hiera to add the spcific commands parameters like this:
sensu::checks:
'check_openmanage':
command: '/usr/lib64/nagios/plugins/check_openmanage --no-storage -b ctrl_fw=0'
handlers: 'default'
standalone: false
subscribers: 'dell'

However I get the following error which is kind of expected:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Sensu::Check[check_openmanage] is already declared in file modules/base/manifests/dell.pp:18; cannot redeclare at puppet/modules/sensu/manifests/init.pp:428 on node 'my node'

So i'm wondering how can I achieve my goal without having to add if $::fqdn == 'my_node_name' blocks in my base class?

@jlambert121
Copy link
Contributor

In the past I've solved this by defining a variable that either supplies --no-storage or an empty string to be inserted when the check is created based on a fact or something else known, but that doesn't work as smoothly in hiera. I'm wondering if $extensions, $handlers, and $checks should use hiera_hash to fetch and merge their values. Would that solve this issue for you?

@jaxxstorm
Copy link
Contributor

jaxxstorm commented Sep 15, 2016

I think @jlambert121 has it right. I'd do it like this:

class base (
  $storage = undef
) {

if $storage {
    $storage_real = $storage
}

sensu::check {'check_openmanage':
  command => "/usr/lib64/nagios/plugins/check_openmanage -b ctrl_fw=0 $storage_real",
  handlers => 'default',
  standalone => false,
  subscribers => 'dell',
  }
}

Then you can override it in hiera, otherwise it'll be undef:

role.yaml
base::storage: true

@jaxxstorm
Copy link
Contributor

Please reopen if you need further assistance

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