Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where known but unavailable plugins would not be skipped #329

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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