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

Implement conditional statements/loops parameter for icinga2::object::* #354

Closed
baurmatt opened this issue Aug 17, 2017 · 9 comments
Closed

Comments

@baurmatt
Copy link
Contributor

Expected Behavior

puppet-icinga2 allows to add a Service like this:

apply Service "vhost " for (vhost => config in host.vars.http_vhosts) {
  host_name = "localhost"

  check_command = "http"

  if (config.interval) {
    check_interval = config.interval
  } else {
    check_interval = 5m
  }

  assign where host.vars.http_vhosts
}

The important part for us is the if () {} else {} part

Current Behavior

Its currently not possible to add conditional statements/loops by using the icinga2::object::* classes

Possible Solution

Due to the (could be) complex nature of conditional statements/loops I suggest to only add a custom parameter to the icinga2::object::* classes which allows to add free text to an object.

Steps to Reproduce (for bugs)

Try to add a conditional statements/loops with icinga2::object::* classes.

Your Environment

  • Module version (puppet module list): Forked master with enhancements
  • Puppet version (puppet -V): 4.10.1
  • Operating System and version: Ubuntu 16.04
@lbetz
Copy link
Contributor

lbetz commented Aug 17, 2017

How the module should know at what position the custom snippet has to be added?

@baurmatt
Copy link
Contributor Author

baurmatt commented Aug 17, 2017

Not sure yet :( The best solution would probably be something like the concat::fragment order parameter but this is surely really hard to implement. Perhaps we just try it after import?

@lbetz
Copy link
Contributor

lbetz commented Aug 30, 2017

That's not stable. What will be done if you wanna use attribute set by the same object?

@baurmatt
Copy link
Contributor Author

Not sure what you mean, sorry. Can you give an example please?

@lazyfrosch
Copy link
Contributor

Conditional statements require context and order.

At the moment the object config is rendered from a Hash, where the order doesn't matter.

We could offer a custom_code string field. But still, the best way should be to handle special cases via a separate config file. (out of scope of icinga2::object)

@lbetz
Copy link
Contributor

lbetz commented Aug 30, 2017 via email

@baurmatt
Copy link
Contributor Author

custom(_code) would be fine with me. I definitely prefer it over a custom made icinga2::config::fragment because i can use all the object.conf.erb logic.

@lbetz
Copy link
Contributor

lbetz commented Aug 30, 2017

No you can't, lazyfrosch explained it.

@bobapple
Copy link
Contributor

We had this discussion many times over the time. It does not make sense for us to add this kind of complexity to the module. I think even these complex types of configuration are already covered in an acceptable way. I'll close this issue since we had this topic for many times now, thank you for your effort.

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

4 participants