Skip to content

Commit

Permalink
Adds installation from source to all modules
Browse files Browse the repository at this point in the history
(cherry picked from commit fc19a33)
  • Loading branch information
mocdaniel committed Nov 22, 2023
1 parent 831d4a3 commit b3e3de1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
15 changes: 10 additions & 5 deletions roles/icingaweb2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@

- name: Gather module packages
ansible.builtin.set_fact:
icingaweb2_packages: "{{ icingaweb2_packages + [ icingaweb2_module_packages[item.key] ] }}"
icingaweb2_packages: "{{ icingaweb2_packages + [icingaweb2_module_packages[item.key]] }}"
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"
when: icingaweb2_modules is defined and icingaweb2_module_packages[item.key] is defined and item.value.enabled|bool and item.value.source == "package"

- name: Include OS specific installation
ansible.builtin.include_tasks: "install_on_{{ ansible_os_family | lower }}.yml"

- name: Include module installation from source
ansible.builtin.include_tasks: "modules/install_modules_from_source.yml"
when: icingaweb2_modules is defined
loop: "{{ icingaweb2_modules | dict2items }}"

- name: Manage Icinga Web 2 config
ansible.builtin.include_tasks: "manage_icingaweb_config.yml"

Expand All @@ -35,11 +40,11 @@

- name: Manage enabled/disabled modules
ansible.builtin.file:
src: "{{ icingaweb2_config.global.module_path + '/' + item.key if item.value.enabled|bool else omit }}"
src: "{{ icingaweb2_config.global.module_path + '/' + item.key if item.value.enabled | bool else omit }}"
dest: "{{ icingaweb2_config_dir }}/enabledModules/{{ item.key }}"
owner: "{{ icingaweb2_httpd_user }}"
group: "{{ icingaweb2_group }}"
state: "{{ 'link' if item.value.enabled|bool else 'absent' }}"
state: "{{ 'link' if item.value.enabled | bool else 'absent' }}"
force: yes
mode: "0777"
when: icingaweb2_modules is defined
Expand All @@ -50,5 +55,5 @@
ansible.builtin.service:
name: "icinga-{{ item.key }}"
state: restarted
when: icingaweb2_modules is defined and item.value.enabled|bool and item.key in ['vspheredb', 'x509', 'reporting']
when: icingaweb2_modules is defined and item.value.enabled | bool and item.key in ['reporting', 'director', 'vspheredb', 'x509']
loop: "{{ icingaweb2_modules | dict2items }}"
39 changes: 39 additions & 0 deletions roles/icingaweb2/tasks/modules/install_modules_from_source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: "Install module from source: {{ _module }}"
when: vars['icingaweb2_modules'][_module]['source'] == 'git'
vars:
_module: "{{ item.key }}"
block:
- name: Download release {{ icingaweb2_module_source_versions[_module] }}
ansible.builtin.get_url:
url: https://github.com/Icinga/icingaweb2-module-{{ _module }}/archive/refs/tags/{{ icingaweb2_module_source_versions[_module] }}.tar.gz
dest: /tmp/
mode: "0644"
register: _download

- name: Extract source archive
ansible.builtin.unarchive:
src: "{{ _download.dest }}"
dest: "{{ _download.dest | dirname }}"
owner: "{{ icingaweb2_httpd_user }}"
group: "{{ icingaweb2_group }}"
mode: "0755"
remote_src: true

- name: Create module directory
ansible.builtin.file:
state: directory
dest: "{{ icingaweb2_config.global.module_path }}/{{ _module }}"
owner: "{{ icingaweb2_httpd_user }}"
group: "{{ icingaweb2_group }}"
mode: "0755"

- name: Move module to module path
ansible.builtin.copy:
src: "{{ _download.dest | dirname }}/{{ _download.dest | basename | regex_replace('\\.tar\\.gz', '') }}/"
dest: "{{ icingaweb2_config.global.module_path }}/{{ _module }}"
owner: "{{ icingaweb2_httpd_user }}"
group: "{{ icingaweb2_group }}"
mode: "0755"
force: true
remote_src: true
6 changes: 5 additions & 1 deletion roles/icingaweb2/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ icingaweb2_module_packages:
businessprocess: icinga-businessprocess

icingaweb2_module_source_versions:
reporting: v1.0.0
businessprocess: v2.5.0
director: v1.11.0
icingadb: v1.1.1
reporting: v1.0.0
x509: v1.3.1

0 comments on commit b3e3de1

Please sign in to comment.