host.conf.tmpl 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_primary_ip'] (node_config, 'v4').ip %}
  7. {%- set address6 = salt['ffho_net.get_primary_ip'] (node_config, 'v6').ip %}
  8. {%- set monitoring_config = node_config.get ('monitoring', {}) %}
  9. {%- set status = node_config.get ('status', 'active') %}
  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 status != 'active' %}
  25. # This node has status {{ status }}, 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. {#- Bare-metal host #}
  40. {%- if node_config.get ('hardware', False) %}
  41. # Bare metal host
  42. vars.hardware = true
  43. vars.manufacturer = "{{ node_config['manufacturer']|replace ('"', '\"') }}"
  44. vars.model = "{{ node_config['model']|replace ('"', '\\"') }}"
  45. {%- endif %}
  46. {#- VM #}
  47. {%- if node_config.get ('virtual', False) %}
  48. # VM
  49. vars.virtual = true
  50. vars.vm = {
  51. "vcpus" = {{ node_config['vm_config']['vcpus'] }},
  52. "memory" = {{ node_config['vm_config']['memory'] }},
  53. "disk" = {{ node_config['vm_config']['disk'] }},
  54. }
  55. {%- endif %}
  56. {#- Special monitoring related config for this host? #}
  57. {%- if 'host_vars' in monitoring_config %}
  58. # Host vars for node
  59. {%- for key, value in monitoring_config.get ('host_vars').items ()|sort %}
  60. vars.{{ key }} = "{{ value }}"
  61. {%- endfor %}
  62. {%- endif %}
  63. {%- if 'service_param' in monitoring_config %}
  64. # Service params
  65. vars.service_param = {
  66. {%- for service, params in monitoring_config.get ('service_param').items ()|sort %}
  67. "{{ service }}" = {
  68. {%- for entry, value in params.items ()|sort %}
  69. "{{ entry }}" = "{{ value }}",
  70. {%- endfor %}
  71. },
  72. {%- endfor %}
  73. }
  74. {%- endif %}
  75. }