host.conf.tmpl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #
  2. # {{ node_id }}
  3. #
  4. {%- set roles = node_config.get ('roles', []) %}
  5. {%- set sites = node_config.get ('sites', []) %}
  6. {%- set address = salt['ffho_net.get_loopback_ip'] (node_config, node_id, 'v4') %}
  7. {%- set address6 = salt['ffho_net.get_loopback_ip'] (node_config, node_id, 'v6') %}
  8. {%- set monitoring_config = node_config.get ('monitoring', {}) %}
  9. {%- if 'icinga2server' not in roles %}
  10. object Endpoint "{{ node_id }}" {
  11. host = "{{ node_id }}"
  12. }
  13. object Zone "{{ node_id }}" {
  14. endpoints = [ "{{ node_id }}" ]
  15. parent = "master"
  16. }
  17. {%- endif %}
  18. object Host "{{ node_id }}" {
  19. import "generic-host"
  20. display_name = "{{ node_id }}"
  21. address = "{{ address }}"
  22. address6 = "{{ address6 }}"
  23. vars.os = "Linux"
  24. vars.roles = [
  25. {%- for role in roles|sort %}
  26. "{{ role }}",
  27. {%- endfor %}
  28. ]
  29. vars.sites = [
  30. {%- for site in sites|sort %}
  31. "{{ site }}",
  32. {%- endfor %}
  33. ]
  34. {%- if 'service_param' in monitoring_config %}
  35. vars.service_param = {
  36. {%- for service, params in monitoring_config.get ('service_param').items ()|sort %}
  37. "{{ service }}" = {
  38. {%- for entry, value in params.items ()|sort %}
  39. "{{ entry }}" = "{{ value }}",
  40. {%- endfor %}
  41. },
  42. {%- endfor %}
  43. }
  44. {%- endif %}
  45. }