Skip to content

Commit

Permalink
Added block rescue statement if unsupported os found.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkayontour committed Jan 17, 2024
1 parent 16beee3 commit 62a12f4
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 15 deletions.
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 62a12f4

Please sign in to comment.