diff --git a/icinga2/defaults.yaml b/icinga2/defaults.yaml index 00108e1..ea2d9f5 100644 --- a/icinga2/defaults.yaml +++ b/icinga2/defaults.yaml @@ -47,6 +47,7 @@ icinga2: - php-intl - php-gd - php-imagick + - git features: api: False command: True @@ -59,6 +60,8 @@ icinga2: perfdata: False statusdata: False syslog: False + modules_repo: https://github.com/Icinga/icingaweb2-module- # ${modulename}.git is appended + modules: check_command: openvpn: diff --git a/icinga2/icinga-web2-modules.sls b/icinga2/icinga-web2-modules.sls new file mode 100644 index 0000000..c782396 --- /dev/null +++ b/icinga2/icinga-web2-modules.sls @@ -0,0 +1,11 @@ +{% from "icinga2/map.jinja" import icinga2 with context %} +{% from "icinga2/map.jinja" import module with context %} + +{% for name, data in icinga2.icinga_web2.modules.items() %} +{{ module( name, + data.get("repo", icinga2.icinga_web2.modules_repo + name + ".git"), + data.version, + data.get("path", icinga2.icinga_web2.modules_dir + "/" + name), + data.get("enable", true) + ) }} +{% endfor %} diff --git a/icinga2/icinga-web2.sls b/icinga2/icinga-web2.sls index 536c62e..544979f 100644 --- a/icinga2/icinga-web2.sls +++ b/icinga2/icinga-web2.sls @@ -4,3 +4,4 @@ include: - .pgsql-ido - .icinga-web2-core - .icinga-web2-database + - .icinga-web2-modules diff --git a/icinga2/map.jinja b/icinga2/map.jinja index 97463a0..c853174 100644 --- a/icinga2/map.jinja +++ b/icinga2/map.jinja @@ -26,3 +26,23 @@ - watch_in: - service: icinga2_service_restart {%- endmacro %} + +{%- macro module(name, repo, branch, path, enable) %} +{%- set action = 'enable' if enable else 'disable' %} +"icingaweb2_module_{{ name }}": + {% if action == "enable" %} + git.latest: + - name: {{ repo }} + - target: {{ path }} + - rev: {{ branch }} + - require: + - pkg: icinga2-web2 + {% endif %} + cmd.run: + - name: icingacli module {{ action }} {{ name }} + - unless: "icingacli module list | grep '^{{ name }} .* enabled '" + {% if action == "enable" %} + - require: + - git: icingaweb2_module_{{ name }} + {% endif %} +{%- endmacro %} diff --git a/pillar.example b/pillar.example index b4d5a1d..7c371e5 100644 --- a/pillar.example +++ b/pillar.example @@ -25,6 +25,12 @@ icinga2: perfdata: True statusdata: True # ... + modules: + incubator: + version: v0.5.0 # tag or branch + enable: true # optional + repo: https://github.com/Icinga/icingaweb2-module-incubator.git # optional + path: /usr/share/icingaweb2/modules/incubator # optional notification: xmpp: