From efd510e946f6e71a26be9b468e698e8c27f97699 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 13 Jun 2024 13:08:48 -0400 Subject: [PATCH 1/3] The modules to download web content on Windows and Linux use different status codes. This has been fixed. --- roles/agent/tasks/Win32NT-files.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/agent/tasks/Win32NT-files.yml b/roles/agent/tasks/Win32NT-files.yml index 8adf02ee4..4bd066602 100644 --- a/roles/agent/tasks/Win32NT-files.yml +++ b/roles/agent/tasks/Win32NT-files.yml @@ -121,13 +121,13 @@ register: __checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' - changed_when: __checkmk_agent_host_download_state.status_code is defined and __checkmk_agent_host_download_state.status_code == 200 + changed_when: __checkmk_agent_host_download_state.status is defined and __checkmk_agent_host_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" - name: "{{ ansible_system }}: Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {{ (__checkmk_agent_host_download_state.status_code is defined and __checkmk_agent_host_download_state.status_code == 200) | bool }} + {{ (__checkmk_agent_host_download_state.status is defined and __checkmk_agent_host_download_state.status == 200) | bool }} - name: "{{ ansible_system }}: Download folder-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." ansible.builtin.uri: @@ -144,18 +144,18 @@ Accept: "application/octet-stream" register: __checkmk_agent_folder_download_state when: | - checkmk_agent_edition | lower != "cre" + checkmk_agent_edition | lower != "cre__checkmk_agent_folder_download_state" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 failed_when: 'false' - changed_when: __checkmk_agent_folder_download_state.status_code is defined and __checkmk_agent_folder_download_state.status_code == 200 + changed_when: __checkmk_agent_folder_download_state.status is defined and __checkmk_agent_folder_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" - name: "{{ ansible_system }}: Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {{ (__checkmk_agent_folder_download_state.status_code is defined and __checkmk_agent_folder_download_state.status_code == 200) | bool }} + {{ (__checkmk_agent_folder_download_state.status is defined and __checkmk_agent_folder_download_state.status == 200) | bool }} - name: "{{ ansible_system }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent (delegated)." ansible.builtin.uri: From d1f8eea08c23817b7a635ec472b7013d5be082c7 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 13 Jun 2024 13:14:03 -0400 Subject: [PATCH 2/3] Fix typo. --- roles/agent/tasks/Win32NT-files.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/agent/tasks/Win32NT-files.yml b/roles/agent/tasks/Win32NT-files.yml index 4bd066602..34ed3d46e 100644 --- a/roles/agent/tasks/Win32NT-files.yml +++ b/roles/agent/tasks/Win32NT-files.yml @@ -144,7 +144,7 @@ Accept: "application/octet-stream" register: __checkmk_agent_folder_download_state when: | - checkmk_agent_edition | lower != "cre__checkmk_agent_folder_download_state" + checkmk_agent_edition | lower != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 From 28fc4251800b4ba6d6d006edd95449588e3a1ba7 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 13 Jun 2024 13:18:33 -0400 Subject: [PATCH 3/3] Add changelog. --- changelogs/fragments/agent.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/fragments/agent.yml diff --git a/changelogs/fragments/agent.yml b/changelogs/fragments/agent.yml new file mode 100644 index 000000000..79369dbb5 --- /dev/null +++ b/changelogs/fragments/agent.yml @@ -0,0 +1,5 @@ +bugfixes: + - Agent role - For Windows hosts the download of correct setup files was broken + due to a mixup in the modules used to fetch the files. The role would always + fall back to the GENERIC agent, even if a specific agent was available. + This is fixed now.