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 #12770] If-else statement #460

Closed
icinga-migration opened this issue Sep 22, 2016 · 4 comments
Closed

[dev.icinga.com #12770] If-else statement #460

icinga-migration opened this issue Sep 22, 2016 · 4 comments
Labels

Comments

@icinga-migration
Copy link

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

Created by siyalrach on 2016-09-22 13:36:09 +00:00

Assignee: (none)
Status: Rejected (closed on 2016-10-13 12:27:28 +00:00)
Target Version: (none)
Last Update: 2016-10-13 12:27:28 +00:00 (in Redmine)


Is it possible to implement this in Director ?

/**
 * Used to check which mode we are running
 */
template Service "running-mode" {
  if (host.vars.checkHost) {
    vars.devMode = false;
  } else {
    vars.devMode = !PRODUCTION
  }

  if (vars.devMode || host.vars.mute_notification) {
    vars.mute_notification = true
  }
}

In our environment we sometime debug hosts and don't want to spam users with notifications.


Relations:

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-09-23 14:35:05 +00:00

This is not gonna happen, not in this exact way. As a workaround you could manually deploy this template to your Icinga node and allow Director to use it by a) defining it as an "external object" and b) creating an intermediary wrapper template as the GUI wouldn't allow you to inherit from external objects.

As the GUI doesn't allow you to use that feature you have to prepare this through the REST API or by using the CLI as follows:

icingacli director host create running-mode --object_type external_object
icingacli director host create running-mode-wrapper --object_type template --imports running-mode

Your hosts in Director should then be allowed to inherit from 'running-mode-wrapper' and work as expected. When working with multiple Icinga instances this might require you to install this template everywhere. In that case please have a look at the fileshipper module - it allows you to ship custom config through the Director.

In future you will be allowed to also solve this in the following ways:

  • through notification apply rules: Director is able to render nested conditions since a long time, but GUI elements are still missing. This will however not allow you to set devMode depending on two other properties
  • by moving the logic of this to a custom function, this will be implemented with #11982 and allow you to a) define a function and b) define vars based on (parameterized) functions

Cheers,
Thomas

@icinga-migration
Copy link
Author

Updated by siyalrach on 2016-09-25 16:31:54 +00:00

Thx..
I didn't know that is was possible to reference external object from Director module, but I will try to implement it like that :).

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-10-13 12:26:05 +00:00

  • Relates set to 11982

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-10-13 12:27:28 +00:00

  • Status changed from New to Rejected

I'll reject this issue as it will probably never work like this. However the implementation for the linked feature request will allow you to build what you want to achieve by moving your logic to a function.

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

1 participant