host.conf.tmpl 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. {#- Bare-metal host #}
  45. {%- if node_config.get ('hardware', False) %}
  46. # Bare metal host
  47. vars.hardware = true
  48. vars.manufacturer = "{{ node_config['manufacturer']|replace ('"', '\"') }}"
  49. vars.model = "{{ node_config['model']|replace ('"', '\\"') }}"
  50. {%- endif %}
  51. {#- VM #}
  52. {%- if node_config.get ('virtual', False) %}
  53. # VM
  54. vars.virtual = true
  55. vars.vm = {
  56. "vcpus" = {{ node_config['vm_config']['vcpus'] }},
  57. "memory" = {{ node_config['vm_config']['memory'] }},
  58. "disk" = {{ node_config['vm_config']['disk'] }},
  59. }
  60. {%- endif %}
  61. {#- Special monitoring related config for this host? #}
  62. {%- if 'host_vars' in monitoring_config %}
  63. # Host vars for node
  64. {%- for key, value in monitoring_config.get ('host_vars').items ()|sort %}
  65. vars.{{ key }} = "{{ value }}"
  66. {%- endfor %}
  67. {%- endif %}
  68. {%- if 'service_param' in monitoring_config %}
  69. # Service params
  70. vars.service_param = {
  71. {%- for service, params in monitoring_config.get ('service_param').items ()|sort %}
  72. "{{ service }}" = {
  73. {%- for entry, value in params.items ()|sort %}
  74. "{{ entry }}" = "{{ value }}",
  75. {%- endfor %}
  76. },
  77. {%- endfor %}
  78. }
  79. {%- endif %}
  80. }