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

[dev.icinga.com #12095] boolean custom field and assign rules does not work #339

Closed
icinga-migration opened this issue Jul 5, 2016 · 32 comments
Assignees
Labels
Milestone

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/12095

Created by Tuxdiver on 2016-07-05 09:25:49 +00:00

Assignee: (none)
Status: New
Target Version: 1.3.1
Last Update: 2016-11-30 08:37:27 +00:00 (in Redmine)


Using a custom field of type boolean and trying to use this in an apply rule does not work, because director always adds quotes around the value part:

    assign where host.vars.test_boolean == "true"

I think, this should be:

    assign where host.vars.test_boolean == true

Solution: remember the field type while generating the code for the apply rule

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-10-24 04:42:07 +00:00

  • Target Version set to 1.2.0

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-11-03 13:01:13 +00:00

  • Target Version changed from 1.2.0 to 1.3.0
  • Done % changed from 0 to 50

Already works for internal boolean, needs some more tweaking for vars - will be implemented soon, but is too late for 1.2.0.

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-11-30 08:37:28 +00:00

  • Target Version changed from 1.3.0 to 1.3.1

@icinga-migration icinga-migration added this to the 1.3.1 milestone Jan 17, 2017
@Thomas-Gelf Thomas-Gelf removed this from the 1.3.1 milestone Feb 17, 2017
@friesoft
Copy link
Contributor

friesoft commented Mar 1, 2017

Any news? :) Seems to apply everywhere where apply rules are used (notifications, service groups, ...)

@rajo
Copy link

rajo commented Mar 9, 2017

+1 this would really be helpful if this would work soon

edited: this also seems to hold true, when I assign custom fields to a template and want another custom field be filtered upon another boolean field - doesn't work either

@widhalmt
Copy link
Member

widhalmt commented Mar 16, 2017

+1 from me. I just hit that as well.

@SimonHoenscheid
Copy link

+1

2 similar comments
@jcromero
Copy link

+1

@Meinen
Copy link

Meinen commented Apr 6, 2017

+1

@noriah
Copy link

noriah commented Apr 13, 2017

Any news on this yet?

@xtruthx
Copy link

xtruthx commented Apr 21, 2017

+1

@MaartenUreel
Copy link

+1
still a big issue

@vita2
Copy link
Contributor

vita2 commented Apr 24, 2017

+1
i need this for assignment rules to check if host notifications are enabled

apply Notification "host-mail" to Host {
    import "notification-mail"

    assign where host.enable_notifications == "true"
    user_groups = [ "netadmins" ]
}

@papst01
Copy link

papst01 commented May 10, 2017

+1

10 similar comments
@kjde
Copy link

kjde commented Jun 7, 2017

+1

@Foxeronie
Copy link

+1

@kajla
Copy link

kajla commented Jun 14, 2017

+1

@wlma
Copy link

wlma commented Jun 21, 2017

+1

@Hrocc
Copy link

Hrocc commented Jun 23, 2017

+1

@itsopensource
Copy link

+1

@chas0rde
Copy link

+1

@fireheadman
Copy link

+1

@cyberkov
Copy link

+1

@wols
Copy link

wols commented Jul 30, 2017

+1

@vita2
Copy link
Contributor

vita2 commented Jul 31, 2017

hello @Thomas-Gelf,

it would be nice if you could consider a fix for this issue in the upcoming 1.4 release ☺️

@Thomas-Gelf
Copy link
Contributor

No more likes? I should wait for more of them...

...just kidding 😆 I hear you!

@Thomas-Gelf Thomas-Gelf self-assigned this Aug 25, 2017
@Thomas-Gelf
Copy link
Contributor

Anyone involved here: could you please let me know whether the implementation for the linked feature request solves your problem? It does not try to "understand" the strings "true" or "false" and it does not do anything for false (you can use a negation for this). But it provides is true (or set) as a new virtual operator type, and renders to where <chosen.property>. So you can use it for boolean true or also to say assign where host.address6 (or similar).

Cheers,
Thomas

@vita2
Copy link
Contributor

vita2 commented Aug 25, 2017

now it is possible to build a assignment rule for notifications which only matches if "enable_notifications" was set. example:

zones.d/master/notification_apply.conf

apply Notification "host-1st-pushover" to Host {
    import "template-pushover-host"
    import "template-host-1st"

    assign where host.address && host.enable_notifications
    user_groups = [ "netadmins" ]
}

it is also possible to create a service-apply-rule which only hits if a certain custom host variable was set to true. example:

zones.d/director-global/service_apply.conf

apply Service "booleantest" {
    import "dummy"

    assign where host.vars.booleantest

    import DirectorOverrideTemplate
}

for me, it works as expected now. thank you!

have a nice weekend 🍻😄

@Thomas-Gelf
Copy link
Contributor

@vita2: who needs a weekend - didn't you notice that I'm on vacation since two weeks? Glad to hear that it works for you!

@menewol
Copy link

menewol commented Sep 7, 2017

does this only work if writing the service_apply.conf manually? im trying to match wether a host has an odd ip address with the regex function in the icinga director. my regex "[13579]$" matches for the very last digit in the ipaddress, so if a host has an odd address this should match to true.

i've attached 2 screenshots...this is either still a problem for the director or i'm doing something terribly wrong. if second please just point it out to me so i'll go on finding the right solution!
service_apply
render_failure
best regards, wolfgang

@Foxeronie
Copy link

@menewol You can set the "=" to "is true (or set)" to use this on vars, addresses, etc.
But I dont think you can insert a regex rule in the first field.
I opened a regex feature request already. #435

@menewol
Copy link

menewol commented Sep 7, 2017

@Foxeronie which version is it you are using? we're running 2.4.1 and theres no "is true (or set)" option. should this assign where rule work if it is set up manually?

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