host.conf.tmpl 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #
  2. # {{ node_id }}
  3. #
  4. {%- set roles = node_config.get ('roles', []) %}
  5. {%- set sites = node_config.get ('sites', []) %}
  6. {%- if node_config.get ('primary_ips', False) %}
  7. {%- set address = node_config['primary_ips'].get ('v4', '') %}
  8. {%- set address6 = node_config['primary_ips'].get ('v6', '') %}
  9. {%- else %}
  10. {%- set address = salt['ffho_net.get_loopback_ip'] (node_config, node_id, 'v4') %}
  11. {%- set address6 = salt['ffho_net.get_loopback_ip'] (node_config, node_id, 'v6') %}
  12. {%- endif %}
  13. {%- set monitoring_config = node_config.get ('monitoring', {}) %}
  14. {%- set status = node_config.get ('status', 'active') %}
  15. {%- if 'icinga2server' not in roles %}
  16. object Endpoint "{{ node_id }}" {
  17. host = "{{ node_id }}"
  18. }
  19. object Zone "{{ node_id }}" {
  20. endpoints = [ "{{ node_id }}" ]
  21. parent = "master"
  22. }
  23. {%- endif %}
  24. object Host "{{ node_id }}" {
  25. import "generic-host"
  26. display_name = "{{ node_id }}"
  27. address = "{{ address }}"
  28. address6 = "{{ address6 }}"
  29. {%- if status != 'active' %}
  30. # This node has status {{ status }}, don't whine about anything here
  31. enable_notifications = false
  32. {%- endif %}
  33. vars.os = "Linux"
  34. vars.roles = [
  35. {%- for role in roles|sort %}
  36. "{{ role }}",
  37. {%- endfor %}
  38. ]
  39. vars.sites = [
  40. {%- for site in sites|sort %}
  41. "{{ site }}",
  42. {%- endfor %}
  43. ]
  44. {%- if 'host_vars' in monitoring_config %}
  45. # Host vars for node
  46. {%- for key, value in monitoring_config.get ('host_vars').items ()|sort %}
  47. vars.{{ key }} = "{{ value }}"
  48. {%- endfor %}
  49. {%- endif %}
  50. {%- if 'service_param' in monitoring_config %}
  51. # Service params
  52. vars.service_param = {
  53. {%- for service, params in monitoring_config.get ('service_param').items ()|sort %}
  54. "{{ service }}" = {
  55. {%- for entry, value in params.items ()|sort %}
  56. "{{ entry }}" = "{{ value }}",
  57. {%- endfor %}
  58. },
  59. {%- endfor %}
  60. }
  61. {%- endif %}
  62. }