From b0222170284a26486edcab4e771d9f0b512ee2de Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 4 Jul 2023 09:37:36 +0200 Subject: [PATCH 01/31] Add support for folder-specific agent download. --- roles/agent/tasks/Debian.yml | 50 ++++++++++++++++++++++++++++++------ roles/agent/tasks/RedHat.yml | 50 ++++++++++++++++++++++++++++++------ roles/agent/tasks/Suse.yml | 50 ++++++++++++++++++++++++++++++------ 3 files changed, 126 insertions(+), 24 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index c872e4edd..104233d0e 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -14,7 +14,7 @@ checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme" become: false - register: checkmk_agent_download_state + register: checkmk_agent_generic_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' changed_when: 'false' @@ -22,6 +22,10 @@ tags: - download-package +- name: "Set Fact: Agent State: host-specific." + ansible.builtin.set_fact: + checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" + - name: "Debian Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" @@ -32,7 +36,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status == 200 + and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: - download-package @@ -48,10 +52,40 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status == 200 + and checkmk_agent_host_specific | bool tags: - install-package +- name: "Debian Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.uri: + url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_deb&agent_type=generic&folder_name={{ checkmk_agent_folder }}" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.cee }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + become: false + register: checkmk_agent_folder_download_state + when: | + (checkmk_agent_edition == "cee" or + checkmk_agent_edition == "cce" or + checkmk_agent_edition == "cfe" or + checkmk_agent_edition == "cme") + and checkmk_agent_folder is defined + and not checkmk_agent_host_specific | bool + retries: 3 + failed_when: 'false' + changed_when: 'false' + delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package + +- name: "Set Fact: Agent State: folder-specific." + ansible.builtin.set_fact: + checkmk_agent_folder_specific: >- + {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} + - name: "Debian Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_deb&agent_type=generic" @@ -67,13 +101,13 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and checkmk_agent_folder_specific | bool retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package -- name: "Debian Derivates: Transfer GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "Debian Derivates: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -83,12 +117,12 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) and checkmk_agent_delegate_download != inventory_hostname tags: - download-package -- name: "Debian Derivatives: Install GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "Debian Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: deb: "{{ checkmk_agent_agent.file.cee }}" @@ -99,7 +133,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) tags: - install-package diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 5a2074cc0..bf9b4e8d7 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -14,7 +14,7 @@ checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme" become: false - register: checkmk_agent_download_state + register: checkmk_agent_generic_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' changed_when: 'false' @@ -22,6 +22,10 @@ tags: - download-package +- name: "Set Fact: Agent State: host-specific." + ansible.builtin.set_fact: + checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" + - name: "RedHat Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" @@ -32,7 +36,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status == 200 + and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: - download-package @@ -48,10 +52,40 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status == 200 + and checkmk_agent_host_specific | bool tags: - install-package +- name: "RedHat Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.uri: + url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic&folder_name={{ checkmk_agent_folder }}" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.cee }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + become: false + register: checkmk_agent_folder_download_state + when: | + (checkmk_agent_edition == "cee" or + checkmk_agent_edition == "cce" or + checkmk_agent_edition == "cfe" or + checkmk_agent_edition == "cme") + and checkmk_agent_folder is defined + and not checkmk_agent_host_specific | bool + retries: 3 + failed_when: 'false' + changed_when: 'false' + delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package + +- name: "Set Fact: Agent State: folder-specific." + ansible.builtin.set_fact: + checkmk_agent_folder_specific: >- + {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} + - name: "RedHat Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic" @@ -67,13 +101,13 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and checkmk_agent_folder_specific | bool retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package -- name: "RedHat Derivates: Transfer GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "RedHat Derivates: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -83,12 +117,12 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) and checkmk_agent_delegate_download != inventory_hostname tags: - download-package -- name: "RedHat Derivatives: Install GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "RedHat Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.yum: name: "{{ checkmk_agent_agent.file.cee }}" @@ -99,7 +133,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) tags: - install-package diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index b0445b0aa..7532cbebe 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -14,7 +14,7 @@ checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme" become: false - register: checkmk_agent_download_state + register: checkmk_agent_generic_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' changed_when: 'false' @@ -22,6 +22,10 @@ tags: - download-package +- name: "Set Fact: Agent State: host-specific." + ansible.builtin.set_fact: + checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" + - name: "Suse Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" @@ -32,7 +36,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status == 200 + and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: - download-package @@ -49,10 +53,40 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status == 200 + and checkmk_agent_host_specific | bool tags: - install-package +- name: "Suse Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.uri: + url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic&folder_name={{ checkmk_agent_folder }}" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.cee }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + become: false + register: checkmk_agent_folder_download_state + when: | + (checkmk_agent_edition == "cee" or + checkmk_agent_edition == "cce" or + checkmk_agent_edition == "cfe" or + checkmk_agent_edition == "cme") + and checkmk_agent_folder is defined + and not checkmk_agent_host_specific | bool + retries: 3 + failed_when: 'false' + changed_when: 'false' + delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package + +- name: "Set Fact: Agent State: folder-specific." + ansible.builtin.set_fact: + checkmk_agent_folder_specific: >- + {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} + - name: "Suse Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic" @@ -68,13 +102,13 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and checkmk_agent_folder_specific | bool retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package -- name: "Suse Derivates: Transfer GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "Suse Derivates: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -84,12 +118,12 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) and checkmk_agent_delegate_download != inventory_hostname tags: - download-package -- name: "Suse Derivatives: Install GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "Suse Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: name: "{{ checkmk_agent_agent.file.cee }}" @@ -101,7 +135,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status != 200 + and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) tags: - install-package From a876708ccf552057cc725b513fde87762a281e8c Mon Sep 17 00:00:00 2001 From: "max.sickora" Date: Wed, 26 Jul 2023 15:45:57 +0200 Subject: [PATCH 02/31] Set Fact runs now only with enterprise --- roles/agent/tasks/Debian.yml | 5 +++++ roles/agent/tasks/RedHat.yml | 5 +++++ roles/agent/tasks/Suse.yml | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 104233d0e..893bd9497 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -25,6 +25,11 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" + when: | + checkmk_agent_edition == "cee" or + checkmk_agent_edition == "cce" or + checkmk_agent_edition == "cfe" or + checkmk_agent_edition == "cme" - name: "Debian Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index bf9b4e8d7..1082fc71e 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -25,6 +25,11 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" + when: | + checkmk_agent_edition == "cee" or + checkmk_agent_edition == "cce" or + checkmk_agent_edition == "cfe" or + checkmk_agent_edition == "cme" - name: "RedHat Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index 7532cbebe..95aef9179 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -25,6 +25,11 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" + when: | + checkmk_agent_edition == "cee" or + checkmk_agent_edition == "cce" or + checkmk_agent_edition == "cfe" or + checkmk_agent_edition == "cme" - name: "Suse Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: From 8ca295cc1bd25c4f13411cab8169aef17f6ceeeb Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Wed, 26 Jul 2023 17:09:30 +0200 Subject: [PATCH 03/31] Fix set_fact and conditional error. --- roles/agent/tasks/Debian.yml | 10 +++------- roles/agent/tasks/RedHat.yml | 10 +++------- roles/agent/tasks/Suse.yml | 10 +++------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 893bd9497..228d9916d 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -24,12 +24,8 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: - checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" - when: | - checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme" + checkmk_agent_host_specific: >- + {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} - name: "Debian Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -106,7 +102,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_folder_specific | bool + and not checkmk_agent_folder_specific | bool retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 1082fc71e..d4797d232 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -24,12 +24,8 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: - checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" - when: | - checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme" + checkmk_agent_host_specific: >- + {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} - name: "RedHat Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -106,7 +102,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_folder_specific | bool + and not checkmk_agent_folder_specific | bool retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index 95aef9179..065bf2ce6 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -24,12 +24,8 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: - checkmk_agent_host_specific: "{% if checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %}" - when: | - checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme" + checkmk_agent_host_specific: >- + {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} - name: "Suse Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -107,7 +103,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_folder_specific | bool + and not checkmk_agent_folder_specific | bool retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: From aadcb4e400dec5d1ab3eb4ff770ce43fb944ae14 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Mon, 14 Aug 2023 15:55:44 +0200 Subject: [PATCH 04/31] Bugfix task names. --- roles/agent/tasks/Debian.yml | 4 +--- roles/agent/tasks/RedHat.yml | 4 +--- roles/agent/tasks/Suse.yml | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 538023e62..b76f24aff 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -27,7 +27,6 @@ checkmk_agent_host_specific: >- {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} -- name: "Debian Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" @@ -58,7 +57,7 @@ tags: - install-package -- name: "Debian Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_deb&agent_type=generic&folder_name={{ checkmk_agent_folder }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -88,7 +87,6 @@ checkmk_agent_folder_specific: >- {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} -- name: "Debian Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." - name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_deb&agent_type=generic" diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index a73030cd8..51ee7e611 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -27,7 +27,6 @@ checkmk_agent_host_specific: >- {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} -- name: "RedHat Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" @@ -58,7 +57,7 @@ tags: - install-package -- name: "RedHat Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic&folder_name={{ checkmk_agent_folder }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -88,7 +87,6 @@ checkmk_agent_folder_specific: >- {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} -- name: "RedHat Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." - name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic" diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index d7be13fe6..68eeffdb1 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -27,7 +27,6 @@ checkmk_agent_host_specific: >- {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} -- name: "Suse Derivates: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" @@ -59,7 +58,7 @@ tags: - install-package -- name: "Suse Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic&folder_name={{ checkmk_agent_folder }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -89,7 +88,6 @@ checkmk_agent_folder_specific: >- {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} -- name: "Suse Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." - name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic" From 8cd6b8d3a863e388cb4ce80c9c07f05e7a5a02ea Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Mon, 14 Aug 2023 17:38:12 +0200 Subject: [PATCH 05/31] Finalize folder awareness. --- roles/agent/tasks/Debian.yml | 18 +++++++++--------- roles/agent/tasks/RedHat.yml | 18 +++++++++--------- roles/agent/tasks/Suse.yml | 18 +++++++++--------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index b76f24aff..9fa4586a0 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -14,10 +14,10 @@ checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme" become: false - register: checkmk_agent_generic_download_state + 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: 'false' + changed_when: checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -25,7 +25,7 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} + {% if checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 %}true{% else %}false{% endif %} - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -77,7 +77,7 @@ and not checkmk_agent_host_specific | bool retries: 3 failed_when: 'false' - changed_when: 'false' + changed_when: checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -102,13 +102,13 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and not checkmk_agent_folder_specific | bool + and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -118,12 +118,12 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) + and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: deb: "{{ checkmk_agent_agent.file.cee }}" @@ -134,7 +134,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) + and not checkmk_agent_host_specific | bool tags: - install-package diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 51ee7e611..f6d81676b 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -14,10 +14,10 @@ checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme" become: false - register: checkmk_agent_generic_download_state + 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: 'false' + changed_when: checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -25,7 +25,7 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} + {% if checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 %}true{% else %}false{% endif %} - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -77,7 +77,7 @@ and not checkmk_agent_host_specific | bool retries: 3 failed_when: 'false' - changed_when: 'false' + changed_when: checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -102,13 +102,13 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and not checkmk_agent_folder_specific | bool + and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -118,12 +118,12 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) + and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.yum: name: "{{ checkmk_agent_agent.file.cee }}" @@ -134,7 +134,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) + and not checkmk_agent_host_specific | bool tags: - install-package diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index 68eeffdb1..649d54e7b 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -14,10 +14,10 @@ checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme" become: false - register: checkmk_agent_generic_download_state + 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: 'false' + changed_when: checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -25,7 +25,7 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {% if checkmk_agent_generic_download_state.status is defined and checkmk_agent_generic_download_state.status == 200 %}true{% else %}false{% endif %} + {% if checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 %}true{% else %}false{% endif %} - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -78,7 +78,7 @@ and not checkmk_agent_host_specific | bool retries: 3 failed_when: 'false' - changed_when: 'false' + changed_when: checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -103,13 +103,13 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and not checkmk_agent_folder_specific | bool + and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -119,12 +119,12 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) + and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: name: "{{ checkmk_agent_agent.file.cee }}" @@ -136,7 +136,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and (not checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) + and not checkmk_agent_host_specific | bool tags: - install-package From 1b61849fe136c752c6f5c9ed45da11e71c6f3fe1 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Mon, 14 Aug 2023 17:39:11 +0200 Subject: [PATCH 06/31] Add folder awareness for Windows. --- roles/agent/tasks/Windows.yml | 46 ++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 0ef34edb1..0b859696f 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -26,14 +26,19 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme" - register: checkmk_agent_download_state + 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: 'false' + changed_when: checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package +- name: "Set Fact: Agent State: host-specific." + ansible.builtin.set_fact: + checkmk_agent_host_specific: >- + {% if checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 %}true{% else %}false{% endif %} + - name: "{{ ansible_os_family }}: Install host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.host }}" @@ -43,10 +48,39 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status_code == 200 + and checkmk_agent_host_specific | bool tags: - install-package +- name: "{{ ansible_os_family }} Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_get_url: + url: "{{ checkmk_agent_agent.url.cee }}?os_type=windows_msi&agent_type=generic&folder_name={{ checkmk_agent_folder }}" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.cee }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + register: checkmk_agent_folder_download_state + when: | + (checkmk_agent_edition == "cee" or + checkmk_agent_edition == "cce" or + checkmk_agent_edition == "cfe" or + checkmk_agent_edition == "cme") + 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 + delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package + +- name: "Set Fact: Agent State: folder-specific." + ansible.builtin.set_fact: + checkmk_agent_folder_specific: >- + {% if checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200 %}true{% else %}false{% endif %} + - name: "{{ ansible_os_family }}: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: url: "{{ checkmk_agent_agent.url.cee }}?os_type=windows_msi&agent_type=generic" @@ -61,13 +95,13 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status_code != 200 + and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package -- name: "{{ ansible_os_family }}: Install GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }}: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.cee }}" state: present @@ -76,7 +110,7 @@ checkmk_agent_edition == "cce" or checkmk_agent_edition == "cfe" or checkmk_agent_edition == "cme") - and checkmk_agent_download_state.status_code != 200 + and not checkmk_agent_host_specific | bool tags: - install-package From f0ab8463d7d253591a911eaf5e35a3eeff21d515 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Mon, 14 Aug 2023 17:57:47 +0200 Subject: [PATCH 07/31] Try improving set_fact block. --- roles/agent/tasks/Windows.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 0b859696f..40eeae45b 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -37,7 +37,11 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {% if checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 %}true{% else %}false{% endif %} + {%- if checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 -%} + true + {%- else -%} + false + {%- endif -%} - name: "{{ ansible_os_family }}: Install host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: @@ -79,7 +83,11 @@ - name: "Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {% if checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200 %}true{% else %}false{% endif %} + {%- if checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200 -%} + true + {%- else -%} + false + {%- endif -%} - name: "{{ ansible_os_family }}: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: From 927bba128bf17d84bd23042cffc0cba4d83ba4f0 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Mon, 14 Aug 2023 18:23:42 +0200 Subject: [PATCH 08/31] Add changelog. --- changelogs/fragments/agent.yml | 2 ++ 1 file changed, 2 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..f18339599 --- /dev/null +++ b/changelogs/fragments/agent.yml @@ -0,0 +1,2 @@ +minor_changes: + - Agent role - Allow the role to download folder-specific agents. From 24b44105bc0e8632e3f76aa11a2a23011e4cd7b8 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Mon, 14 Aug 2023 18:24:21 +0200 Subject: [PATCH 09/31] Improve templating per @msekania. --- roles/agent/tasks/Debian.yml | 4 ++-- roles/agent/tasks/RedHat.yml | 4 ++-- roles/agent/tasks/Suse.yml | 4 ++-- roles/agent/tasks/Windows.yml | 12 ++---------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 9fa4586a0..67b61f986 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -25,7 +25,7 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {% if checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 %}true{% else %}false{% endif %} + {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -85,7 +85,7 @@ - name: "Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} + {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} - name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index f6d81676b..9230f2fe5 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -25,7 +25,7 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {% if checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 %}true{% else %}false{% endif %} + {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -85,7 +85,7 @@ - name: "Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} + {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} - name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index 649d54e7b..afa7d606f 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -25,7 +25,7 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {% if checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 %}true{% else %}false{% endif %} + {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} - name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: @@ -86,7 +86,7 @@ - name: "Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {% if checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 %}true{% else %}false{% endif %} + {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} - name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 40eeae45b..04954ff50 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -37,11 +37,7 @@ - name: "Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {%- if checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 -%} - true - {%- else -%} - false - {%- endif -%} + {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} - name: "{{ ansible_os_family }}: Install host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: @@ -83,11 +79,7 @@ - name: "Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {%- if checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200 -%} - true - {%- else -%} - false - {%- endif -%} + {{ (checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200) | bool }} - name: "{{ ansible_os_family }}: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: From eec35ab9df1a86f8f7e3020a0e690da295e2196b Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 09:10:02 +0200 Subject: [PATCH 10/31] Simplify conditionals. --- roles/agent/tasks/Debian.yml | 37 ++++++++--------------------------- roles/agent/tasks/Linux.yml | 8 ++------ roles/agent/tasks/RedHat.yml | 35 +++++++-------------------------- roles/agent/tasks/Suse.yml | 35 +++++++-------------------------- roles/agent/tasks/Win32NT.yml | 10 ++-------- roles/agent/tasks/Windows.yml | 25 +++++------------------ 6 files changed, 31 insertions(+), 119 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 67b61f986..dc56fecd7 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -9,10 +9,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme" + checkmk_agent_edition != "cre" become: false register: checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case @@ -33,10 +30,7 @@ dest: "{{ checkmk_agent_agent.file.host }}" mode: "0644" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -49,10 +43,7 @@ force: "{{ checkmk_agent_force_install | bool }}" state: present when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_host_specific | bool tags: - install-package @@ -69,10 +60,7 @@ become: false register: checkmk_agent_folder_download_state when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 @@ -98,10 +86,7 @@ Accept: "application/octet-stream" become: false when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" @@ -114,10 +99,7 @@ dest: "{{ checkmk_agent_agent.file.cee }}" mode: "0644" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -130,15 +112,12 @@ force: "{{ checkmk_agent_force_install | bool }}" state: present when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not checkmk_agent_host_specific | bool tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Install Checkmk CRE Agent." +- name: "{{ ansible_os_family }} Derivatives: Install Checkmk {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: deb: "{{ checkmk_agent_agent.file.cre }}" diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 6e4eb5d8c..d4af055f9 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -71,9 +71,7 @@ -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} register: checkmk_agent_update_state when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_updater_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_pass is defined and checkmk_agent_pass | length) @@ -87,9 +85,7 @@ -U {{ checkmk_agent_user }} -S {{ checkmk_agent_auth }} register: checkmk_agent_update_state when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_updater_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_secret is defined and checkmk_agent_secret | length) diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 9230f2fe5..82728d4c8 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -9,10 +9,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme" + checkmk_agent_edition != "cre" become: false register: checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case @@ -33,10 +30,7 @@ dest: "{{ checkmk_agent_agent.file.host }}" mode: "0644" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -49,10 +43,7 @@ state: present disable_gpg_check: true when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_host_specific | bool tags: - install-package @@ -69,10 +60,7 @@ become: false register: checkmk_agent_folder_download_state when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 @@ -98,10 +86,7 @@ Accept: "application/octet-stream" become: false when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" @@ -114,10 +99,7 @@ dest: "{{ checkmk_agent_agent.file.cee }}" mode: "0644" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -130,10 +112,7 @@ state: present disable_gpg_check: true when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not checkmk_agent_host_specific | bool tags: - install-package diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index afa7d606f..7b20795d3 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -9,10 +9,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme" + checkmk_agent_edition != "cre" become: false register: checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case @@ -33,10 +30,7 @@ dest: "{{ checkmk_agent_agent.file.host }}" mode: "0644" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -50,10 +44,7 @@ state: present disable_gpg_check: true when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_host_specific | bool tags: - install-package @@ -70,10 +61,7 @@ become: false register: checkmk_agent_folder_download_state when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 @@ -99,10 +87,7 @@ Accept: "application/octet-stream" become: false when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" @@ -115,10 +100,7 @@ dest: "{{ checkmk_agent_agent.file.cee }}" mode: "0644" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -132,10 +114,7 @@ state: present disable_gpg_check: true when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not checkmk_agent_host_specific | bool tags: - install-package diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index 4560a0d2c..660920975 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -43,10 +43,7 @@ args: chdir: "C:\\Program Files (x86)\\checkmk\\service\\" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_pass is defined and checkmk_agent_pass | length) @@ -61,10 +58,7 @@ args: chdir: "C:\\Program Files (x86)\\checkmk\\service\\" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_secret is defined and checkmk_agent_secret | length) diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 04954ff50..fca64b505 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -22,10 +22,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme" + checkmk_agent_edition != "cre" register: checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' @@ -44,10 +41,7 @@ path: "{{ checkmk_agent_agent.file.host }}" state: present when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_host_specific | bool tags: - install-package @@ -63,10 +57,7 @@ Accept: "application/octet-stream" register: checkmk_agent_folder_download_state when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 @@ -91,10 +82,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" @@ -106,10 +94,7 @@ path: "{{ checkmk_agent_agent.file.cee }}" state: present when: | - (checkmk_agent_edition == "cee" or - checkmk_agent_edition == "cce" or - checkmk_agent_edition == "cfe" or - checkmk_agent_edition == "cme") + checkmk_agent_edition != "cre" and not checkmk_agent_host_specific | bool tags: - install-package From 143d11e2d72d56d105d89fd739eeae64d12c7249 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 09:24:14 +0200 Subject: [PATCH 11/31] Add edition verification and make it case insensitive. --- roles/agent/tasks/Debian.yml | 16 ++++++++-------- roles/agent/tasks/Linux.yml | 6 +++--- roles/agent/tasks/RedHat.yml | 16 ++++++++-------- roles/agent/tasks/Suse.yml | 16 ++++++++-------- roles/agent/tasks/Win32NT.yml | 4 ++-- roles/agent/tasks/Windows.yml | 14 +++++++------- roles/agent/tasks/main.yml | 5 +++++ roles/agent/vars/main.yml | 8 ++++++++ 8 files changed, 49 insertions(+), 36 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index dc56fecd7..1795aa1c8 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -9,7 +9,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" become: false register: checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case @@ -30,7 +30,7 @@ dest: "{{ checkmk_agent_agent.file.host }}" mode: "0644" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -43,7 +43,7 @@ force: "{{ checkmk_agent_force_install | bool }}" state: present when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_host_specific | bool tags: - install-package @@ -60,7 +60,7 @@ become: false register: checkmk_agent_folder_download_state when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 @@ -86,7 +86,7 @@ Accept: "application/octet-stream" become: false when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" @@ -99,7 +99,7 @@ dest: "{{ checkmk_agent_agent.file.cee }}" mode: "0644" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -112,7 +112,7 @@ force: "{{ checkmk_agent_force_install | bool }}" state: present when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not checkmk_agent_host_specific | bool tags: - install-package @@ -123,6 +123,6 @@ deb: "{{ checkmk_agent_agent.file.cre }}" force: "{{ checkmk_agent_force_install | bool }}" state: present - when: checkmk_agent_edition == "cre" + when: checkmk_agent_edition | lower == "cre" tags: - install-package diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index d4af055f9..0419dbf37 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -20,7 +20,7 @@ validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" dest: "{{ checkmk_agent_agent.file.cre }}" mode: '0640' - when: checkmk_agent_edition == "cre" + when: checkmk_agent_edition | lower == "cre" register: result retries: 3 delay: 10 @@ -71,7 +71,7 @@ -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} register: checkmk_agent_update_state when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_updater_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_pass is defined and checkmk_agent_pass | length) @@ -85,7 +85,7 @@ -U {{ checkmk_agent_user }} -S {{ checkmk_agent_auth }} register: checkmk_agent_update_state when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_updater_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_secret is defined and checkmk_agent_secret | length) diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 82728d4c8..77d858d14 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -9,7 +9,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" become: false register: checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case @@ -30,7 +30,7 @@ dest: "{{ checkmk_agent_agent.file.host }}" mode: "0644" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -43,7 +43,7 @@ state: present disable_gpg_check: true when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_host_specific | bool tags: - install-package @@ -60,7 +60,7 @@ become: false register: checkmk_agent_folder_download_state when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 @@ -86,7 +86,7 @@ Accept: "application/octet-stream" become: false when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" @@ -99,7 +99,7 @@ dest: "{{ checkmk_agent_agent.file.cee }}" mode: "0644" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -112,7 +112,7 @@ state: present disable_gpg_check: true when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not checkmk_agent_host_specific | bool tags: - install-package @@ -123,7 +123,7 @@ name: "{{ checkmk_agent_agent.file.cre }}" state: present disable_gpg_check: true - when: checkmk_agent_edition == "cre" + when: checkmk_agent_edition | lower == "cre" tags: - install-package diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index 7b20795d3..6b701a67f 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -9,7 +9,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" become: false register: checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case @@ -30,7 +30,7 @@ dest: "{{ checkmk_agent_agent.file.host }}" mode: "0644" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -44,7 +44,7 @@ state: present disable_gpg_check: true when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_host_specific | bool tags: - install-package @@ -61,7 +61,7 @@ become: false register: checkmk_agent_folder_download_state when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 @@ -87,7 +87,7 @@ Accept: "application/octet-stream" become: false when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" @@ -100,7 +100,7 @@ dest: "{{ checkmk_agent_agent.file.cee }}" mode: "0644" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not checkmk_agent_host_specific | bool and checkmk_agent_delegate_download != inventory_hostname tags: @@ -114,7 +114,7 @@ state: present disable_gpg_check: true when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not checkmk_agent_host_specific | bool tags: - install-package @@ -126,6 +126,6 @@ force: "{{ checkmk_agent_force_install | bool }}" state: present disable_gpg_check: true - when: checkmk_agent_edition == "cre" + when: checkmk_agent_edition | lower == "cre" tags: - install-package diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index 660920975..876b21f78 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -43,7 +43,7 @@ args: chdir: "C:\\Program Files (x86)\\checkmk\\service\\" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_pass is defined and checkmk_agent_pass | length) @@ -58,7 +58,7 @@ args: chdir: "C:\\Program Files (x86)\\checkmk\\service\\" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_secret is defined and checkmk_agent_secret | length) diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index fca64b505..a936adef9 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -4,7 +4,7 @@ url: "{{ checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" dest: "{{ checkmk_agent_agent.file.cre }}" - when: checkmk_agent_edition == "cre" + when: checkmk_agent_edition | lower == "cre" register: result retries: 3 delay: 10 @@ -22,7 +22,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" register: checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' @@ -41,7 +41,7 @@ path: "{{ checkmk_agent_agent.file.host }}" state: present when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_host_specific | bool tags: - install-package @@ -57,7 +57,7 @@ Accept: "application/octet-stream" register: checkmk_agent_folder_download_state when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 @@ -82,7 +82,7 @@ Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" Accept: "application/octet-stream" when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" @@ -94,7 +94,7 @@ path: "{{ checkmk_agent_agent.file.cee }}" state: present when: | - checkmk_agent_edition != "cre" + checkmk_agent_edition | lower != "cre" and not checkmk_agent_host_specific | bool tags: - install-package @@ -103,6 +103,6 @@ ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.cre }}" state: present - when: checkmk_agent_edition == "cre" + when: checkmk_agent_edition | lower == "cre" tags: - install-package diff --git a/roles/agent/tasks/main.yml b/roles/agent/tasks/main.yml index 57ae2ce1a..a27466828 100644 --- a/roles/agent/tasks/main.yml +++ b/roles/agent/tasks/main.yml @@ -1,4 +1,9 @@ --- +- name: "Preflight - Fail if Checkmk Edition is incorrect." + ansible.builtin.fail: + msg: "The provided Checkmk Edition '{{ checkmk_agent_edition | lower }}' does not exist or is not supported by this role." + when: checkmk_agent_edition | lower not in checkmk_agent_edition_mapping + - name: "Include OS family specific variables." ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" tags: diff --git a/roles/agent/vars/main.yml b/roles/agent/vars/main.yml index f6a712bf6..6211fb2a7 100644 --- a/roles/agent/vars/main.yml +++ b/roles/agent/vars/main.yml @@ -2,3 +2,11 @@ checkmk_agent_site_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/{{ checkmk_agent_site }}" checkmk_agent_auth: "{% if checkmk_agent_secret is defined and checkmk_agent_secret | length %}{{ checkmk_agent_secret }}{% else %}{{ checkmk_agent_pass }}{% endif %}" # noqa yaml[line-length] + +# Due to inconsistent naming of editions, we normalize them here for convenience +checkmk_agent_edition_mapping: + cre: raw + cfe: free + cee: enterprise + cce: cloud + cme: managed From 5bb0b61e4ecdc233e73cb7a85d2aacbac374c32f Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 09:25:52 +0200 Subject: [PATCH 12/31] Remove redundant 'Checkmk' from task name. --- roles/agent/tasks/Debian.yml | 16 ++++++++-------- roles/agent/tasks/RedHat.yml | 14 +++++++------- roles/agent/tasks/Suse.yml | 14 +++++++------- roles/agent/tasks/Windows.yml | 10 +++++----- roles/agent/tasks/main.yml | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 1795aa1c8..43fcf20d8 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -1,5 +1,5 @@ --- -- name: "{{ ansible_os_family }} Derivatives: Download host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?host_name={{ checkmk_agent_host_name }}&os_type=linux_deb&agent_type=host_name" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -24,7 +24,7 @@ checkmk_agent_host_specific: >- {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} -- name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" dest: "{{ checkmk_agent_agent.file.host }}" @@ -36,7 +36,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: deb: "{{ checkmk_agent_agent.file.host }}" @@ -48,7 +48,7 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_deb&agent_type=generic&folder_name={{ checkmk_agent_folder }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -75,7 +75,7 @@ checkmk_agent_folder_specific: >- {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} -- name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download GENERIC {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_deb&agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -93,7 +93,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -105,7 +105,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: deb: "{{ checkmk_agent_agent.file.cee }}" @@ -117,7 +117,7 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Install Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: deb: "{{ checkmk_agent_agent.file.cre }}" diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 77d858d14..26e310ce0 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -1,5 +1,5 @@ --- -- name: "{{ ansible_os_family }} Derivatives: Download host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?host_name={{ checkmk_agent_host_name }}&os_type=linux_rpm&agent_type=host_name" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -24,7 +24,7 @@ checkmk_agent_host_specific: >- {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} -- name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" dest: "{{ checkmk_agent_agent.file.host }}" @@ -36,7 +36,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.yum: name: "{{ checkmk_agent_agent.file.host }}" @@ -48,7 +48,7 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic&folder_name={{ checkmk_agent_folder }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -75,7 +75,7 @@ checkmk_agent_folder_specific: >- {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} -- name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download GENERIC {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -93,7 +93,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -105,7 +105,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.yum: name: "{{ checkmk_agent_agent.file.cee }}" diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index 6b701a67f..86236dbbd 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -1,5 +1,5 @@ --- -- name: "{{ ansible_os_family }} Derivatives: Download host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?host_name={{ checkmk_agent_host_name }}&os_type=linux_rpm&agent_type=host_name" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -24,7 +24,7 @@ checkmk_agent_host_specific: >- {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} -- name: "{{ ansible_os_family }} Derivatives: Transfer host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.host }}" dest: "{{ checkmk_agent_agent.file.host }}" @@ -36,7 +36,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: name: "{{ checkmk_agent_agent.file.host }}" @@ -49,7 +49,7 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic&folder_name={{ checkmk_agent_folder }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -76,7 +76,7 @@ checkmk_agent_folder_specific: >- {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} -- name: "{{ ansible_os_family }} Derivatives: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download GENERIC {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: "{{ checkmk_agent_agent.url.cee }}?os_type=linux_rpm&agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -94,7 +94,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cee }}" dest: "{{ checkmk_agent_agent.file.cee }}" @@ -106,7 +106,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: name: "{{ checkmk_agent_agent.file.cee }}" diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index a936adef9..ef59a1b97 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -12,7 +12,7 @@ tags: - download-package -- name: "{{ ansible_os_family }}: Download host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: url: "{{ checkmk_agent_agent.url.cee }}?host_name={{ checkmk_agent_host_name }}&os_type=windows_msi&agent_type=host_name" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -36,7 +36,7 @@ checkmk_agent_host_specific: >- {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} -- name: "{{ ansible_os_family }}: Install host-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }}: Install host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.host }}" state: present @@ -46,7 +46,7 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Download folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Download folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: url: "{{ checkmk_agent_agent.url.cee }}?os_type=windows_msi&agent_type=generic&folder_name={{ checkmk_agent_folder }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -72,7 +72,7 @@ checkmk_agent_folder_specific: >- {{ (checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200) | bool }} -- name: "{{ ansible_os_family }}: Download GENERIC Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: url: "{{ checkmk_agent_agent.url.cee }}?os_type=windows_msi&agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -89,7 +89,7 @@ tags: - download-package -- name: "{{ ansible_os_family }}: Install GENERIC or folder-specific Checkmk {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }}: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.cee }}" state: present diff --git a/roles/agent/tasks/main.yml b/roles/agent/tasks/main.yml index a27466828..bd414bc8f 100644 --- a/roles/agent/tasks/main.yml +++ b/roles/agent/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: "Preflight - Fail if Checkmk Edition is incorrect." ansible.builtin.fail: - msg: "The provided Checkmk Edition '{{ checkmk_agent_edition | lower }}' does not exist or is not supported by this role." + msg: "The provided Checkmk Edition '{{ checkmk_agent_edition }}' does not exist or is not supported by this role." when: checkmk_agent_edition | lower not in checkmk_agent_edition_mapping - name: "Include OS family specific variables." From e3c98647cea124125fa31d9fab03a2bca2487f74 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 10:01:17 +0200 Subject: [PATCH 13/31] Add missing task to transfer CRE agent in delegated download scenario. --- roles/agent/tasks/Debian.yml | 13 ++++++++++++- roles/agent/tasks/RedHat.yml | 13 ++++++++++++- roles/agent/tasks/Suse.yml | 13 ++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 43fcf20d8..6f67bfca4 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -117,7 +117,18 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Install {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.copy: + src: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + mode: "0644" + when: | + checkmk_agent_edition | lower == "cre" + and checkmk_agent_delegate_download != inventory_hostname + tags: + - download-package + +- name: "{{ ansible_os_family }} Derivatives: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: deb: "{{ checkmk_agent_agent.file.cre }}" diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 26e310ce0..3b0a33adb 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -117,7 +117,18 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Install Checkmk CRE Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.copy: + src: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + mode: "0644" + when: | + checkmk_agent_edition | lower == "cre" + and checkmk_agent_delegate_download != inventory_hostname + tags: + - download-package + +- name: "{{ ansible_os_family }} Derivatives: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.yum: name: "{{ checkmk_agent_agent.file.cre }}" diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index 86236dbbd..fe68cdd45 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -119,7 +119,18 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Install Checkmk CRE Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.copy: + src: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + mode: "0644" + when: | + checkmk_agent_edition | lower == "cre" + and checkmk_agent_delegate_download != inventory_hostname + tags: + - download-package + +- name: "{{ ansible_os_family }} Derivatives: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: name: "{{ checkmk_agent_agent.file.cre }}" From 188ab87a270c90bf69258c8feecdba423bd79874 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 11:42:22 +0200 Subject: [PATCH 14/31] Bugfix delegated download. --- roles/agent/tasks/Linux.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 0419dbf37..5fcf2b57e 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -14,7 +14,7 @@ checkmk_agent_prep_legacy | bool and ansible_facts.packages['systemd'][0]['version'] | regex_search('\d{1,}') | int < 220 -- name: "{{ ansible_system }}: Download Checkmk CRE agent." +- name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} agent." ansible.builtin.get_url: url: "{{ checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -24,7 +24,8 @@ register: result retries: 3 delay: 10 - until: "result.changed | bool" + until: "not result.failed | bool" + delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package From cb0fc0f5022bf8236c6c6ce8824b2aab0b268938 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 12:07:57 +0200 Subject: [PATCH 15/31] Bugfix agent download. --- roles/agent/tasks/Windows.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index ef59a1b97..5c8750649 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -1,5 +1,5 @@ --- -- name: "{{ ansible_os_family }}: Download Checkmk CRE Agent." +- name: "{{ ansible_os_family }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: url: "{{ checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -8,7 +8,7 @@ register: result retries: 3 delay: 10 - until: "result.changed | bool" + until: "not result.failed | bool" tags: - download-package @@ -99,7 +99,7 @@ tags: - install-package -- name: "{{ ansible_os_family }}: Install Checkmk CRE Agent." +- name: "{{ ansible_os_family }}: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.cre }}" state: present From ef861c2bdb5c46dab4e2970e1579781ff6452a62 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 17 Aug 2023 16:36:25 +0200 Subject: [PATCH 16/31] Bugfix remote registration. --- roles/agent/tasks/Linux.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 5fcf2b57e..d6a4c81e1 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -68,7 +68,7 @@ become: true ansible.builtin.shell: | cmk-update-agent register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_server }} -i {{ checkmk_agent_site }} -p {{ checkmk_agent_protocol }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_protocol }} \ -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} register: checkmk_agent_update_state when: | @@ -82,7 +82,7 @@ become: true ansible.builtin.shell: | cmk-update-agent register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_server }} -i {{ checkmk_agent_site }} -p {{ checkmk_agent_protocol }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_protocol }} \ -U {{ checkmk_agent_user }} -S {{ checkmk_agent_auth }} register: checkmk_agent_update_state when: | @@ -95,7 +95,7 @@ become: true ansible.builtin.shell: | cmk-agent-ctl register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_server }} -i {{ checkmk_agent_site }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} \ -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} --trust-cert register: checkmk_agent_tls_state when: | From 5b2cb8a6f3d0c7595c7fb9b07046dbd30b99c43c Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 22 Aug 2023 12:12:49 +0200 Subject: [PATCH 17/31] Update changelog. --- changelogs/fragments/agent.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelogs/fragments/agent.yml b/changelogs/fragments/agent.yml index f18339599..84cbbeb11 100644 --- a/changelogs/fragments/agent.yml +++ b/changelogs/fragments/agent.yml @@ -1,2 +1,4 @@ minor_changes: - Agent role - Allow the role to download folder-specific agents. +bugfixes: + - Agent role - Fix agent and update registration on remote sites. From f3419b8663725d33048893254a70358ae5fbe063 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 22 Aug 2023 13:37:18 +0200 Subject: [PATCH 18/31] Fix typo. --- plugins/lookup/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/lookup/version.py b/plugins/lookup/version.py index 6defdb10b..1811c7cbe 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -23,7 +23,7 @@ description: automation secret for the REST API access required: True validate_certs: - description: Wether or not to validate TLS cerificates + description: Wether or not to validate TLS certificates type: boolean required: False default: True From deaad5eb86c3621d52df9314353d6e862879d1b4 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 22 Aug 2023 14:20:58 +0200 Subject: [PATCH 19/31] Add integration tests for lookup plugin 'version'. --- .../workflows/ans-int-test-lkp-version.yaml | 68 +++++++++++++++++++ .../targets/lookup_version/tasks/main.yml | 18 +++++ .../targets/lookup_version/tasks/prep.yml | 31 +++++++++ .../targets/lookup_version/tasks/test.yml | 17 +++++ .../targets/lookup_version/vars/main.yml | 33 +++++++++ 5 files changed, 167 insertions(+) create mode 100644 .github/workflows/ans-int-test-lkp-version.yaml create mode 100644 tests/integration/targets/lookup_version/tasks/main.yml create mode 100644 tests/integration/targets/lookup_version/tasks/prep.yml create mode 100644 tests/integration/targets/lookup_version/tasks/test.yml create mode 100644 tests/integration/targets/lookup_version/vars/main.yml diff --git a/.github/workflows/ans-int-test-lkp-version.yaml b/.github/workflows/ans-int-test-lkp-version.yaml new file mode 100644 index 000000000..e9bf66343 --- /dev/null +++ b/.github/workflows/ans-int-test-lkp-version.yaml @@ -0,0 +1,68 @@ +# README: +# - When changing the module name, it needs to be changed in 'env:MODULE_NAME' and in 'on:pull_requests:path'! +# +# Resources: +# - Template for this file: https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml +# - About Ansible integration tests: https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html + +env: + NAMESPACE: checkmk + COLLECTION_NAME: general + MODULE_NAME: lookup_version + +name: Ansible Integration Tests for Version Lookup Module +on: + workflow_dispatch: + pull_request: + branches: + - main + - devel + paths: + - 'plugins/lookup/version.py' + +jobs: + + integration: + runs-on: ubuntu-latest + name: Ⓐ${{ matrix.ansible }}+py${{ matrix.python }} + strategy: + fail-fast: false + matrix: + ansible: + - stable-2.13 + - stable-2.14 + - stable-2.15 + - devel + python: + - '3.8' + - '3.9' + - '3.10' + - '3.11' + exclude: + # Exclude unsupported sets. + - ansible: stable-2.13 + python: '3.11' + + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' # Ansible 2.13 does not support Python 3.11. + + - name: Install ansible-base (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Provide secrets file + run: echo "${{ secrets.CHECKMK_DOWNLOAD_PW }}" > ./tests/integration/files/.dl-secret + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + env: + CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} + + - name: Run integration test + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/tests/integration/targets/lookup_version/tasks/main.yml b/tests/integration/targets/lookup_version/tasks/main.yml new file mode 100644 index 000000000..d2a7115a7 --- /dev/null +++ b/tests/integration/targets/lookup_version/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: "Run preparations." + ansible.builtin.include_tasks: prep.yml + +- name: "Wait for site to be ready." + ansible.builtin.pause: + seconds: 5 + when: | + ((download_pass is defined and download_pass | length) or item.item.edition == 'cre') + and (item.stdout_lines is defined and 'OVERALL 1' in item.stdout_lines) + loop: "{{ site_status.results }}" + +- name: "Testing." + ansible.builtin.include_tasks: test.yml + loop: "{{ test_sites }}" + loop_control: + loop_var: outer_item + when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_version/tasks/prep.yml b/tests/integration/targets/lookup_version/tasks/prep.yml new file mode 100644 index 000000000..7f81d9051 --- /dev/null +++ b/tests/integration/targets/lookup_version/tasks/prep.yml @@ -0,0 +1,31 @@ +--- +- name: "Download Checkmk Versions." + ansible.builtin.get_url: + url: "{{ download_url }}" + dest: /tmp/checkmk-server-{{ item.site }}.deb + mode: "0640" + url_username: "{{ download_user | default(omit) }}" + url_password: "{{ download_pass | default(omit) }}" + loop: "{{ test_sites }}" + when: (download_pass is defined and download_pass | length) or item.edition == "cre" + +- name: "Install Checkmk Versions." + ansible.builtin.apt: + deb: /tmp/checkmk-server-{{ item.site }}.deb + state: present + loop: "{{ test_sites }}" + when: (download_pass is defined and download_pass | length) or item.edition == "cre" + +- name: "Create Sites." + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ automation_secret }} {{ item.site }}" + args: + creates: "/omd/sites/{{ item.site }}" + loop: "{{ test_sites }}" + when: (download_pass is defined and download_pass | length) or item.edition == "cre" + +- name: "Start Sites." + ansible.builtin.shell: "omd status -b {{ item.site }} || omd start {{ item.site }}" + register: site_status + changed_when: site_status.rc == "0" + loop: "{{ test_sites }}" + when: (download_pass is defined and download_pass | length) or item.edition == "cre" diff --git a/tests/integration/targets/lookup_version/tasks/test.yml b/tests/integration/targets/lookup_version/tasks/test.yml new file mode 100644 index 000000000..31a6e8c01 --- /dev/null +++ b/tests/integration/targets/lookup_version/tasks/test.yml @@ -0,0 +1,17 @@ +--- +- name: "{{ outer_item.version }} - Get Checkmk version." + ansible.builtin.debug: + msg: "Version is {{ version }}" + vars: + version: "{{ lookup('checkmk.general.version', + server_url + '/' + outer_item.site, + validate_certs=False, + automation_user=automation_user, + automation_secret=automation_secret) + }}" + delegate_to: localhost + register: looked_up_version + +- name: "{{ outer_item.version }} - Verify Checkmk version." + ansible.builtin.assert: + that: "outer_item.version in looked_up_version.msg" diff --git a/tests/integration/targets/lookup_version/vars/main.yml b/tests/integration/targets/lookup_version/vars/main.yml new file mode 100644 index 000000000..79e330c9c --- /dev/null +++ b/tests/integration/targets/lookup_version/vars/main.yml @@ -0,0 +1,33 @@ +--- +# In these integration tests, we do not normalize the edition naming, but stick +# to the naming of the setup files. For example 'raw' and 'enterprise' rather +# than 'CRE' and 'CEE'. +test_sites: + - version: "2.2.0p7" + edition: "cre" + site: "stable_raw" + - version: "2.2.0p7" + edition: "cee" + site: "stable_ent" + - version: "2.1.0p32" + edition: "cre" + site: "old_raw" + - version: "2.0.0p38" + edition: "cre" + site: "ancient_raw" + +server_url: "http://127.0.0.1/" +automation_user: "cmkadmin" +automation_secret: "d7589df1" + +download_url: "https://download.checkmk.com/checkmk/{{ item.version }}/check-mk-{{ checkmk_server_edition_mapping[item.edition] }}-{{ item.version }}_0.{{ ansible_distribution_release }}_amd64.deb" # noqa yaml[line-length] +download_user: "d-gh-ansible-dl" +download_pass: "{{ lookup('ansible.builtin.file', '/root/ansible_collections/checkmk/general/tests/integration/files/.dl-secret', errors='ignore') | default(omit) }}" # noqa yaml[line-length] + +# Due to inconsistent naming of editions, we normalize them here for convenience +checkmk_server_edition_mapping: + cre: raw + cfe: free + cee: enterprise + cce: cloud + cme: managed From 02a6e34110e399a74e1b005316d6a9591a3f5a08 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 22 Aug 2023 14:22:56 +0200 Subject: [PATCH 20/31] Add Max as a collection maintainer. --- galaxy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/galaxy.yml b/galaxy.yml index 36827f9a5..47b2a7619 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -21,6 +21,7 @@ authors: - "Marcel Arentz (https://github.com/godspeed-you)" - "Robin Gierse (https://github.com/robin-checkmk)" - "Lars Getwan (https://github.com/lgetwan)" + - "Max Sickora (https://github.com/Max-checkmk)" ### OPTIONAL but strongly recommended From 2d97350a47c4db358b3d4b751ee6fece8aa7f9f4 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 22 Aug 2023 14:23:05 +0200 Subject: [PATCH 21/31] Clean up molecule workflows. --- .github/workflows/molecule-role-agent.yaml | 1 - .github/workflows/molecule-role-server.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/molecule-role-agent.yaml b/.github/workflows/molecule-role-agent.yaml index cdbc517ae..970bde40c 100644 --- a/.github/workflows/molecule-role-agent.yaml +++ b/.github/workflows/molecule-role-agent.yaml @@ -75,6 +75,5 @@ jobs: - name: "Run Molecule." run: | cd roles/agent/ - # ln -s ../../requirements.yml requirements.yml molecule test -s ${{ matrix.checkmk }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/molecule-role-server.yaml b/.github/workflows/molecule-role-server.yaml index a49472cea..e88cf82e4 100644 --- a/.github/workflows/molecule-role-server.yaml +++ b/.github/workflows/molecule-role-server.yaml @@ -75,6 +75,5 @@ jobs: - name: "Run Molecule." run: | cd roles/server/ - # ln -s ../../requirements.yml requirements.yml molecule test -s ${{ matrix.checkmk }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} From efa3a44b5a486d0ca063e5ec53a4f051f3d63189 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Wed, 23 Aug 2023 14:15:40 +0200 Subject: [PATCH 22/31] Re-add missing port to handler. A regression caused the port to be missing from the handler. This re-implements 1d7828bf4bdf5eb0da061cc29836943194206c1b. --- roles/agent/handlers/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/agent/handlers/main.yml b/roles/agent/handlers/main.yml index d115b4fb6..0cd1f3246 100644 --- a/roles/agent/handlers/main.yml +++ b/roles/agent/handlers/main.yml @@ -2,7 +2,7 @@ - name: "Activate Changes." listen: activate changes checkmk.general.activation: - server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}" + server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/" site: "{{ checkmk_agent_site }}" automation_user: "{{ checkmk_agent_user }}" automation_secret: "{{ checkmk_agent_auth }}" From eef29cac106e4b2b015d48cb71d787a3566fdd21 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 14:31:56 +0200 Subject: [PATCH 23/31] Stop @Max-checkmk's whining. Aka.: Improve task titles for vanilla agent tasks. --- roles/agent/tasks/Debian.yml | 4 ++-- roles/agent/tasks/Linux.yml | 2 +- roles/agent/tasks/RedHat.yml | 4 ++-- roles/agent/tasks/Suse.yml | 4 ++-- roles/agent/tasks/Windows.yml | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 6f67bfca4..ca07e2135 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -117,7 +117,7 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cre }}" dest: "{{ checkmk_agent_agent.file.cre }}" @@ -128,7 +128,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install Vanilla agent." become: true ansible.builtin.apt: deb: "{{ checkmk_agent_agent.file.cre }}" diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index d6a4c81e1..344a8a0e4 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -14,7 +14,7 @@ checkmk_agent_prep_legacy | bool and ansible_facts.packages['systemd'][0]['version'] | regex_search('\d{1,}') | int < 220 -- name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} agent." +- name: "{{ ansible_system }}: Download Vanilla agent." ansible.builtin.get_url: url: "{{ checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 3b0a33adb..2d10f88fd 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -117,7 +117,7 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cre }}" dest: "{{ checkmk_agent_agent.file.cre }}" @@ -128,7 +128,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install Vanilla agent." become: true ansible.builtin.yum: name: "{{ checkmk_agent_agent.file.cre }}" diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index fe68cdd45..87de4863b 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -119,7 +119,7 @@ tags: - install-package -- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla agent." ansible.builtin.copy: src: "{{ checkmk_agent_agent.file.cre }}" dest: "{{ checkmk_agent_agent.file.cre }}" @@ -130,7 +130,7 @@ tags: - download-package -- name: "{{ ansible_os_family }} Derivatives: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }} Derivatives: Install Vanilla agent." become: true community.general.zypper: name: "{{ checkmk_agent_agent.file.cre }}" diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 5c8750649..23f1c03d2 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -1,5 +1,5 @@ --- -- name: "{{ ansible_os_family }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }}: Download Vanilla agent." ansible.windows.win_get_url: url: "{{ checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" @@ -99,7 +99,7 @@ tags: - install-package -- name: "{{ ansible_os_family }}: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." +- name: "{{ ansible_os_family }}: Install Vanilla agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.cre }}" state: present From 0264d1fc3842fadf1d6f3b23b21de4c2d12bdc8b Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 15:03:14 +0200 Subject: [PATCH 24/31] Bump Checkmk version. --- roles/agent/README.md | 2 +- roles/agent/defaults/main.yml | 2 +- roles/agent/molecule/2.2.0/group_vars/all.yml | 2 +- roles/server/README.md | 2 +- roles/server/defaults/main.yml | 2 +- roles/server/molecule/2.2.0/group_vars/all.yml | 2 +- scripts/release.sh | 2 +- tests/integration/targets/activation/vars/main.yml | 4 ++-- tests/integration/targets/bakery/vars/main.yml | 2 +- tests/integration/targets/contact_group/vars/main.yml | 4 ++-- tests/integration/targets/discovery/vars/main.yml | 4 ++-- tests/integration/targets/downtime/vars/main.yml | 4 ++-- tests/integration/targets/folder/vars/main.yml | 4 ++-- tests/integration/targets/host/vars/main.yml | 4 ++-- tests/integration/targets/host_group/vars/main.yml | 4 ++-- tests/integration/targets/lookup_version/vars/main.yml | 4 ++-- tests/integration/targets/password/vars/main.yml | 4 ++-- tests/integration/targets/rule/vars/main.yml | 4 ++-- tests/integration/targets/service_group/vars/main.yml | 4 ++-- tests/integration/targets/tag_group/vars/main.yml | 4 ++-- tests/integration/targets/user/vars/main.yml | 4 ++-- 21 files changed, 34 insertions(+), 34 deletions(-) diff --git a/roles/agent/README.md b/roles/agent/README.md index bdaf8d890..11b8469ad 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -17,7 +17,7 @@ It can be installed as easy as running: - checkmk_agent_version: "2.2.0p7" + checkmk_agent_version: "2.2.0p8" The Checkmk version of your site. diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index 48b17d816..e5a990470 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -1,5 +1,5 @@ --- -checkmk_agent_version: "2.2.0p7" +checkmk_agent_version: "2.2.0p8" checkmk_agent_edition: cre checkmk_agent_protocol: http checkmk_agent_server: localhost diff --git a/roles/agent/molecule/2.2.0/group_vars/all.yml b/roles/agent/molecule/2.2.0/group_vars/all.yml index d7d4e9258..0a723fdca 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_version: "2.2.0p7" +checkmk_version: "2.2.0p8" checkmk_edition: "cre" checkmk_site: "my_site" automation_user: "cmkadmin" diff --git a/roles/server/README.md b/roles/server/README.md index f7faac221..d1f8372bf 100644 --- a/roles/server/README.md +++ b/roles/server/README.md @@ -23,7 +23,7 @@ To learn about the distributions used in automated tests, inspect the correspond - checkmk_server_version: "2.2.0p7" + checkmk_server_version: "2.2.0p8" The Checkmk version of your site. diff --git a/roles/server/defaults/main.yml b/roles/server/defaults/main.yml index 0a39c3ca9..fe1d3bdbf 100644 --- a/roles/server/defaults/main.yml +++ b/roles/server/defaults/main.yml @@ -24,7 +24,7 @@ checkmk_server_server_stable_os: - Ubuntu-20 - Ubuntu-22 -checkmk_server_version: "2.2.0p7" +checkmk_server_version: "2.2.0p8" checkmk_server_edition: cre checkmk_server_verify_setup: 'true' diff --git a/roles/server/molecule/2.2.0/group_vars/all.yml b/roles/server/molecule/2.2.0/group_vars/all.yml index 5c665de2a..6b5d2a834 100644 --- a/roles/server/molecule/2.2.0/group_vars/all.yml +++ b/roles/server/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_version: "2.2.0p7" +checkmk_version: "2.2.0p8" checkmk_edition: "cre" checkmk_site: "my_site" server_url: "http://127.0.0.1/" diff --git a/scripts/release.sh b/scripts/release.sh index 99527bc41..79e251a82 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -17,7 +17,7 @@ collection_dir="${script_dir%/*}" # Update these as necessary: checkmk_ancient="2.0.0p38" checkmk_oldstable="2.1.0p32" -checkmk_stable="2.2.0p7" +checkmk_stable="2.2.0p8" while getopts 's:t:' OPTION; do case "$OPTION" in diff --git a/tests/integration/targets/activation/vars/main.yml b/tests/integration/targets/activation/vars/main.yml index 07a8e82f5..a552bdaa6 100644 --- a/tests/integration/targets/activation/vars/main.yml +++ b/tests/integration/targets/activation/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/bakery/vars/main.yml b/tests/integration/targets/bakery/vars/main.yml index cad589e93..d06c63b13 100644 --- a/tests/integration/targets/bakery/vars/main.yml +++ b/tests/integration/targets/bakery/vars/main.yml @@ -3,7 +3,7 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/contact_group/vars/main.yml b/tests/integration/targets/contact_group/vars/main.yml index ea9ded16f..8a2186b2c 100644 --- a/tests/integration/targets/contact_group/vars/main.yml +++ b/tests/integration/targets/contact_group/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/discovery/vars/main.yml b/tests/integration/targets/discovery/vars/main.yml index a141225e6..89ca29cbf 100644 --- a/tests/integration/targets/discovery/vars/main.yml +++ b/tests/integration/targets/discovery/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/downtime/vars/main.yml b/tests/integration/targets/downtime/vars/main.yml index 07a8e82f5..a552bdaa6 100644 --- a/tests/integration/targets/downtime/vars/main.yml +++ b/tests/integration/targets/downtime/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/folder/vars/main.yml b/tests/integration/targets/folder/vars/main.yml index 45db8384a..0f8956039 100644 --- a/tests/integration/targets/folder/vars/main.yml +++ b/tests/integration/targets/folder/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/host/vars/main.yml b/tests/integration/targets/host/vars/main.yml index d0c3ec9ef..769511d32 100644 --- a/tests/integration/targets/host/vars/main.yml +++ b/tests/integration/targets/host/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/host_group/vars/main.yml b/tests/integration/targets/host_group/vars/main.yml index eaeabb8f9..49c1187c7 100644 --- a/tests/integration/targets/host_group/vars/main.yml +++ b/tests/integration/targets/host_group/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/lookup_version/vars/main.yml b/tests/integration/targets/lookup_version/vars/main.yml index 79e330c9c..623c0404a 100644 --- a/tests/integration/targets/lookup_version/vars/main.yml +++ b/tests/integration/targets/lookup_version/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/password/vars/main.yml b/tests/integration/targets/password/vars/main.yml index d9688f498..9ddd1a98e 100644 --- a/tests/integration/targets/password/vars/main.yml +++ b/tests/integration/targets/password/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/rule/vars/main.yml b/tests/integration/targets/rule/vars/main.yml index f224f95d4..67f0d7668 100644 --- a/tests/integration/targets/rule/vars/main.yml +++ b/tests/integration/targets/rule/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/service_group/vars/main.yml b/tests/integration/targets/service_group/vars/main.yml index ed777a8cf..74f078998 100644 --- a/tests/integration/targets/service_group/vars/main.yml +++ b/tests/integration/targets/service_group/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/tag_group/vars/main.yml b/tests/integration/targets/tag_group/vars/main.yml index 79e330c9c..623c0404a 100644 --- a/tests/integration/targets/tag_group/vars/main.yml +++ b/tests/integration/targets/tag_group/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index 952520510..e0eb20eb3 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -3,10 +3,10 @@ # to the naming of the setup files. For example 'raw' and 'enterprise' rather # than 'CRE' and 'CEE'. test_sites: - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cre" site: "stable_raw" - - version: "2.2.0p7" + - version: "2.2.0p8" edition: "cee" site: "stable_ent" - version: "2.1.0p32" From 54bfa61bc35729ec533640c3eb0c49a293e19400 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 15:21:32 +0200 Subject: [PATCH 25/31] Enable preflight check for edition. --- changelogs/fragments/server.yml | 2 ++ roles/server/tasks/main.yml | 5 +++++ roles/server/tasks/sites.yml | 4 ++-- roles/server/tasks/update-site.yml | 9 +++++---- roles/server/vars/Debian.yml | 2 +- roles/server/vars/RedHat.yml | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/server.yml diff --git a/changelogs/fragments/server.yml b/changelogs/fragments/server.yml new file mode 100644 index 000000000..241df2cd8 --- /dev/null +++ b/changelogs/fragments/server.yml @@ -0,0 +1,2 @@ +minor_changes: + - Server role - Add preflight check for correct Checkmk edition. diff --git a/roles/server/tasks/main.yml b/roles/server/tasks/main.yml index adb48187f..551d5b8fa 100644 --- a/roles/server/tasks/main.yml +++ b/roles/server/tasks/main.yml @@ -6,6 +6,11 @@ (ansible_distribution_version is not defined) or (ansible_distribution + "-" + ansible_distribution_major_version not in checkmk_server_server_stable_os) +- name: "Preflight - Fail if Checkmk Edition is incorrect." + ansible.builtin.fail: + msg: "The provided Checkmk Edition '{{ checkmk_server_edition | lower }}' does not exist or is not supported by this role." + when: checkmk_server_edition | lower not in checkmk_server_edition_mapping + - name: "Include OS Family specific Variables." ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" tags: diff --git a/roles/server/tasks/sites.yml b/roles/server/tasks/sites.yml index 3962acd68..c19b57c5c 100644 --- a/roles/server/tasks/sites.yml +++ b/roles/server/tasks/sites.yml @@ -3,7 +3,7 @@ become: true ansible.builtin.shell: | set -o pipefail - omd -V {{ item.version }}.{{ checkmk_server_edition }} create {{ item.name }} + omd -V {{ item.version }}.{{ checkmk_server_edition | lower }} create {{ item.name }} args: executable: /bin/bash creates: "/omd/sites/{{ item.name }}" @@ -23,7 +23,7 @@ executable: /bin/bash no_log: true loop: "{{ checkmk_server_sites }}" - changed_when: "checkmk_server_sites_versions.stdout != item.version + '.' + checkmk_server_edition" + changed_when: "checkmk_server_sites_versions.stdout != item.version + '.' + checkmk_server_edition | lower" when: item.state != "absent" register: checkmk_server_sites_versions tags: diff --git a/roles/server/tasks/update-site.yml b/roles/server/tasks/update-site.yml index 55696fbd5..6e5fd93b4 100644 --- a/roles/server/tasks/update-site.yml +++ b/roles/server/tasks/update-site.yml @@ -8,7 +8,7 @@ - name: "Check if desired version is installed." ansible.builtin.shell: | set -o pipefail - omd versions | egrep -o '{{ item.item.version }}.{{ checkmk_server_edition }}' + omd versions | egrep -o '{{ item.item.version }}.{{ checkmk_server_edition | lower }}' args: executable: /bin/bash register: checkmk_server_sites_versions @@ -27,7 +27,7 @@ ansible.builtin.pause: seconds: 5 prompt: | - Proceeding with updating site {{ item.item.name }} from version {{ item.stdout }} to version {{ item.item.version }}.{{ checkmk_server_edition }}. + Proceeding with updating site {{ item.item.name }} from version {{ item.stdout }} to version {{ item.item.version }}.{{ checkmk_server_edition | lower }}. This is a minor patch update.{% if checkmk_server_backup_on_update %} A backup will be created in {{ checkmk_server_backup_dir }}. {% endif %} This can take a while! The site will be down during the update when: | @@ -39,7 +39,8 @@ ansible.builtin.pause: seconds: 60 prompt: > - Proceeding with updating site {{ item.item.name }} from version {{ item.stdout }} to version {{ item.item.version }}.{{ checkmk_server_edition }}.\n + Proceeding with updating site {{ item.item.name }} + from version {{ item.stdout }} to version {{ item.item.version }}.{{ checkmk_server_edition | lower }}.\n This is a major update. This can carry risks. {% if checkmk_server_backup_on_update %} A backup will be created in {{ checkmk_server_backup_dir }}. {% endif %}\n This can take a while! The site will be down during the update @@ -60,7 +61,7 @@ become: true ansible.builtin.shell: | omd stop {{ item.item.name }} - omd -f -V {{ item.item.version }}.{{ checkmk_server_edition }} update --conflict {{ item.item.update_conflict_resolution }} {{ item.item.name }} + omd -f -V {{ item.item.version }}.{{ checkmk_server_edition | lower }} update --conflict {{ item.item.update_conflict_resolution }} {{ item.item.name }} args: executable: /bin/bash register: checkmk_server_sites_updated diff --git a/roles/server/vars/Debian.yml b/roles/server/vars/Debian.yml index ca2f93f44..569f1094b 100644 --- a/roles/server/vars/Debian.yml +++ b/roles/server/vars/Debian.yml @@ -1,5 +1,5 @@ --- -checkmk_server_setup_file: "check-mk-{{ checkmk_server_edition_mapping[checkmk_server_edition] }}-{{ checkmk_server_version }}_0.{{ ansible_distribution_release }}_amd64.deb" # noqa yaml[line-length] +checkmk_server_setup_file: "check-mk-{{ checkmk_server_edition_mapping[checkmk_server_edition | lower] }}-{{ checkmk_server_version }}_0.{{ ansible_distribution_release }}_amd64.deb" # noqa yaml[line-length] checkmk_server_prerequisites: - freeipmi diff --git a/roles/server/vars/RedHat.yml b/roles/server/vars/RedHat.yml index 763b9060f..8494d13a6 100644 --- a/roles/server/vars/RedHat.yml +++ b/roles/server/vars/RedHat.yml @@ -1,6 +1,6 @@ --- -checkmk_server_setup_file: "check-mk-{{ checkmk_server_edition_mapping[checkmk_server_edition] }}-{{ checkmk_server_version }}-el{{ ansible_distribution_major_version }}-38.x86_64.rpm" # noqa yaml[line-length] +checkmk_server_setup_file: "check-mk-{{ checkmk_server_edition_mapping[checkmk_server_edition | lower] }}-{{ checkmk_server_version }}-el{{ ansible_distribution_major_version }}-38.x86_64.rpm" # noqa yaml[line-length] checkmk_server_ports: - 80/tcp From e375f186804a5d0e1e6fef9a44bf063d713b4822 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 15:24:13 +0200 Subject: [PATCH 26/31] Add lookup labels to labeller. --- .github/labels-issues.yml | 9 +++++++++ .github/labels-prs.yml | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/.github/labels-issues.yml b/.github/labels-issues.yml index 52eb4a8b6..354cadc3f 100644 --- a/.github/labels-issues.yml +++ b/.github/labels-issues.yml @@ -49,3 +49,12 @@ module:tag_group: module:user: - 'Component Name: user' + +lookup:version: + - 'Component Name: lookup_version' + +lookup:folder: + - 'Component Name: lookup_folder' + +lookup:folders: + - 'Component Name: lookup_folders' diff --git a/.github/labels-prs.yml b/.github/labels-prs.yml index 47fc9ddca..67984e9b5 100644 --- a/.github/labels-prs.yml +++ b/.github/labels-prs.yml @@ -49,3 +49,9 @@ module:user: lookup:version: - 'plugins/modules/lookup/version.py' + +lookup:folder: + - 'Component Name: lookup_folder' + +lookup:folders: + - 'Component Name: lookup_folders' From 93fadb31dd77cbb7254c9feeecc5695f90ff9254 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 15:46:31 +0200 Subject: [PATCH 27/31] Get rid of mega integration test. Run individual tests once a week instead, in addition to triggered runs. --- .../workflows/ans-int-test-activation.yaml | 2 + .github/workflows/ans-int-test-bakery.yaml | 2 + .../workflows/ans-int-test-contact_group.yaml | 2 + .github/workflows/ans-int-test-discovery.yaml | 2 + .github/workflows/ans-int-test-downtime.yaml | 2 + .github/workflows/ans-int-test-folder.yaml | 2 + .github/workflows/ans-int-test-host.yaml | 2 + .../workflows/ans-int-test-host_group.yaml | 2 + .../workflows/ans-int-test-lkp-version.yaml | 2 + .github/workflows/ans-int-test-password.yaml | 2 + .github/workflows/ans-int-test-rule.yaml | 2 + .../workflows/ans-int-test-service_group.yaml | 2 + .github/workflows/ans-int-test-tag_group.yaml | 2 + .github/workflows/ans-int-test-user.yaml | 2 + .github/workflows/ans-int-tests-full.yaml | 77 ------------------- 15 files changed, 28 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/ans-int-tests-full.yaml diff --git a/.github/workflows/ans-int-test-activation.yaml b/.github/workflows/ans-int-test-activation.yaml index 1d33acf32..870767dbc 100644 --- a/.github/workflows/ans-int-test-activation.yaml +++ b/.github/workflows/ans-int-test-activation.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Activation Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-bakery.yaml b/.github/workflows/ans-int-test-bakery.yaml index 1f0b53fe5..4eb958fc5 100644 --- a/.github/workflows/ans-int-test-bakery.yaml +++ b/.github/workflows/ans-int-test-bakery.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Bakery Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-contact_group.yaml b/.github/workflows/ans-int-test-contact_group.yaml index 210a71d1e..2d62d9f27 100644 --- a/.github/workflows/ans-int-test-contact_group.yaml +++ b/.github/workflows/ans-int-test-contact_group.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Contact Group Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-discovery.yaml b/.github/workflows/ans-int-test-discovery.yaml index c3c43ec55..dc20e6b72 100644 --- a/.github/workflows/ans-int-test-discovery.yaml +++ b/.github/workflows/ans-int-test-discovery.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Discovery Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-downtime.yaml b/.github/workflows/ans-int-test-downtime.yaml index b8772ccb9..029afd046 100644 --- a/.github/workflows/ans-int-test-downtime.yaml +++ b/.github/workflows/ans-int-test-downtime.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Downtime Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-folder.yaml b/.github/workflows/ans-int-test-folder.yaml index 1846bbfcf..4d8624e3b 100644 --- a/.github/workflows/ans-int-test-folder.yaml +++ b/.github/workflows/ans-int-test-folder.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Folder Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-host.yaml b/.github/workflows/ans-int-test-host.yaml index 08f785430..1fc268643 100644 --- a/.github/workflows/ans-int-test-host.yaml +++ b/.github/workflows/ans-int-test-host.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Host Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-host_group.yaml b/.github/workflows/ans-int-test-host_group.yaml index 769a22a7c..f8b06db04 100644 --- a/.github/workflows/ans-int-test-host_group.yaml +++ b/.github/workflows/ans-int-test-host_group.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Host Group Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-lkp-version.yaml b/.github/workflows/ans-int-test-lkp-version.yaml index e9bf66343..52be7382d 100644 --- a/.github/workflows/ans-int-test-lkp-version.yaml +++ b/.github/workflows/ans-int-test-lkp-version.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Version Lookup Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-password.yaml b/.github/workflows/ans-int-test-password.yaml index 0590b47ad..af10021b0 100644 --- a/.github/workflows/ans-int-test-password.yaml +++ b/.github/workflows/ans-int-test-password.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Password Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-rule.yaml b/.github/workflows/ans-int-test-rule.yaml index 76122a6b9..bedcd47c5 100644 --- a/.github/workflows/ans-int-test-rule.yaml +++ b/.github/workflows/ans-int-test-rule.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Rule Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-service_group.yaml b/.github/workflows/ans-int-test-service_group.yaml index 68b7f1d69..20a7fddb2 100644 --- a/.github/workflows/ans-int-test-service_group.yaml +++ b/.github/workflows/ans-int-test-service_group.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Service Group Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-tag_group.yaml b/.github/workflows/ans-int-test-tag_group.yaml index 612eb084b..77303cc20 100644 --- a/.github/workflows/ans-int-test-tag_group.yaml +++ b/.github/workflows/ans-int-test-tag_group.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for Tag Group Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-test-user.yaml b/.github/workflows/ans-int-test-user.yaml index 651a20b04..b8e1f7237 100644 --- a/.github/workflows/ans-int-test-user.yaml +++ b/.github/workflows/ans-int-test-user.yaml @@ -13,6 +13,8 @@ env: name: Ansible Integration Tests for User Module on: workflow_dispatch: + schedule: + - cron: '0 0 * * 0' pull_request: branches: - main diff --git a/.github/workflows/ans-int-tests-full.yaml b/.github/workflows/ans-int-tests-full.yaml deleted file mode 100644 index 84633d978..000000000 --- a/.github/workflows/ans-int-tests-full.yaml +++ /dev/null @@ -1,77 +0,0 @@ -# README: -# - When changing the module name, it needs to be changed in 'env:MODULE_NAME' and in 'on:pull_requests:path'! -# -# Resources: -# - Template for this file: https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml -# - About Ansible integration tests: https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html - -env: - NAMESPACE: checkmk - COLLECTION_NAME: general - -name: Ansible Integration Tests for all Modules -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * *' - -jobs: - - integration: - runs-on: ubuntu-latest - name: ${{ matrix.module }} (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) - strategy: - fail-fast: false - matrix: - ansible: - - stable-2.13 - - stable-2.14 - - stable-2.15 - - devel - python: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - module: - - activation - - bakery - - contact_group - - discovery - - downtime - - folder - - host_group - - host - - password - - rule - - service_group - - tag_group - - user - exclude: - # Exclude unsupported sets. - - ansible: stable-2.13 - python: '3.11' - - steps: - - name: Check out code - uses: actions/checkout@v3 - with: - path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' # Ansible 2.13 does not support Python 3.11. - - - name: Install ansible-base (${{ matrix.ansible }}) - run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check - - - name: Provide secrets file - run: echo "${{ secrets.CHECKMK_DOWNLOAD_PW }}" > ./tests/integration/files/.dl-secret - working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} - env: - CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - - - name: Run integration test - run: ansible-test integration ${{ matrix.module }} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --coverage - working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} From 2d8508ccfbd6b0ea52f96b6c4bc09ddde354a787 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 15:46:45 +0200 Subject: [PATCH 28/31] Run sanity checks prior to release. --- .github/workflows/release.yaml | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c814dfb0f..a71362da4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,7 +5,44 @@ on: # yamllint disable-line rule:truthy workflow_dispatch: jobs: + + # + # Run sanity checks prior to release. + # + + sanity: + runs-on: ubuntu-latest + name: Sanity (Ⓐ${{ matrix.ansible }}) + strategy: + fail-fast: false + matrix: + ansible: + - stable-2.13 + - stable-2.14 + - stable-2.15 + - devel + + steps: + + - name: Check out code + uses: actions/checkout@v3 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' # Ansible 2.13 does not support Python 3.11. + + - name: Install ansible-base (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Run sanity tests + run: ansible-test sanity --docker -v --color --coverage + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + release: + needs: sanity runs-on: ubuntu-latest steps: From aadda907856c9ebe80c5fd96d04d94f6b72be0b5 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 15:56:10 +0200 Subject: [PATCH 29/31] Add changelog. --- changelogs/fragments/agent.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelogs/fragments/agent.yml b/changelogs/fragments/agent.yml index 84cbbeb11..2e87a3727 100644 --- a/changelogs/fragments/agent.yml +++ b/changelogs/fragments/agent.yml @@ -1,4 +1,6 @@ minor_changes: - Agent role - Allow the role to download folder-specific agents. + - Agent role - Add preflight check for correct Checkmk edition. bugfixes: - Agent role - Fix agent and update registration on remote sites. + - Agent role - Fix activation handler URL. From 176b5c24a0c79fbaace48cd9a522d702dfb5251a Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 15:56:22 +0200 Subject: [PATCH 30/31] Fix typos. --- README.md | 2 +- plugins/modules/activation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 59919f461..2a3d5d411 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ See [CONTRIBUTING](CONTRIBUTING.md). See [CHANGELOG.rst](CHANGELOG.rst). ## Roadmap - + This is merely a collection of possible additions to the role. Please do **not** consider a concrete planning document! diff --git a/plugins/modules/activation.py b/plugins/modules/activation.py index 33090ca9c..c0a7a2271 100644 --- a/plugins/modules/activation.py +++ b/plugins/modules/activation.py @@ -29,7 +29,7 @@ default: [] type: raw force_foreign_changes: - description: Wheather to active foreign changes. + description: Whether to active foreign changes. default: false type: bool From c31f7508a07d845fff6d3b5a2b291138f167d573 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 24 Aug 2023 16:47:18 +0200 Subject: [PATCH 31/31] Bump collection version. --- SUPPORT.md | 1 + galaxy.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/SUPPORT.md b/SUPPORT.md index 8491d0770..7549ee571 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -37,3 +37,4 @@ Collection Version | Checkmk Versions | Ansible Versions | Remarks 2.4.1 | 2.0.0p37, 2.1.0p31, 2.2.0p7 | 2.13, 2.14, 2.15 | None 3.0.0 | 2.0.0p38, 2.1.0p32, 2.2.0p7 | 2.13, 2.14, 2.15 | Breaking changes to the following modules: `folder`, `host`, `host_group`, `rule`. 3.1.0 | 2.0.0p38, 2.1.0p32, 2.2.0p7 | 2.13, 2.14, 2.15 | None +3.2.0 | 2.0.0p38, 2.1.0p32, 2.2.0p8 | 2.13, 2.14, 2.15 | None diff --git a/galaxy.yml b/galaxy.yml index 47b2a7619..f16f60614 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ name: general # The version of the collection. Must be compatible with semantic versioning -version: 3.1.0 +version: 3.2.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md