From 467579a209dd9d5b7d7243a757de0e0de8cb0fe0 Mon Sep 17 00:00:00 2001 From: Gianmarco Mameli Date: Tue, 4 Nov 2025 20:49:08 +0100 Subject: [PATCH 1/2] Refactor conditionals to ensure proper evaluation of package lists in Debian, RedHat, and Suse installation tasks --- changelogs/fragments/fix_broken_conditionals.yml | 2 ++ roles/monitoring_plugins/tasks/install_on_Debian.yml | 4 ++-- roles/monitoring_plugins/tasks/install_on_RedHat.yml | 6 +++--- roles/monitoring_plugins/tasks/install_on_Suse.yml | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/fix_broken_conditionals.yml diff --git a/changelogs/fragments/fix_broken_conditionals.yml b/changelogs/fragments/fix_broken_conditionals.yml new file mode 100644 index 00000000..156e4c79 --- /dev/null +++ b/changelogs/fragments/fix_broken_conditionals.yml @@ -0,0 +1,2 @@ +bugfixes: + - "Fix broken conditionals when using on ansible-core >= 2.19 because of some playbooks changes" \ No newline at end of file diff --git a/roles/monitoring_plugins/tasks/install_on_Debian.yml b/roles/monitoring_plugins/tasks/install_on_Debian.yml index c3bf10fb..54d676dc 100644 --- a/roles/monitoring_plugins/tasks/install_on_Debian.yml +++ b/roles/monitoring_plugins/tasks/install_on_Debian.yml @@ -10,7 +10,7 @@ changed_when: apt_result.stdout is defined when: - needed_packages is defined - - needed_packages + - needed_packages | length > 0 - name: Apt - remove non-requested packages become: yes @@ -20,4 +20,4 @@ autoremove: "{{ icinga_monitoring_plugins_autoremove }}" when: - icinga_monitoring_plugins_remove - - unwanted_packages + - unwanted_packages | length > 0 diff --git a/roles/monitoring_plugins/tasks/install_on_RedHat.yml b/roles/monitoring_plugins/tasks/install_on_RedHat.yml index 95a6b9d9..f6baf6f5 100644 --- a/roles/monitoring_plugins/tasks/install_on_RedHat.yml +++ b/roles/monitoring_plugins/tasks/install_on_RedHat.yml @@ -14,7 +14,7 @@ when: - ansible_distribution_major_version < "8" - needed_packages is defined - - needed_packages + - needed_packages | length > 0 - name: Dnf - install requested packages become: yes @@ -26,7 +26,7 @@ when: - ansible_distribution_major_version >= "8" - needed_packages is defined - - needed_packages + - needed_packages | length > 0 - name: Yum - remove non-requested packages become: yes @@ -36,4 +36,4 @@ autoremove: "{{ icinga_monitoring_plugins_autoremove }}" when: - icinga_monitoring_plugins_remove - - unwanted_packages + - unwanted_packages | length > 0 diff --git a/roles/monitoring_plugins/tasks/install_on_Suse.yml b/roles/monitoring_plugins/tasks/install_on_Suse.yml index 56d9d3aa..c7290924 100644 --- a/roles/monitoring_plugins/tasks/install_on_Suse.yml +++ b/roles/monitoring_plugins/tasks/install_on_Suse.yml @@ -10,7 +10,7 @@ changed_when: zypper_result.stdout is defined when: - needed_packages is defined - - needed_packages + - needed_packages | length > 0 - name: Zypper - remove non-requested packages become: yes @@ -20,4 +20,4 @@ clean_deps: "{{ icinga_monitoring_plugins_autoremove }}" when: - icinga_monitoring_plugins_remove - - unwanted_packages + - unwanted_packages | length > 0 From ea960553234361d1c67861fbd04a9a0f1669b64a Mon Sep 17 00:00:00 2001 From: Donien <88634789+Donien@users.noreply.github.com> Date: Mon, 10 Nov 2025 16:23:21 +0100 Subject: [PATCH 2/2] Update changelogs/fragments/fix_broken_conditionals.yml --- changelogs/fragments/fix_broken_conditionals.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/fix_broken_conditionals.yml b/changelogs/fragments/fix_broken_conditionals.yml index 156e4c79..072905d9 100644 --- a/changelogs/fragments/fix_broken_conditionals.yml +++ b/changelogs/fragments/fix_broken_conditionals.yml @@ -1,2 +1,2 @@ bugfixes: - - "Fix broken conditionals when using on ansible-core >= 2.19 because of some playbooks changes" \ No newline at end of file + - "Use explicit booleans in conditions inside of role :code:`monitoring_plugins` for compatibility with :code:`ansible-core >= 2.19`. Thanks @gianmarco-mameli" \ No newline at end of file