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

Assign rule regex seems incorrect #209

Closed
zachfi opened this issue Jan 21, 2017 · 6 comments
Closed

Assign rule regex seems incorrect #209

zachfi opened this issue Jan 21, 2017 · 6 comments
Labels

Comments

@zachfi
Copy link
Contributor

zachfi commented Jan 21, 2017

Hi. I'm starting to migrate to this module, and I'm trying to apply a service that looks like the following.

  icinga2::object::notification { 'slack-host':
    command      => 'slack-host-notification',
    users        => ['Ops'],
    apply        => true,
    apply_target => 'Host',
    assign       => ['host.vars.os'],
    interval     => 86400,
  }

The assign target fails with the following error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, validate_re(): "host.vars.os" does not match "^.+\\s+(=>\\s+.+\\s+)?in\\s+.+$" at /usr/local/etc/puppet/code/environments/newmon/modules/icinga2/manifests/object.pp:91:28 at /usr/local/etc/puppet/code/environments/newmon/modules/icinga2/manifests/object/service.pp:266 on node mon5.example.com

From my reading of the docs, and prior working with icinga2, the assign rule above should be valid. My goal is to assign this notification to a host where the os variable exists, no matter its value. Perhaps there is a better approach to this. Not all hosts have the os variable, since I might be monitoring external systems that don't run puppet, for example.

Is there a simple workaround, or does the regex need updating? Any advice here would be appreciated.

@zachfi
Copy link
Contributor Author

zachfi commented Jan 21, 2017

I just noticed #208, which looks related, but #208 looks like the regex at least passes. Maybe I'm doing something wrong.

@Reamer
Copy link
Contributor

Reamer commented Jan 22, 2017

I do something quite similar and it works for me with module v1.0.1.
My definition in hiera looks nearly the same:
my running configuration:

  mattermost_host:
    target: '/etc/icinga2/conf.d/notifications_apply.conf'
    apply: true
    apply_target: Host
    assign:
      - 'true'
    command: 'mattermost_host'
    states: [ 'Up', 'Down' ]
    types: [ 'Problem', 'Acknowledgement', 'Recovery', 'Custom', 'FlappingStart', 'FlappingEnd', 'DowntimeStart', 'DowntimeEnd', 'DowntimeRemoved' ]
    period: '24x7'
    users: [ 'mattermost' ]

But I also test with 'host.vars.os' and it works, no regex problems.

  mattermost_host:
    target: '/etc/icinga2/conf.d/notifications_apply.conf'
    apply: true
    apply_target: Host
    assign:
      - 'host.vars.os'
    command: 'mattermost_host'
    states: [ 'Up', 'Down' ]
    types: [ 'Problem', 'Acknowledgement', 'Recovery', 'Custom', 'FlappingStart', 'FlappingEnd', 'DowntimeStart', 'DowntimeEnd', 'DowntimeRemoved' ]
    period: '24x7'
    users: [ 'mattermost' ]

Best Regards
Reamer

@lbetz
Copy link
Contributor

lbetz commented Jan 23, 2017

Did you really use

assign => ['host.var.os'],

that looks like you forgot the 's' at the end of 'vars'? Of course, the error message doesn't help.

@bobapple
Copy link
Contributor

Can you also test the current master? #208 should be fixed there

@zachfi
Copy link
Contributor Author

zachfi commented Jan 23, 2017

I think the short var is a typo from my adjustment after the paste. It looks like my fork is missing a few commits. I'll rebase and test again.

@zachfi
Copy link
Contributor Author

zachfi commented Jan 23, 2017

I've rebased now and I look to be having a new error, so perhaps I opened this too soon. Thanks for the advice. I'll close this out and reopen if I see this issue again.

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

No branches or pull requests

4 participants