選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

50 行
1.4KB

  1. {% from "icinga2/map.jinja" import icinga2 with context %}
  2. {% from "icinga2/macros.jinja" import printconfig with context %}
  3. include:
  4. - icinga2
  5. /etc/icinga2/conf.d:
  6. file.directory:
  7. - require:
  8. - pkg: icinga2
  9. {% set conf_files = {"hosts": "object",
  10. "groups": "object",
  11. "templates": "template",
  12. "downtimes": "apply",
  13. "services": "apply",
  14. "downtimes": "apply"}
  15. %}
  16. {% for object, type in conf_files.items() %}
  17. {% if icinga2.config[object] is defined %}
  18. /etc/icinga2/conf.d/{{object}}.conf:
  19. file.managed:
  20. - listen_in:
  21. - service: icinga2_service
  22. - require:
  23. - file: /etc/icinga2/conf.d
  24. - contents: |
  25. {%- for obj, objopts in icinga2.config[object].items() %}
  26. {%- if objopts["for"] is defined %}
  27. {{ printconfig("apply", objopts["type"], obj, objopts["conf"], objopts["for"], "for") }}
  28. {%- elif objopts["to"] is defined %}
  29. {{ printconfig("apply", objopts["type"], obj, objopts["conf"], objopts["to"], "to") }}
  30. {%- else %}
  31. {{ printconfig(type, objopts["type"], obj, objopts["conf"]) }}
  32. {%- endif %}
  33. {%- endfor %}
  34. {%- endif %}
  35. {%- endfor %}
  36. icinga2_zones_conf:
  37. file.managed:
  38. - name: {{icinga2.config_dir}}/zones.conf
  39. - source: salt://icinga2/templates/zones.conf.jinja
  40. - template: jinja
  41. - require:
  42. - pkg: icinga2
  43. - listen_in:
  44. - service: icinga2_service