From 80ca89621d3dbd2f09936e082a704f53fd4b0249 Mon Sep 17 00:00:00 2001 From: Gerlof Fokkema Date: Mon, 1 Jul 2024 16:51:17 +0200 Subject: [PATCH] Allow registering on a http subsite with a https central site. Currently the variable `checkmk_agent_server_protocol` is used both for downloading the agent at the central site, and for registering the agent at the subsite, therefore making it mandatory to use http or https on both sites without mixing. Introduces a new variable `checkmk_agent_registration_server_protocol` which defaults to `checkmk_agent_server_protocol`, similar to the other `checkmk_agent_registration_*` variables to solve that. --- roles/agent/defaults/main.yml | 1 + roles/agent/molecule/2.1.0/group_vars/all.yml | 1 + roles/agent/molecule/2.2.0/group_vars/all.yml | 1 + roles/agent/molecule/2.3.0/group_vars/all.yml | 1 + roles/agent/tasks/Linux.yml | 4 ++-- roles/agent/tasks/Win32NT.yml | 2 +- 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index a39a9e605..e82f3fbaf 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -4,6 +4,7 @@ checkmk_agent_edition: cre checkmk_agent_server_protocol: http checkmk_agent_server: localhost checkmk_agent_site: mysite +checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'true' diff --git a/roles/agent/molecule/2.1.0/group_vars/all.yml b/roles/agent/molecule/2.1.0/group_vars/all.yml index 98bf3d455..0112736d4 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -12,6 +12,7 @@ checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" +checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' 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 81d3f7f09..63daf8788 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -12,6 +12,7 @@ checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" +checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' diff --git a/roles/agent/molecule/2.3.0/group_vars/all.yml b/roles/agent/molecule/2.3.0/group_vars/all.yml index 77ff0e1ee..395449edd 100644 --- a/roles/agent/molecule/2.3.0/group_vars/all.yml +++ b/roles/agent/molecule/2.3.0/group_vars/all.yml @@ -12,6 +12,7 @@ checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" +checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 6ddc18fd9..f64ac6ca1 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -106,7 +106,7 @@ become: true ansible.builtin.shell: | cmk-update-agent register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_registration_server_protocol }} \ -U {{ checkmk_agent_user }} -P {{ __checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" register: __checkmk_agent_update_state @@ -122,7 +122,7 @@ become: true ansible.builtin.shell: | cmk-update-agent register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_registration_server_protocol }} \ -U {{ checkmk_agent_user }} -S {{ __checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" register: __checkmk_agent_update_state diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index 5cbe3eb95..189fa8766 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -74,7 +74,7 @@ - name: "{{ ansible_system }}: Register Agent for automatic Updates using Automation Secret." # noqa no-changed-when ansible.windows.win_command: | check_mk_agent.exe updater register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_registration_server_protocol }} \ -U {{ checkmk_agent_user }} -S {{ __checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" register: __checkmk_agent_update_state