Skip to content

Commit

Permalink
Fix/proper fail on unsupported os (#258)
Browse files Browse the repository at this point in the history
* Added block rescue statement if unsupported os found.

* added changelog fragment
  • Loading branch information
mkayontour authored Jan 31, 2024
1 parent a2ad28c commit 1f7ba22
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 15 deletions.
1 change: 1 addition & 0 deletions changelogs/fragments/minor_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
bugfixes:
- "icingaweb2: run pqslcmd with LANG=C to ensure the output is in english."
- remove superfluous curly brace (#246)
- Added block rescue statement if unsupported os found. (#232)
minor_changes:
- added tests for icingaweb2 ini template
- added pyinilint as ini validator after templates
Expand Down
15 changes: 10 additions & 5 deletions roles/icinga2/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
---
- name: Check supported operatingsystems
block:
- name: Install on {{ ansible_os_family }}
ansible.builtin.include_tasks: "install_on_{{ ansible_os_family }}.yml"
rescue:
- name: "OS family not supported!"
ansible.builtin.fail:
msg: "The OS {{ ansible_os_family }} is not supported!"

- name: install on {{ ansible_os_family }}
include_tasks: "install_on_{{ ansible_os_family }}.yml"

- name: fragments dir
file:
- name: Prepare fragments path
ansible.builtin.file:
state: directory
path: "{{ icinga2_fragments_path }}"
owner: root
Expand Down
10 changes: 8 additions & 2 deletions roles/icingadb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
paths:
- "{{ role_path }}/vars"

- name: Include OS specific installation
ansible.builtin.include_tasks: "install_on_{{ ansible_os_family | lower }}.yml"
- name: Check supported operatingsystems
block:
- name: Include OS specific installation
ansible.builtin.include_tasks: "install_on_{{ ansible_os_family | lower }}.yml"
rescue:
- name: "OS family not supported!"
ansible.builtin.fail:
msg: "The OS {{ ansible_os_family }} is not supported!"

- name: Include Tasks to configure IcingaDB
ansible.builtin.include_tasks: manage_config.yml
Expand Down
10 changes: 8 additions & 2 deletions roles/icingadb_redis/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
paths:
- "{{ role_path }}/vars"

- name: Include OS specific installation
ansible.builtin.include_tasks: "install_on_{{ ansible_os_family | lower }}.yml"
- name: Check supported operatingsystems
block:
- name: Include OS specific installation
ansible.builtin.include_tasks: "install_on_{{ ansible_os_family | lower }}.yml"
rescue:
- name: "OS family not supported!"
ansible.builtin.fail:
msg: "The OS {{ ansible_os_family }} is not supported!"

- name: Manage IcingaDB Redis configuration
ansible.builtin.include_tasks: "manage_config.yml"
Expand Down
10 changes: 8 additions & 2 deletions roles/icingaweb2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
loop: "{{ icingaweb2_modules | dict2items }}"
when: icingaweb2_modules is defined and icingaweb2_module_packages[item.key] is defined and item.value.enabled | bool == true and item.value.source == "package"

- name: Include OS specific installation
ansible.builtin.include_tasks: "install_on_{{ ansible_os_family | lower }}.yml"
- name: Check supported operatingsystems
block:
- name: Include OS specific installation
ansible.builtin.include_tasks: "install_on_{{ ansible_os_family | lower }}.yml"
rescue:
- name: "OS family not supported!"
ansible.builtin.fail:
msg: "The OS {{ ansible_os_family }} is not supported!"

- name: Manage Icinga Web 2 config
ansible.builtin.include_tasks: "manage_icingaweb_config.yml"
Expand Down
10 changes: 8 additions & 2 deletions roles/monitoring_plugins/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

- gather_facts:

- name: Include OS family specific vars
include_vars: "{{ role_path }}/vars/{{ ansible_os_family }}.yml"
- name: Check supported operatingsystems
block:
- name: Include OS family specific vars
ansible.builtin.include_vars: "{{ role_path }}/vars/{{ ansible_os_family }}.yml"
rescue:
- name: "OS family not supported!"
ansible.builtin.fail:
msg: "The OS {{ ansible_os_family }} is not supported!"

- name: Include OS distribution/version specific vars
include_vars: "{{ lookup('first_found', params) }}"
Expand Down
10 changes: 8 additions & 2 deletions roles/repos/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@
- icinga_repo_subscription_username is defined
- icinga_repo_subscription_password is defined

- name: Add repositories
ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml"
- name: Check OS family
block:
- name: Add repositories {{ ansible_os_family }}
ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml"
rescue:
- name: "OS family not supported!"
ansible.builtin.fail:
msg: "The OS '{{ ansible_os_family }}' isn't currently supported!"

0 comments on commit 1f7ba22

Please sign in to comment.