diff --git a/doc/role-icingaweb2/role-icingaweb2.md b/doc/role-icingaweb2/role-icingaweb2.md index 4faf1ae7..7cfe8195 100644 --- a/doc/role-icingaweb2/role-icingaweb2.md +++ b/doc/role-icingaweb2/role-icingaweb2.md @@ -7,6 +7,23 @@ The role icingaweb2 installs and configures Icinga Web 2 and its modules. * [IcingaDB](./module-icingadb.md) * [Monitoring](./module-monitoring.md) +Custom modules can either be installed via package or git repository. +Therefore set the variable `source` with either `package` or a string consisting `git,repository_url,tag/version/branch` +If no `tag/version/branch` is set the default `HEAD` will be used. + +Furthermore it's possible to differentiate between your own custom modules (for example custom themes) and Icinga specific modules. + +If you want to manage the config by yourself or the module doesn't need further configuration set the variable `manage_config` to `true` otherwise it needs to be set to `false` + +Example: +``` +icingaweb2_modules: + my_theme: + enabled: true + manage_config: true + source: git,https://github.com/slalomsk8er/icingaweb2-theme-solarized.git,v1.0.0 +``` + ## Variables ### Icinga Web 2 DB Configuration @@ -47,3 +64,5 @@ icingaweb2_resources: type: ldap [...] ``` + + diff --git a/roles/icingaweb2/tasks/main.yml b/roles/icingaweb2/tasks/main.yml index e6bd7b6b..9fd9fe70 100644 --- a/roles/icingaweb2/tasks/main.yml +++ b/roles/icingaweb2/tasks/main.yml @@ -18,9 +18,23 @@ loop: "{{ icingaweb2_modules | dict2items }}" when: icingaweb2_modules is defined and icingaweb2_module_packages[item.key] is defined and item.value.enabled is true and item.value.source == "package" +- name: Gather source packages from git + ansible.builtin.set_fact: + icingaweb2_git_packages: "{{ icingaweb2_git_packages + [item] }}" + loop: "{{ icingaweb2_modules | dict2items }}" + when: icingaweb2_modules is defined and item.value.enabled is true and (item.value.source | split(','))[0] == "git" + - name: Include OS specific installation ansible.builtin.include_tasks: "install_on_{{ ansible_os_family | lower }}.yml" +- name: Install Icingaweb2 Module from Git + ansible.builtin.git: + repo: "{{ (item.value.source | split(','))[1] }}" + dest: "{{ icingaweb2_config['global']['module_path'] }}/{{ item.key }}" + version: "{{ (item.value.source | split(',')[2] | default(omit) }}" + loop: "{{ icingaweb2_git_packages }}" + when: icingaweb2_modules is defined and item.value.enabled is true and (item.value.source | split(','))[0] == "git" + - name: Manage Icinga Web 2 config ansible.builtin.include_tasks: "manage_icingaweb_config.yml" @@ -30,7 +44,7 @@ - name: Configure modules ansible.builtin.include_tasks: "modules/{{ item.key }}.yml" - when: icingaweb2_modules is defined + when: icingaweb2_modules is defined and (item.value.custom is false or item.value.custom is not defined) loop: "{{ icingaweb2_modules | dict2items }}" - name: Manage enabled/disabled modules diff --git a/roles/icingaweb2/vars/debian-ubuntu.yml b/roles/icingaweb2/vars/debian-ubuntu.yml index 10b89b9c..b48af20e 100644 --- a/roles/icingaweb2/vars/debian-ubuntu.yml +++ b/roles/icingaweb2/vars/debian-ubuntu.yml @@ -1,3 +1,4 @@ icingaweb2_httpd_user: www-data icingaweb2_fragments_path: /var/tmp/icingaweb icingaweb2_packages: ["icingaweb2","icingacli","libapache2-mod-php"] + diff --git a/roles/icingaweb2/vars/main.yml b/roles/icingaweb2/vars/main.yml index 8092fd97..cdc0228a 100644 --- a/roles/icingaweb2/vars/main.yml +++ b/roles/icingaweb2/vars/main.yml @@ -2,4 +2,6 @@ icingaweb2_module_packages: icingadb: icingadb-web director: icinga-director - businessprocess: icinga-businessprocess \ No newline at end of file + + businessprocess: icinga-businessprocess +icingaweb2_git_packages: []