Skip to content

Commit

Permalink
Fix bug where known but unavailable plugins would not be skipped
Browse files Browse the repository at this point in the history
Fixes #327
  • Loading branch information
Donien committed Oct 10, 2024
1 parent 220913e commit 4a58ebb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/fix_327_unavailable_plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- Fixed a bug in :code:`monitoring_plugins` where a requested plugin that is **unavailable** would cause a failure even though it is a **known** plugin and should be skipped (#327).
18 changes: 9 additions & 9 deletions roles/monitoring_plugins/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
paths:
- "{{ role_path }}/vars"

- name: Make sure that check plugins are requested and that they are defined
assert:
that:
- icinga_monitoring_plugins_check_commands is defined
- diff | length == 0
fail_msg: "The following requested check command names (variable 'icinga_monitoring_plugins_check_commands') are not recognized as available check plugins on this host: {{ diff }}"
vars:
diff: "{{ icinga_monitoring_plugins_check_commands | default([]) | difference(icinga_monitoring_plugins_available_packages | map(attribute='name') | list) | difference(['all']) }}"

- name: Clean up variable discrepancy - remove entries
set_fact:
icinga_monitoring_plugins_available_packages: "{{ icinga_monitoring_plugins_available_packages | difference(icinga_monitoring_plugins_available_packages_exclude) }}"
Expand All @@ -33,15 +42,6 @@
icinga_monitoring_plugins_available_packages: "{{ icinga_monitoring_plugins_available_packages + icinga_monitoring_plugins_available_packages_include }}"
when: icinga_monitoring_plugins_available_packages_include is defined

- name: Make sure that check plugins are requested and that they are defined
assert:
that:
- icinga_monitoring_plugins_check_commands is defined
- diff | length == 0
fail_msg: "The following requested check command names (variable 'icinga_monitoring_plugins_check_commands') are not recognized as available check plugins on this host: {{ diff }}"
vars:
diff: "{{ icinga_monitoring_plugins_check_commands | default([]) | difference(icinga_monitoring_plugins_available_packages | map(attribute='name') | list) | difference(['all']) }}"

- name: Create list of packages to be installed
set_fact:
needed_packages: "{{ icinga_monitoring_plugins_available_packages | map(attribute='pkg_name') if 'all' in icinga_monitoring_plugins_check_commands else (needed_packages | default([]) + (icinga_monitoring_plugins_available_packages | selectattr('name','equalto', item) | map(attribute='pkg_name') | list)) | unique }}"
Expand Down

0 comments on commit 4a58ebb

Please sign in to comment.