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

Support conditional blocks inside objects #652

Closed
jcharaoui opened this issue Feb 25, 2021 · 3 comments
Closed

Support conditional blocks inside objects #652

jcharaoui opened this issue Feb 25, 2021 · 3 comments

Comments

@jcharaoui
Copy link
Contributor

One of the great features of Icinga2 is the ability to include code blocks within host and service definitions.

For example:

apply Service "eventlog_" for (eventlog => config in host.vars.eventlog) {
  import "generic-service"
  check_command = "eventlog-windows"
  max_check_attempts = 1 
  volatile = true
  command_endpoint = host.name
  vars += config
  assign where true
  ignore where host.vars.noagent

  if (config.check_interval) {
    check_interval = config.check_interval
  } else {
    check_interval = 1h
  }
}

Currently, it's not possible to define the if / else blocks using the Puppet module, the only alternative is to drop an extra config file.

@jcharaoui
Copy link
Contributor Author

This could be solved in the same manner as the Puppetlabs Apache module, using a custom_fragment parameter.

@lbetz
Copy link
Contributor

lbetz commented Mar 1, 2021

We discussed it years ago and decided against it. In contrast to Apache, the order is decisive and "only" at the end makes very few users happy. But you can use a fragment for an entire object, see icinga2::config::fragment.

@jcharaoui
Copy link
Contributor Author

Fair enough, thanks for taking the time to reply.

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

2 participants