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 importing templates below everything else #2703

Open
Al2Klimov opened this issue Feb 9, 2023 · 0 comments
Open

Support importing templates below everything else #2703

Al2Klimov opened this issue Feb 9, 2023 · 0 comments

Comments

@Al2Klimov
Copy link
Member

I.e.:

template Service "ssh-service" {
  import "generic-service"
  // "save" original command name, and replace it
  vars.original_check_command = check_command
  check_command = "by_ssh"
  // these get evaluated at runtime
  vars.by_ssh_command = {{ get_check_command(service.vars.original_check_command).command }}
  vars.by_ssh_arguments = {{ get_check_command(service.vars.original_check_command).arguments }}
}

apply Service "users" {
  check_command = "users"
  vars.users_wgreater = 3
  vars.users_cgreater = 5
  // ...
  import "ssh-service" // <======== HERE
}

(c) https://www.netways.de/en/blog/2016/03/21/check_by_ssh-mit-icinga-2/

Not strictly required, but very useful for check_by_ssh or Icinga/icinga2#9062.

Ideally one can even order imports. But this could be emulated with a few nested templates which import others and this below-feature.

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

No branches or pull requests

1 participant