diff --git a/changelogs/fragments/fix_327_unavailable_plugin.yml b/changelogs/fragments/fix_327_unavailable_plugin.yml new file mode 100644 index 00000000..201c66cb --- /dev/null +++ b/changelogs/fragments/fix_327_unavailable_plugin.yml @@ -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). diff --git a/roles/monitoring_plugins/tasks/main.yml b/roles/monitoring_plugins/tasks/main.yml index e48ecaf2..4d40153a 100644 --- a/roles/monitoring_plugins/tasks/main.yml +++ b/roles/monitoring_plugins/tasks/main.yml @@ -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) }}" @@ -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 }}"