host.conf.tmpl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. {%- set state = node_config.get ('state', 'operation') %}
  10. {%- if 'icinga2server' not in roles %}
  11. object Endpoint "{{ node_id }}" {
  12. host = "{{ node_id }}"
  13. }
  14. object Zone "{{ node_id }}" {
  15. endpoints = [ "{{ node_id }}" ]
  16. parent = "master"
  17. }
  18. {%- endif %}
  19. object Host "{{ node_id }}" {
  20. import "generic-host"
  21. display_name = "{{ node_id }}"
  22. address = "{{ address }}"
  23. address6 = "{{ address6 }}"
  24. {%- if state != 'operation' %}
  25. # This node has state {{ state }}, don't whine about anything here
  26. enable_notifications = false
  27. {%- endif %}
  28. vars.os = "Linux"
  29. vars.roles = [
  30. {%- for role in roles|sort %}
  31. "{{ role }}",
  32. {%- endfor %}
  33. ]
  34. vars.sites = [
  35. {%- for site in sites|sort %}
  36. "{{ site }}",
  37. {%- endfor %}
  38. ]
  39. {%- if 'service_param' in monitoring_config %}
  40. vars.service_param = {
  41. {%- for service, params in monitoring_config.get ('service_param').items ()|sort %}
  42. "{{ service }}" = {
  43. {%- for entry, value in params.items ()|sort %}
  44. "{{ entry }}" = "{{ value }}",
  45. {%- endfor %}
  46. },
  47. {%- endfor %}
  48. }
  49. {%- endif %}
  50. }