From 40aafeceb199eaf79cb3a920ecac978902beb515 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 13:25:47 +0200 Subject: [PATCH 01/25] Merge legacy.yml into Linux.yml. --- roles/agent/tasks/Linux.yml | 19 ++++++++++++++++++- roles/agent/tasks/legacy.yml | 18 ------------------ 2 files changed, 18 insertions(+), 19 deletions(-) delete mode 100644 roles/agent/tasks/legacy.yml diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 5fcf2b57e..472d235a4 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -9,7 +9,24 @@ ansible.builtin.service_facts: - name: "{{ ansible_system }}: Import Legacy agent tasks." - ansible.builtin.include_tasks: "legacy.yml" + block: + - name: "{{ ansible_system }}: Install xinetd" + become: true + ansible.builtin.package: + name: xinetd + state: present + tags: + - install-package + - install-prerequisites + + - name: "{{ ansible_system }}: Enable xinetd" + become: true + ansible.builtin.service: + name: xinetd + state: started + enabled: true + tags: + - enable-xinetd when: | checkmk_agent_prep_legacy | bool and ansible_facts.packages['systemd'][0]['version'] | regex_search('\d{1,}') | int < 220 diff --git a/roles/agent/tasks/legacy.yml b/roles/agent/tasks/legacy.yml deleted file mode 100644 index adc3c38be..000000000 --- a/roles/agent/tasks/legacy.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- name: "{{ ansible_system }}: Install xinetd" - become: true - ansible.builtin.package: - name: xinetd - state: present - tags: - - install-package - - install-prerequisites - -- name: "{{ ansible_system }}: Enable xinetd" - become: true - ansible.builtin.service: - name: xinetd - state: started - enabled: true - tags: - - enable-xinetd From 3b88c36071dab876102f81417b40b72f05008d65 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 13:52:42 +0200 Subject: [PATCH 02/25] Generalize file management. --- roles/agent/tasks/Debian.yml | 105 ------------- roles/agent/tasks/Linux-files.yml | 131 +++++++++++++++++ roles/agent/tasks/Linux.yml | 17 +-- roles/agent/tasks/RedHat.yml | 105 ------------- roles/agent/tasks/Suse.yml | 107 +------------- roles/agent/tasks/Win32NT-files.yml | 199 +++++++++++++++++++++++++ roles/agent/tasks/Win32NT.yml | 2 +- roles/agent/tasks/Windows-WIP.yml | 221 ++++++++++++++++++++++++++++ roles/agent/tasks/Windows.yml | 80 ---------- roles/agent/tasks/main.yml | 6 + roles/agent/vars/main.yml | 6 + 11 files changed, 566 insertions(+), 413 deletions(-) create mode 100644 roles/agent/tasks/Linux-files.yml create mode 100644 roles/agent/tasks/Win32NT-files.yml create mode 100644 roles/agent/tasks/Windows-WIP.yml diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index 6f67bfca4..2cd0e376c 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -1,41 +1,4 @@ --- -- 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 }}" - dest: "{{ checkmk_agent_agent.file.host }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - when: | - 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 - failed_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 - -- name: "Set Fact: Agent State: host-specific." - ansible.builtin.set_fact: - 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_agent_edition | upper }} Agent." - ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.host }}" - dest: "{{ checkmk_agent_agent.file.host }}" - mode: "0644" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_host_specific | bool - and checkmk_agent_delegate_download != inventory_hostname - tags: - - download-package - - name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: @@ -48,63 +11,6 @@ tags: - install-package -- 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 }}" - 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 | lower != "cre" - 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 is defined and checkmk_agent_folder_download_state.status == 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: >- - {{ (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_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 }}" - dest: "{{ checkmk_agent_agent.file.cee }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - become: false - when: | - 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 }}" - tags: - - download-package - -- 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 }}" - mode: "0644" - when: | - checkmk_agent_edition | lower != "cre" - and not checkmk_agent_host_specific | bool - and checkmk_agent_delegate_download != inventory_hostname - tags: - - download-package - - name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: @@ -117,17 +23,6 @@ tags: - install-package -- 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: diff --git a/roles/agent/tasks/Linux-files.yml b/roles/agent/tasks/Linux-files.yml new file mode 100644 index 000000000..2bb3b863c --- /dev/null +++ b/roles/agent/tasks/Linux-files.yml @@ -0,0 +1,131 @@ +--- +- 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 }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + mode: '0640' + when: checkmk_agent_edition | lower == "cre" + register: result + retries: 3 + delay: 10 + until: "not result.failed | bool" + delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package + +- name: "{{ ansible_system }}: 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={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + agent_type=host_name" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.host }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + when: | + 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 + failed_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 + +- name: "Set Fact: Agent State: host-specific." + ansible.builtin.set_fact: + checkmk_agent_host_specific: >- + {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} + +- name: "{{ ansible_system }}: Download folder-specific {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.uri: + url: + "{{ checkmk_agent_agent.url.cee }}?\ + os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + folder_name={{ checkmk_agent_folder }}&\ + agent_type=generic" + 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 | lower != "cre" + 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 is defined and checkmk_agent_folder_download_state.status == 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: >- + {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} + +- name: "{{ ansible_system }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.uri: + url: + "{{ checkmk_agent_agent.url.cee }}?\ + os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + agent_type=generic" + 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 + when: | + 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 }}" + tags: + - download-package + +- name: "{{ ansible_system }}: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." + ansible.builtin.copy: + src: "{{ checkmk_agent_agent.file.host }}" + dest: "{{ checkmk_agent_agent.file.host }}" + mode: "0644" + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_host_specific | bool + and checkmk_agent_delegate_download != inventory_hostname + tags: + - download-package + +- name: "{{ ansible_system }}: 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 }}" + mode: "0644" + when: | + checkmk_agent_edition | lower != "cre" + and not checkmk_agent_host_specific | bool + and checkmk_agent_delegate_download != inventory_hostname + tags: + - download-package + +- name: "{{ ansible_system }}: 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 diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 472d235a4..46aab7870 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -8,7 +8,7 @@ - name: "{{ ansible_system }}: Populate service facts." ansible.builtin.service_facts: -- name: "{{ ansible_system }}: Import Legacy agent tasks." +- name: "{{ ansible_system }}: Import Legacy agent tasks." # noqa key-order[task] block: - name: "{{ ansible_system }}: Install xinetd" become: true @@ -31,21 +31,6 @@ 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." - ansible.builtin.get_url: - url: "{{ checkmk_agent_agent.url.cre }}" - validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cre }}" - mode: '0640' - when: checkmk_agent_edition | lower == "cre" - register: result - retries: 3 - delay: 10 - until: "not result.failed | bool" - delegate_to: "{{ checkmk_agent_delegate_download }}" - tags: - - download-package - - name: "{{ ansible_os_family }}: Run OS Family specific tasks." ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" tags: diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 3b0a33adb..c6a121e6f 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -1,41 +1,4 @@ --- -- 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 }}" - dest: "{{ checkmk_agent_agent.file.host }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - when: | - 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 - failed_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 - -- name: "Set Fact: Agent State: host-specific." - ansible.builtin.set_fact: - 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_agent_edition | upper }} Agent." - ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.host }}" - dest: "{{ checkmk_agent_agent.file.host }}" - mode: "0644" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_host_specific | bool - and checkmk_agent_delegate_download != inventory_hostname - tags: - - download-package - - name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.yum: @@ -48,63 +11,6 @@ tags: - install-package -- 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 }}" - 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 | lower != "cre" - 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 is defined and checkmk_agent_folder_download_state.status == 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: >- - {{ (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_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 }}" - dest: "{{ checkmk_agent_agent.file.cee }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - become: false - when: | - 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 }}" - tags: - - download-package - -- 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 }}" - mode: "0644" - when: | - checkmk_agent_edition | lower != "cre" - and not checkmk_agent_host_specific | bool - and checkmk_agent_delegate_download != inventory_hostname - tags: - - download-package - - name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.yum: @@ -117,17 +23,6 @@ tags: - install-package -- 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: diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index fe68cdd45..42a24c1aa 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -1,41 +1,4 @@ --- -- 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 }}" - dest: "{{ checkmk_agent_agent.file.host }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - when: | - 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 - failed_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 - -- name: "Set Fact: Agent State: host-specific." - ansible.builtin.set_fact: - 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_agent_edition | upper }} Agent." - ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.host }}" - dest: "{{ checkmk_agent_agent.file.host }}" - mode: "0644" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_host_specific | bool - and checkmk_agent_delegate_download != inventory_hostname - tags: - - download-package - - name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: @@ -49,63 +12,6 @@ tags: - install-package -- 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 }}" - 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 | lower != "cre" - 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 is defined and checkmk_agent_folder_download_state.status == 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: >- - {{ (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_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 }}" - dest: "{{ checkmk_agent_agent.file.cee }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - become: false - when: | - 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 }}" - tags: - - download-package - -- 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 }}" - mode: "0644" - when: | - checkmk_agent_edition | lower != "cre" - and not checkmk_agent_host_specific | bool - and checkmk_agent_delegate_download != inventory_hostname - tags: - - download-package - - name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: @@ -119,18 +25,7 @@ tags: - install-package -- 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." +- name: "{{ ansible_os_family }} Derivatives: Install Checkmk {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: name: "{{ checkmk_agent_agent.file.cre }}" diff --git a/roles/agent/tasks/Win32NT-files.yml b/roles/agent/tasks/Win32NT-files.yml new file mode 100644 index 000000000..8e21a601d --- /dev/null +++ b/roles/agent/tasks/Win32NT-files.yml @@ -0,0 +1,199 @@ +--- +- name: "Download to managed Host." + when: checkmk_agent_delegate_download == inventory_hostname + block: + - name: "{{ ansible_system }}: 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 }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + when: | + checkmk_agent_edition | lower == "cre" + register: result + retries: 3 + delay: 10 + until: "not result.failed | bool" + + - name: "{{ ansible_system }}: 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={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + agent_type=host_name" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.host }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + when: | + 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' + 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 }}" + + - name: "Set Fact: Agent State: host-specific." + ansible.builtin.set_fact: + checkmk_agent_host_specific: >- + {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} + + - name: "{{ ansible_system }}: Download folder-specific {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_get_url: + url: + "{{ checkmk_agent_agent.url.cee }}?\ + os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + folder_name={{ checkmk_agent_folder }}&\ + agent_type=generic" + 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 | lower != "cre" + 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 }}" + + - name: "Set Fact: Agent State: folder-specific." + ansible.builtin.set_fact: + checkmk_agent_folder_specific: >- + {{ (checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200) | bool }} + + - name: "{{ ansible_system }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_get_url: + url: + "{{ checkmk_agent_agent.url.cee }}?\ + os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + agent_type=generic" + 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" + when: | + 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 }}" + + +- name: "Download to delegated Host." + when: checkmk_agent_delegate_download != inventory_hostname + block: + - name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent (delegated)." + ansible.builtin.uri: + url: "{{ checkmk_agent_agent.url.cre }}" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + when: | + checkmk_agent_edition | lower == "cre" + register: result + retries: 3 + delay: 10 + until: "not result.failed | bool" + delegate_to: "{{ checkmk_agent_delegate_download }}" + + - name: "{{ ansible_system }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." + ansible.builtin.uri: + url: + "{{ checkmk_agent_agent.url.cee }}?\ + host_name={{ checkmk_agent_host_name }}&\ + os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + agent_type=host_name" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.host }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + when: | + 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' + 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 }}" + + - name: "Set Fact: Agent State: host-specific." + ansible.builtin.set_fact: + checkmk_agent_host_specific: >- + {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} + + - name: "{{ ansible_system }}: Download folder-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." + ansible.builtin.uri: + url: + "{{ checkmk_agent_agent.url.cee }}?\ + os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + folder_name={{ checkmk_agent_folder }}&\ + agent_type=generic" + 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 | lower != "cre" + 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 }}" + + - name: "Set Fact: Agent State: folder-specific." + ansible.builtin.set_fact: + checkmk_agent_folder_specific: >- + {{ (checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200) | bool }} + + - name: "{{ ansible_system }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent (delegated)." + ansible.builtin.uri: + url: + "{{ checkmk_agent_agent.url.cee }}?\ + os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + agent_type=generic" + 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" + when: | + 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 }}" + + - name: "{{ ansible_system }}: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_copy: + src: "{{ checkmk_agent_agent.file.host }}" + dest: "{{ checkmk_agent_agent.file.host }}" + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_host_specific | bool + + - name: "{{ ansible_system }}: Transfer GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_copy: + src: "{{ checkmk_agent_agent.file.cee }}" + dest: "{{ checkmk_agent_agent.file.cee }}" + when: | + checkmk_agent_edition | lower != "cre" + and not checkmk_agent_host_specific | bool + + - name: "{{ ansible_system }}: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_copy: + src: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + when: | + checkmk_agent_edition | lower == "cre" diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index 876b21f78..bf8e14452 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -1,5 +1,5 @@ --- -- name: "({{ ansible_os_family }}): Run OS Family specific tasks." +- name: "{{ ansible_os_family }}: Run OS Family specific tasks." ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" tags: - include-os-family-tasks diff --git a/roles/agent/tasks/Windows-WIP.yml b/roles/agent/tasks/Windows-WIP.yml new file mode 100644 index 000000000..1907844e8 --- /dev/null +++ b/roles/agent/tasks/Windows-WIP.yml @@ -0,0 +1,221 @@ +--- +- 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 }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + when: | + checkmk_agent_edition | lower == "cre" + and checkmk_agent_delegate_download == inventory_hostname + register: result + retries: 3 + delay: 10 + until: "not result.failed | bool" + tags: + - download-package + +- name: "{{ ansible_os_family }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent (delegated)." + ansible.builtin.uri: + url: "{{ checkmk_agent_agent.url.cre }}" + validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + when: | + checkmk_agent_edition | lower == "cre" + and checkmk_agent_delegate_download != inventory_hostname + register: result + retries: 3 + delay: 10 + until: "not result.failed | bool" + delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package + +- 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 }}" + dest: "{{ checkmk_agent_agent.file.host }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_delegate_download == inventory_hostname + register: checkmk_agent_host_download_state + # This task may fail, as we fall back to the generic agent in that case + failed_when: 'false' + changed_when: checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 + delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package + +- name: "{{ ansible_os_family }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." + ansible.builtin.uri: + 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 }}" + dest: "{{ checkmk_agent_agent.file.host }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_delegate_download != inventory_hostname + register: checkmk_agent_host_download_state + # This task may fail, as we fall back to the generic agent in that case + failed_when: 'false' + changed_when: checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 + delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package + +- name: "Set Fact: Agent State: host-specific." + ansible.builtin.set_fact: + checkmk_agent_host_specific: >- + {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} + +- name: "{{ ansible_os_family }} Derivatives: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_copy: + src: "{{ checkmk_agent_agent.file.host }}" + dest: "{{ checkmk_agent_agent.file.host }}" + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_host_specific | bool + and checkmk_agent_delegate_download != inventory_hostname + tags: + - download-package + +- name: "{{ ansible_os_family }}: Install host-specific {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_package: + path: "{{ checkmk_agent_agent.file.host }}" + state: present + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_host_specific | bool + tags: + - install-package + +- 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 }}" + 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 | lower != "cre" + and checkmk_agent_delegate_download == inventory_hostname + 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: "{{ ansible_os_family }} Derivatives: Download folder-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." + ansible.builtin.uri: + 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 | lower != "cre" + and checkmk_agent_delegate_download != inventory_hostname + 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: >- + {{ (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_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 }}" + dest: "{{ checkmk_agent_agent.file.cee }}" + method: GET + headers: + Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Accept: "application/octet-stream" + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_delegate_download == inventory_hostname + 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 }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent (delegated)." + ansible.builtin.uri: + url: "{{ checkmk_agent_agent.url.cee }}?os_type=windows_msi&agent_type=generic" + 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" + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_delegate_download != inventory_hostname + 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 or folder-specific {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_copy: + src: "{{ checkmk_agent_agent.file.cee }}" + dest: "{{ checkmk_agent_agent.file.cee }}" + when: | + checkmk_agent_edition | lower != "cre" + and checkmk_agent_delegate_download != inventory_hostname + and not checkmk_agent_host_specific | bool + tags: + - download-package + +- 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 + when: | + checkmk_agent_edition | lower != "cre" + and not checkmk_agent_host_specific | bool + tags: + - install-package + +- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_copy: + src: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ checkmk_agent_agent.file.cre }}" + when: | + checkmk_agent_edition | lower == "cre" + and checkmk_agent_delegate_download != inventory_hostname + tags: + - download-package + +- name: "{{ ansible_os_family }}: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." + ansible.windows.win_package: + path: "{{ checkmk_agent_agent.file.cre }}" + state: present + when: checkmk_agent_edition | lower == "cre" + tags: + - install-package diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 5c8750649..14a1cdd96 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -1,41 +1,4 @@ --- -- 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 }}" - dest: "{{ checkmk_agent_agent.file.cre }}" - when: checkmk_agent_edition | lower == "cre" - register: result - retries: 3 - delay: 10 - until: "not result.failed | bool" - tags: - - download-package - -- 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 }}" - dest: "{{ checkmk_agent_agent.file.host }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - when: | - 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' - 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: >- - {{ (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_agent_edition | upper }} Agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.host }}" @@ -46,49 +9,6 @@ tags: - install-package -- 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 }}" - 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 | lower != "cre" - 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: >- - {{ (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_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 }}" - dest: "{{ checkmk_agent_agent.file.cee }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - when: | - 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 }}" - tags: - - download-package - - name: "{{ ansible_os_family }}: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.cee }}" diff --git a/roles/agent/tasks/main.yml b/roles/agent/tasks/main.yml index bd414bc8f..d76624681 100644 --- a/roles/agent/tasks/main.yml +++ b/roles/agent/tasks/main.yml @@ -9,6 +9,12 @@ tags: - include-os-family-vars +- name: "{{ ansible_system }}: Include File Management." + ansible.builtin.include_tasks: "{{ ansible_system }}-files.yml" + tags: + - include-system-tasks + - download-package + - name: "{{ ansible_system }}: Include OS specific tasks." ansible.builtin.include_tasks: "{{ ansible_system }}.yml" tags: diff --git a/roles/agent/vars/main.yml b/roles/agent/vars/main.yml index 6211fb2a7..59ccd517d 100644 --- a/roles/agent/vars/main.yml +++ b/roles/agent/vars/main.yml @@ -10,3 +10,9 @@ checkmk_agent_edition_mapping: cee: enterprise cce: cloud cme: managed + +checkmk_agent_files_mapping: + Debian: linux_deb + RedHat: linux_rpm + Suse: linux_rpm + Windows: windows_msi From 9b2cdc0c1ad488a1f028aecfbb99048b273447c2 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 14:10:12 +0200 Subject: [PATCH 03/25] Fix variable usage in names. --- roles/agent/tasks/Linux-files.yml | 4 ++-- roles/agent/tasks/Linux.yml | 6 +++--- roles/agent/tasks/Win32NT-files.yml | 12 ++++++------ roles/agent/tasks/Win32NT.yml | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/roles/agent/tasks/Linux-files.yml b/roles/agent/tasks/Linux-files.yml index 2bb3b863c..7090787ed 100644 --- a/roles/agent/tasks/Linux-files.yml +++ b/roles/agent/tasks/Linux-files.yml @@ -38,7 +38,7 @@ tags: - download-package -- name: "Set Fact: Agent State: host-specific." +- name: "{{ ansible_system }}: Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} @@ -69,7 +69,7 @@ tags: - download-package -- name: "Set Fact: Agent State: folder-specific." +- name: "{{ ansible_system }}: Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 46aab7870..5a8904e09 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -31,12 +31,12 @@ checkmk_agent_prep_legacy | bool and ansible_facts.packages['systemd'][0]['version'] | regex_search('\d{1,}') | int < 220 -- name: "{{ ansible_os_family }}: Run OS Family specific tasks." +- name: "{{ ansible_system }}: Run OS Family specific tasks." ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" tags: - include-os-family-tasks -- name: "Create host on server." +- name: "{{ ansible_system }}: Create host on server." checkmk.general.host: server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/" site: "{{ checkmk_agent_site }}" @@ -105,7 +105,7 @@ and checkmk_agent_tls | bool and (checkmk_agent_auth is defined and checkmk_agent_auth | length) -- name: "Verify Checkmk Agent Port is open." +- name: "{{ ansible_system }}: Verify Checkmk Agent Port is open." ansible.builtin.wait_for: port: 6556 timeout: 60 diff --git a/roles/agent/tasks/Win32NT-files.yml b/roles/agent/tasks/Win32NT-files.yml index 8e21a601d..bcac2e30b 100644 --- a/roles/agent/tasks/Win32NT-files.yml +++ b/roles/agent/tasks/Win32NT-files.yml @@ -1,5 +1,5 @@ --- -- name: "Download to managed Host." +- name: "{{ ansible_system }}: Download to managed Host." when: checkmk_agent_delegate_download == inventory_hostname block: - name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent." @@ -35,7 +35,7 @@ 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 }}" - - name: "Set Fact: Agent State: host-specific." + - name: "{{ ansible_system }}: Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} @@ -63,7 +63,7 @@ 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 }}" - - name: "Set Fact: Agent State: folder-specific." + - name: "{{ ansible_system }}: Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- {{ (checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200) | bool }} @@ -87,7 +87,7 @@ delegate_to: "{{ checkmk_agent_delegate_download }}" -- name: "Download to delegated Host." +- name: "{{ ansible_system }}: Download to delegated Host." when: checkmk_agent_delegate_download != inventory_hostname block: - name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent (delegated)." @@ -124,7 +124,7 @@ 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 }}" - - name: "Set Fact: Agent State: host-specific." + - name: "{{ ansible_system }}: Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} @@ -152,7 +152,7 @@ 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 }}" - - name: "Set Fact: Agent State: folder-specific." + - name: "{{ ansible_system }}: Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- {{ (checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200) | bool }} diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index bf8e14452..4244a0d32 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -1,10 +1,10 @@ --- -- name: "{{ ansible_os_family }}: Run OS Family specific tasks." +- name: "{{ ansible_system }}: Run OS Family specific tasks." ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" tags: - include-os-family-tasks -- name: "Create host on server." +- name: "{{ ansible_system }}: Create host on server." checkmk.general.host: server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/" site: "{{ checkmk_agent_site }}" @@ -24,17 +24,17 @@ when: checkmk_agent_add_host | bool notify: "activate changes" -- name: "Check for Agent Controller Binary." +- name: "{{ ansible_system }}: Check for Agent Controller Binary." ansible.windows.win_stat: path: "{{ checkmk_agent_controller_binary_path }}" register: checkmk_agent_controller_binary -- name: "Check for Agent Binary." +- name: "{{ ansible_system }}: Check for Agent Binary." ansible.windows.win_stat: path: "{{ checkmk_agent_binary_path }}" register: checkmk_agent_binary -- name: "Register Agent for automatic Updates using User Password." # noqa no-changed-when +- name: "{{ ansible_system }}: Register Agent for automatic Updates using User Password." # 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_protocol }} \ @@ -49,7 +49,7 @@ and (checkmk_agent_pass is defined and checkmk_agent_pass | length) and (checkmk_agent_secret is not defined) -- name: "Register Agent for automatic Updates using Automation Secret." # noqa no-changed-when +- 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_protocol }} \ @@ -67,7 +67,7 @@ ansible.builtin.meta: flush_handlers -- name: "Register Agent for TLS." # noqa no-changed-when +- name: "{{ ansible_system }}: Register Agent for TLS." # noqa no-changed-when ansible.windows.win_command: | cmk-agent-ctl.exe register -H {{ checkmk_agent_host_name }} \ -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} \ @@ -80,7 +80,7 @@ and checkmk_agent_tls | bool and (checkmk_agent_auth is defined and checkmk_agent_auth | length) -- name: "Verify Checkmk Agent Port is open." +- name: "{{ ansible_system }}: Verify Checkmk Agent Port is open." ansible.windows.win_wait_for: port: 6556 timeout: 60 From dcb5056357861f981dec3e6019c944aa1735caee Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 15 Aug 2023 14:10:25 +0200 Subject: [PATCH 04/25] Remove WIP file. --- roles/agent/tasks/Windows-WIP.yml | 221 ------------------------------ 1 file changed, 221 deletions(-) delete mode 100644 roles/agent/tasks/Windows-WIP.yml diff --git a/roles/agent/tasks/Windows-WIP.yml b/roles/agent/tasks/Windows-WIP.yml deleted file mode 100644 index 1907844e8..000000000 --- a/roles/agent/tasks/Windows-WIP.yml +++ /dev/null @@ -1,221 +0,0 @@ ---- -- 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 }}" - dest: "{{ checkmk_agent_agent.file.cre }}" - when: | - checkmk_agent_edition | lower == "cre" - and checkmk_agent_delegate_download == inventory_hostname - register: result - retries: 3 - delay: 10 - until: "not result.failed | bool" - tags: - - download-package - -- name: "{{ ansible_os_family }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent (delegated)." - ansible.builtin.uri: - url: "{{ checkmk_agent_agent.url.cre }}" - validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cre }}" - when: | - checkmk_agent_edition | lower == "cre" - and checkmk_agent_delegate_download != inventory_hostname - register: result - retries: 3 - delay: 10 - until: "not result.failed | bool" - delegate_to: "{{ checkmk_agent_delegate_download }}" - tags: - - download-package - -- 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 }}" - dest: "{{ checkmk_agent_agent.file.host }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_delegate_download == inventory_hostname - register: checkmk_agent_host_download_state - # This task may fail, as we fall back to the generic agent in that case - failed_when: 'false' - changed_when: checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 - delegate_to: "{{ checkmk_agent_delegate_download }}" - tags: - - download-package - -- name: "{{ ansible_os_family }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." - ansible.builtin.uri: - 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 }}" - dest: "{{ checkmk_agent_agent.file.host }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_delegate_download != inventory_hostname - register: checkmk_agent_host_download_state - # This task may fail, as we fall back to the generic agent in that case - failed_when: 'false' - changed_when: checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 - delegate_to: "{{ checkmk_agent_delegate_download }}" - tags: - - download-package - -- name: "Set Fact: Agent State: host-specific." - ansible.builtin.set_fact: - checkmk_agent_host_specific: >- - {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} - -- name: "{{ ansible_os_family }} Derivatives: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." - ansible.windows.win_copy: - src: "{{ checkmk_agent_agent.file.host }}" - dest: "{{ checkmk_agent_agent.file.host }}" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_host_specific | bool - and checkmk_agent_delegate_download != inventory_hostname - tags: - - download-package - -- name: "{{ ansible_os_family }}: Install host-specific {{ checkmk_agent_edition | upper }} Agent." - ansible.windows.win_package: - path: "{{ checkmk_agent_agent.file.host }}" - state: present - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_host_specific | bool - tags: - - install-package - -- 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 }}" - 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 | lower != "cre" - and checkmk_agent_delegate_download == inventory_hostname - 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: "{{ ansible_os_family }} Derivatives: Download folder-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." - ansible.builtin.uri: - 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 | lower != "cre" - and checkmk_agent_delegate_download != inventory_hostname - 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: >- - {{ (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_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 }}" - dest: "{{ checkmk_agent_agent.file.cee }}" - method: GET - headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" - Accept: "application/octet-stream" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_delegate_download == inventory_hostname - 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 }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent (delegated)." - ansible.builtin.uri: - url: "{{ checkmk_agent_agent.url.cee }}?os_type=windows_msi&agent_type=generic" - 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" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_delegate_download != inventory_hostname - 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 or folder-specific {{ checkmk_agent_edition | upper }} Agent." - ansible.windows.win_copy: - src: "{{ checkmk_agent_agent.file.cee }}" - dest: "{{ checkmk_agent_agent.file.cee }}" - when: | - checkmk_agent_edition | lower != "cre" - and checkmk_agent_delegate_download != inventory_hostname - and not checkmk_agent_host_specific | bool - tags: - - download-package - -- 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 - when: | - checkmk_agent_edition | lower != "cre" - and not checkmk_agent_host_specific | bool - tags: - - install-package - -- name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." - ansible.windows.win_copy: - src: "{{ checkmk_agent_agent.file.cre }}" - dest: "{{ checkmk_agent_agent.file.cre }}" - when: | - checkmk_agent_edition | lower == "cre" - and checkmk_agent_delegate_download != inventory_hostname - tags: - - download-package - -- name: "{{ ansible_os_family }}: Install Vanilla {{ checkmk_agent_edition | upper }} Agent." - ansible.windows.win_package: - path: "{{ checkmk_agent_agent.file.cre }}" - state: present - when: checkmk_agent_edition | lower == "cre" - tags: - - install-package From 77d68179dbbfe1bbd4c4599eb4425052cc7b873a Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 12 Sep 2023 10:55:25 +0200 Subject: [PATCH 05/25] Rename variables for more clarity. --- playbooks/usecases/remote-registration.yml | 2 +- roles/agent/README.md | 4 ++-- roles/agent/defaults/main.yml | 4 ++-- roles/agent/handlers/main.yml | 2 +- roles/agent/molecule/2.0.0/group_vars/all.yml | 4 ++-- roles/agent/molecule/2.0.0/verify.yml | 4 ++-- roles/agent/molecule/2.1.0/group_vars/all.yml | 4 ++-- roles/agent/molecule/2.1.0/verify.yml | 4 ++-- roles/agent/molecule/2.2.0/group_vars/all.yml | 4 ++-- roles/agent/molecule/2.2.0/verify.yml | 4 ++-- roles/agent/tasks/Linux.yml | 6 +++--- roles/agent/tasks/Win32NT.yml | 6 +++--- roles/agent/tasks/main.yml | 4 ++-- roles/agent/vars/main.yml | 2 +- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/playbooks/usecases/remote-registration.yml b/playbooks/usecases/remote-registration.yml index ded1ce7aa..fc45ffc16 100644 --- a/playbooks/usecases/remote-registration.yml +++ b/playbooks/usecases/remote-registration.yml @@ -14,7 +14,7 @@ checkmk_agent_user: "cmkadmin" checkmk_agent_pass: "password" # Here comes the part, where we get into remote registration - checkmk_agent_protocol: http + checkmk_agent_server_protocol: http # The following should be set to the central site. # This where you configure the host objects. # Currently the agent package is also pulled from here. diff --git a/roles/agent/README.md b/roles/agent/README.md index bdaf8d890..2cf910235 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -33,7 +33,7 @@ The edition you are using. Valid values are `cre`, `cfe`, `cee`, `cce` and `cme` For details about the editions see: https://checkmk.com/product/editions - checkmk_agent_protocol: http + checkmk_agent_server_protocol: http The protocol used to connect to your Checkmk site. @@ -45,7 +45,7 @@ The FQDN or IP address of your Checkmk server. Whether to validate the SSL certificate of the Checkmk server. - checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% endif %}" + checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" The port of the web interface of your Checkmk server. Defaults to port 80 for http and port 443 for https. diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index 48b17d816..dee57af7b 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -1,13 +1,13 @@ --- checkmk_agent_version: "2.2.0p7" checkmk_agent_edition: cre -checkmk_agent_protocol: http +checkmk_agent_server_protocol: http checkmk_agent_server: localhost checkmk_agent_site: my_site checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'true' -checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% endif %}" +checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ automation_user | default('automation') }}" # Depending on which user you will be using, set the password or secret: diff --git a/roles/agent/handlers/main.yml b/roles/agent/handlers/main.yml index d115b4fb6..057f88cfa 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_server_protocol }}://{{ checkmk_agent_server }}" site: "{{ checkmk_agent_site }}" automation_user: "{{ checkmk_agent_user }}" automation_secret: "{{ checkmk_agent_auth }}" diff --git a/roles/agent/molecule/2.0.0/group_vars/all.yml b/roles/agent/molecule/2.0.0/group_vars/all.yml index 0334ffa08..9a23f4095 100644 --- a/roles/agent/molecule/2.0.0/group_vars/all.yml +++ b/roles/agent/molecule/2.0.0/group_vars/all.yml @@ -9,13 +9,13 @@ automation_secret: "d7589df1" # Agent Role checkmk_agent_version: "{{ checkmk_version }}" checkmk_agent_edition: "{{ checkmk_edition }}" -checkmk_agent_protocol: http +checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_site }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' -checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% endif %}" +checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ automation_user | default('automation') }}" # Depending on which user you will be using, set the password or secret: diff --git a/roles/agent/molecule/2.0.0/verify.yml b/roles/agent/molecule/2.0.0/verify.yml index 868935aaa..3494359f2 100644 --- a/roles/agent/molecule/2.0.0/verify.yml +++ b/roles/agent/molecule/2.0.0/verify.yml @@ -24,8 +24,8 @@ ansible.builtin.wait_for: port: 6556 connect_timeout: 30 - register: checkmk_agent_port + register: checkmk_agent_server_port - name: "Test Agent Service is listening on port 6556." ansible.builtin.assert: - that: "(checkmk_agent_port.port == 6556) and (checkmk_agent_port.state == 'started')" + that: "(checkmk_agent_server_port.port == 6556) and (checkmk_agent_server_port.state == 'started')" 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 303023b4d..f579826dc 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -9,13 +9,13 @@ automation_secret: "d7589df1" # Agent Role checkmk_agent_version: "{{ checkmk_version }}" checkmk_agent_edition: "{{ checkmk_edition }}" -checkmk_agent_protocol: http +checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_site }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' -checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% endif %}" +checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ automation_user | default('automation') }}" # Depending on which user you will be using, set the password or secret: diff --git a/roles/agent/molecule/2.1.0/verify.yml b/roles/agent/molecule/2.1.0/verify.yml index 79fce6e30..7ace07b48 100644 --- a/roles/agent/molecule/2.1.0/verify.yml +++ b/roles/agent/molecule/2.1.0/verify.yml @@ -24,8 +24,8 @@ ansible.builtin.wait_for: port: 6556 connect_timeout: 30 - register: checkmk_agent_port + register: checkmk_agent_server_port - name: "Test Agent Service is listening on port 6556." ansible.builtin.assert: - that: "(checkmk_agent_port.port == 6556) and (checkmk_agent_port.state == 'started')" + that: "(checkmk_agent_server_port.port == 6556) and (checkmk_agent_server_port.state == 'started')" 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..b9e96a63c 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -9,13 +9,13 @@ automation_secret: "d7589df1" # Agent Role checkmk_agent_version: "{{ checkmk_version }}" checkmk_agent_edition: "{{ checkmk_edition }}" -checkmk_agent_protocol: http +checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_site }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' -checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% endif %}" +checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ automation_user | default('automation') }}" # Depending on which user you will be using, set the password or secret: diff --git a/roles/agent/molecule/2.2.0/verify.yml b/roles/agent/molecule/2.2.0/verify.yml index 79fce6e30..7ace07b48 100644 --- a/roles/agent/molecule/2.2.0/verify.yml +++ b/roles/agent/molecule/2.2.0/verify.yml @@ -24,8 +24,8 @@ ansible.builtin.wait_for: port: 6556 connect_timeout: 30 - register: checkmk_agent_port + register: checkmk_agent_server_port - name: "Test Agent Service is listening on port 6556." ansible.builtin.assert: - that: "(checkmk_agent_port.port == 6556) and (checkmk_agent_port.state == 'started')" + that: "(checkmk_agent_server_port.port == 6556) and (checkmk_agent_server_port.state == 'started')" diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 5a8904e09..364529148 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -38,7 +38,7 @@ - name: "{{ ansible_system }}: Create host on server." checkmk.general.host: - server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/" + server_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_port }}/" site: "{{ checkmk_agent_site }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" automation_user: "{{ checkmk_agent_user }}" @@ -70,7 +70,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_server }} -i {{ checkmk_agent_site }} -p {{ checkmk_agent_server_protocol }} \ -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} register: checkmk_agent_update_state when: | @@ -84,7 +84,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_server }} -i {{ checkmk_agent_site }} -p {{ checkmk_agent_server_protocol }} \ -U {{ checkmk_agent_user }} -S {{ checkmk_agent_auth }} register: checkmk_agent_update_state when: | diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index 4244a0d32..d1eac5aef 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -6,7 +6,7 @@ - name: "{{ ansible_system }}: Create host on server." checkmk.general.host: - server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/" + server_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_port }}/" site: "{{ checkmk_agent_site }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" automation_user: "{{ checkmk_agent_user }}" @@ -37,7 +37,7 @@ - name: "{{ ansible_system }}: Register Agent for automatic Updates using User Password." # 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_protocol }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} register: checkmk_agent_update_state args: @@ -52,7 +52,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_protocol }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ -U {{ checkmk_agent_user }} -S {{ checkmk_agent_auth }} register: checkmk_agent_update_state args: diff --git a/roles/agent/tasks/main.yml b/roles/agent/tasks/main.yml index d76624681..b6960c778 100644 --- a/roles/agent/tasks/main.yml +++ b/roles/agent/tasks/main.yml @@ -23,7 +23,7 @@ - name: "Fetch fresh monitoring data from host." become: false checkmk.general.discovery: - server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/" + server_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_port }}/" site: "{{ checkmk_agent_site }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" automation_user: "{{ checkmk_agent_user }}" @@ -41,7 +41,7 @@ - name: "Update monitored services and labels on host." become: false checkmk.general.discovery: - server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/" + server_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_port }}/" site: "{{ checkmk_agent_site }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" automation_user: "{{ checkmk_agent_user }}" diff --git a/roles/agent/vars/main.yml b/roles/agent/vars/main.yml index 59ccd517d..f2858a11d 100644 --- a/roles/agent/vars/main.yml +++ b/roles/agent/vars/main.yml @@ -1,5 +1,5 @@ --- -checkmk_agent_site_url: "{{ checkmk_agent_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_port }}/{{ checkmk_agent_site }}" +checkmk_agent_site_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_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] From ae8a1aa7cbd16f4d9a1b62b3803becd10e93b025 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 12 Sep 2023 11:12:31 +0200 Subject: [PATCH 06/25] Make agent port configurable. --- roles/agent/defaults/main.yml | 1 + roles/agent/molecule/2.0.0/verify.yml | 8 ++++---- roles/agent/molecule/2.1.0/verify.yml | 8 ++++---- roles/agent/molecule/2.2.0/verify.yml | 8 ++++---- roles/agent/tasks/Linux.yml | 2 +- roles/agent/tasks/RedHat.yml | 2 +- roles/agent/tasks/Win32NT.yml | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index dee57af7b..3d5975eb2 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -9,6 +9,7 @@ checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'true' checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ automation_user | default('automation') }}" +checkmk_agent_port: "6556" # Depending on which user you will be using, set the password or secret: # checkmk_agent_pass: "{{ automation_secret }}" diff --git a/roles/agent/molecule/2.0.0/verify.yml b/roles/agent/molecule/2.0.0/verify.yml index 3494359f2..a4a8a4062 100644 --- a/roles/agent/molecule/2.0.0/verify.yml +++ b/roles/agent/molecule/2.0.0/verify.yml @@ -22,10 +22,10 @@ - name: "Test that the Agent is listening on the default Port." ansible.builtin.wait_for: - port: 6556 + port: "{{ checkmk_agent_port }}" connect_timeout: 30 - register: checkmk_agent_server_port + register: checkmk_agent_port_state - - name: "Test Agent Service is listening on port 6556." + - name: "Test Agent Service is listening on port {{ checkmk_agent_port }}." ansible.builtin.assert: - that: "(checkmk_agent_server_port.port == 6556) and (checkmk_agent_server_port.state == 'started')" + that: "(checkmk_agent_port_state.port == checkmk_agent_port) and (checkmk_agent_port_state.state == 'started')" diff --git a/roles/agent/molecule/2.1.0/verify.yml b/roles/agent/molecule/2.1.0/verify.yml index 7ace07b48..e2f9cc8f4 100644 --- a/roles/agent/molecule/2.1.0/verify.yml +++ b/roles/agent/molecule/2.1.0/verify.yml @@ -22,10 +22,10 @@ - name: "Test that the Agent is listening on the default Port." ansible.builtin.wait_for: - port: 6556 + port: "{{ checkmk_agent_port }}" connect_timeout: 30 - register: checkmk_agent_server_port + register: checkmk_agent_port_state - - name: "Test Agent Service is listening on port 6556." + - name: "Test Agent Service is listening on port {{ checkmk_agent_port }}." ansible.builtin.assert: - that: "(checkmk_agent_server_port.port == 6556) and (checkmk_agent_server_port.state == 'started')" + that: "(checkmk_agent_port_state.port == checkmk_agent_port) and (checkmk_agent_port_state.state == 'started')" diff --git a/roles/agent/molecule/2.2.0/verify.yml b/roles/agent/molecule/2.2.0/verify.yml index 7ace07b48..e2f9cc8f4 100644 --- a/roles/agent/molecule/2.2.0/verify.yml +++ b/roles/agent/molecule/2.2.0/verify.yml @@ -22,10 +22,10 @@ - name: "Test that the Agent is listening on the default Port." ansible.builtin.wait_for: - port: 6556 + port: "{{ checkmk_agent_port }}" connect_timeout: 30 - register: checkmk_agent_server_port + register: checkmk_agent_port_state - - name: "Test Agent Service is listening on port 6556." + - name: "Test Agent Service is listening on port {{ checkmk_agent_port }}." ansible.builtin.assert: - that: "(checkmk_agent_server_port.port == 6556) and (checkmk_agent_server_port.state == 'started')" + that: "(checkmk_agent_port_state.port == checkmk_agent_port) and (checkmk_agent_port_state.state == 'started')" diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 364529148..7733ced57 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -107,5 +107,5 @@ - name: "{{ ansible_system }}: Verify Checkmk Agent Port is open." ansible.builtin.wait_for: - port: 6556 + port: "{{ checkmk_agent_port }}" timeout: 60 diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index c6a121e6f..3198ffb1f 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -46,7 +46,7 @@ permanent: 'yes' immediate: 'yes' state: enabled - rich_rule: 'rule family="ipv4" source address={{ checkmk_agent_server_ip }} port port="6556" protocol="tcp" accept' + rich_rule: 'rule family="ipv4" source address={{ checkmk_agent_server_ip }} port port="{{ checkmk_agent_port }}" protocol="tcp" accept' zone: "{{ checkmk_agent_configure_firewall_zone | default('public') }}" when: checkmk_agent_server_ip is defined become: true diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index d1eac5aef..1e76ddf60 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -82,5 +82,5 @@ - name: "{{ ansible_system }}: Verify Checkmk Agent Port is open." ansible.windows.win_wait_for: - port: 6556 + port: "{{ checkmk_agent_port }}" timeout: 60 From 2fe135f1752df30d8bd9cb677d9cc7ee0676923f Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 12 Sep 2023 11:40:50 +0200 Subject: [PATCH 07/25] Make agent port verification configurable. --- roles/agent/defaults/main.yml | 3 ++- roles/agent/tasks/Linux.yml | 1 + roles/agent/tasks/Win32NT.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index 3fbcda305..d01935b99 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -9,7 +9,7 @@ checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'true' checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ automation_user | default('automation') }}" -checkmk_agent_port: "6556" +checkmk_agent_port: 6556 # Depending on which user you will be using, set the password or secret: # checkmk_agent_pass: "{{ automation_secret }}" @@ -30,6 +30,7 @@ checkmk_agent_delegate_download: "{{ inventory_hostname }}" checkmk_agent_host_name: "{{ inventory_hostname }}" checkmk_agent_folder: "{{ checkmk_folder_path | default('/') }}" checkmk_agent_force_foreign_changes: 'false' +checkmk_agent_port_check: 'true' checkmk_agent_host_attributes: ipaddress: "{{ checkmk_agent_host_ip | default(omit) }}" diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 4ea7e178d..b47ee429b 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -124,3 +124,4 @@ ansible.builtin.wait_for: port: "{{ checkmk_agent_port }}" timeout: 60 + when: checkmk_agent_port_check | bool diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index 1e76ddf60..bfeaed91c 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -84,3 +84,4 @@ ansible.windows.win_wait_for: port: "{{ checkmk_agent_port }}" timeout: 60 + when: checkmk_agent_port_check | bool From 5e8a385c029f3f4efb8a8160f180950772d75553 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Tue, 12 Sep 2023 11:41:15 +0200 Subject: [PATCH 08/25] Update README and bugfix handler. --- roles/agent/README.md | 9 +++++++++ roles/agent/handlers/main.yml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/roles/agent/README.md b/roles/agent/README.md index 09b86d087..8d52b531a 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -75,6 +75,15 @@ This is mutually exclusive with `checkmk_agent_secret`. The secret for the automation user used to authenticate against your Checkmk site. This is mutually exclusive with `checkmk_agent_pass`. + checkmk_agent_port: 6556 + +Configure the port the agent listens on. We recommend to stick to the default. +**This does not change the agent configuration! It merely tells Ansible which port to talk to.** + + checkmk_agent_port_check: 'true' + +Verify, that the the `checkmk_agent_port` is actually open, before querying it. + checkmk_agent_auto_activate: 'false' Enable automatic activation of changes on all sites. diff --git a/roles/agent/handlers/main.yml b/roles/agent/handlers/main.yml index 0cd1f3246..3e37ff1ab 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 }}:{{ checkmk_agent_port }}/" + server_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_port }}/" site: "{{ checkmk_agent_site }}" automation_user: "{{ checkmk_agent_user }}" automation_secret: "{{ checkmk_agent_auth }}" From 2a08737e12e94762811bfc5f3b98c51dbc33bd7e Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 27 Oct 2023 10:09:38 +0200 Subject: [PATCH 09/25] Update variable style guide. --- CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1d54fc293..6fca1756b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,6 +89,10 @@ It is possible to implement an alias for a module option. This should be used ra The following are guidelines to keep in mind, when changing roles. - Variables - Use snake case (`snake_case_variable`) + - Name variables after their purpose. + - `checkmk_server_foo` for a server role variable + - `checkmk_agent_bar` for a agent role variable + - `checkmk_var_bat` for general variables - Do not prefix the variable with an underscore ( `_` ) - Tags - When tagging roles, separate single words with dashes (`my-custom-tag`) From 70d9f65fe8db34ed74b84d87d5cc851a2e1f2ddd Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 27 Oct 2023 10:32:02 +0200 Subject: [PATCH 10/25] Standardize variables for playbooks. --- playbooks/demo/downtimes.yml | 97 ++++++++++++------------ playbooks/demo/groups.yml | 104 +++++++++++++------------- playbooks/demo/hosts-and-folders.yml | 65 ++++++++-------- playbooks/demo/lookup.yml | 12 +-- playbooks/demo/rules.yml | 64 ++++++++-------- playbooks/demo/users-and-contacts.yml | 44 +++++------ playbooks/roles.yml | 8 +- playbooks/vars/auth.yml | 18 ++--- playbooks/vars/folders.yml | 2 +- playbooks/vars/groups.yml | 8 +- playbooks/vars/rules.yml | 2 +- playbooks/vars/users.yml | 2 +- 12 files changed, 212 insertions(+), 214 deletions(-) diff --git a/playbooks/demo/downtimes.yml b/playbooks/demo/downtimes.yml index e3b301b2b..4d1e4c380 100644 --- a/playbooks/demo/downtimes.yml +++ b/playbooks/demo/downtimes.yml @@ -9,25 +9,25 @@ tasks: - name: "Create folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" attributes: site: "{{ site }}" ipaddress: 127.0.0.1 @@ -36,10 +36,10 @@ - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" @@ -48,10 +48,10 @@ - name: "Downtime 1 - on services with relative timestamps" downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" comment: downtime 1 - on services with relative timestamps start_after: @@ -67,10 +67,10 @@ - name: "Downtime 2 - on services with absolute timestamps" downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" comment: downtime 2 - on services with absolute timestamps start_time: "2024-03-25T20:39:28Z" @@ -82,10 +82,10 @@ - name: "Downtime 3 - on services without timestamps" downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" comment: downtime 3 - on services without timestamps service_descriptions: @@ -97,10 +97,10 @@ - name: "Downtime 4 - on host with relative times" downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" comment: downtime 4 - on host with relative timestamps start_after: @@ -113,10 +113,10 @@ - name: "Downtime 5 - on host with absolute timestamps" downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" comment: downtime 5 - on host with absolute timestamps start_time: "2024-03-25T20:39:28Z" @@ -125,10 +125,10 @@ - name: "Downtime 6 - on host without timestamps" downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" comment: downtime 6 - on host without timestamps delegate_to: localhost @@ -138,14 +138,14 @@ prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Downtime delete 1 - service downtimes" downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" service_descriptions: - "Check_MK" @@ -155,10 +155,10 @@ - name: "Downtime delete 2 - host downtimes" downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" state: absent delegate_to: localhost @@ -168,39 +168,38 @@ prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Delete Hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" state: "absent" delegate_to: localhost - name: "Delete folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "absent" - register: testout delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" diff --git a/playbooks/demo/groups.yml b/playbooks/demo/groups.yml index 3493b28cf..a520dbb2b 100644 --- a/playbooks/demo/groups.yml +++ b/playbooks/demo/groups.yml @@ -17,10 +17,10 @@ - name: "Create host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" @@ -30,10 +30,10 @@ - name: "Create contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" @@ -43,10 +43,10 @@ - name: "Create tag groups." tag_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" id: "{{ item.id }}" title: "{{ item.title | default(item.id) }}" topic: "{{ item.topic }}" @@ -54,14 +54,14 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_tag_groups }}" + loop: "{{ checkmk_var_tag_groups }}" - name: "Create service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" @@ -71,10 +71,10 @@ - name: "Assign hosts to host groups." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "host_groups" rule: location: @@ -93,10 +93,10 @@ - name: "Assign hosts to contact groups." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "host_contactgroups" rule: location: @@ -115,10 +115,10 @@ - name: "Assign services to service groups." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "service_groups" rule: location: @@ -140,14 +140,14 @@ prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site - Showcase creation of groups." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" @@ -156,10 +156,10 @@ - name: "Unassign hosts to host groups." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "host_groups" rule: location: @@ -178,10 +178,10 @@ - name: "Unassign hosts to contact groups." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "host_contactgroups" rule: location: @@ -200,10 +200,10 @@ - name: "Unassign services to service groups." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "service_groups" rule: location: @@ -222,10 +222,10 @@ - name: "Delete service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -234,22 +234,22 @@ - name: "Delete tag groups." tag_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" id: "{{ item.id }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_tag_groups }}" + loop: "{{ checkmk_var_tag_groups }}" - name: "Delete contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -258,10 +258,10 @@ - name: "Delete host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -273,14 +273,14 @@ prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site - Showcase host and folders were deleted" activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" diff --git a/playbooks/demo/hosts-and-folders.yml b/playbooks/demo/hosts-and-folders.yml index 2e0c7f203..57292b08c 100644 --- a/playbooks/demo/hosts-and-folders.yml +++ b/playbooks/demo/hosts-and-folders.yml @@ -10,25 +10,25 @@ - name: "Create folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" attributes: site: "{{ site }}" ipaddress: 127.0.0.1 @@ -40,14 +40,14 @@ prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" @@ -56,12 +56,12 @@ - name: "Change host attributes." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" attributes: site: "{{ site }}" alias: "Important Server" @@ -71,10 +71,10 @@ - name: "Move host to another folder." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" folder: "/bar" state: "present" @@ -85,46 +85,45 @@ prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Delete Hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" state: "absent" delegate_to: localhost - name: "Delete folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "absent" - register: testout delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "Pause to review changes." ansible.builtin.pause: prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" diff --git a/playbooks/demo/lookup.yml b/playbooks/demo/lookup.yml index 96545907d..9b4e65257 100644 --- a/playbooks/demo/lookup.yml +++ b/playbooks/demo/lookup.yml @@ -10,9 +10,9 @@ - name: "Get Checkmk version." ansible.builtin.debug: - msg: "Version is {{ version }}" + msg: "Version is {{ checkmk_var_version }}" vars: - version: "{{ lookup('checkmk.general.version', + checkmk_var_version: "{{ lookup('checkmk.general.version', server_url + '/' + site, validate_certs=False, automation_user=automation_user, @@ -43,7 +43,7 @@ ansible.builtin.debug: msg: "Host found in {{ item.0.id }}: {{ item.1.title }}" vars: - looping: "{{ + checkmk_var_looping: "{{ lookup('checkmk.general.all_folders', '~tests', show_hosts=True, @@ -53,7 +53,7 @@ automation_secret=automation_secret, validate_certs=False) }}" - loop: "{{ looping | subelements('members.hosts.value') }}" + loop: "{{ checkmk_var_looping | subelements('members.hosts.value') }}" loop_control: label: "{{ item.0.id }}" delegate_to: localhost @@ -61,9 +61,9 @@ - name: "Get the attributes of folder /tests" ansible.builtin.debug: - msg: "Attributes of folder /network: {{ attributes }}" + msg: "Attributes of folder /network: {{ checkmk_var_attributes }}" vars: - attributes: "{{ + checkmk_var_attributes: "{{ lookup('checkmk.general.folder', '~tests', site_url=server_url + '/' + site, diff --git a/playbooks/demo/rules.yml b/playbooks/demo/rules.yml index 25ce1498c..09845b3a8 100644 --- a/playbooks/demo/rules.yml +++ b/playbooks/demo/rules.yml @@ -17,25 +17,25 @@ - name: "Create folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" attributes: site: "{{ site }}" ipaddress: 127.0.0.1 @@ -44,14 +44,14 @@ - name: "Create rules." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "{{ item.ruleset }}" rule: "{{ item.rule }}" state: "present" - loop: "{{ checkmk_rules }}" + loop: "{{ checkmk_var_rules }}" run_once: true # noqa run-once[task] delegate_to: localhost @@ -60,14 +60,14 @@ prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" @@ -76,54 +76,54 @@ - name: "Delete rules." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "{{ item.ruleset }}" rule: "{{ item.rule }}" state: "absent" - loop: "{{ checkmk_rules }}" + loop: "{{ checkmk_var_rules }}" run_once: true # noqa run-once[task] delegate_to: localhost - name: "Delete Hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" state: "absent" delegate_to: localhost - name: "Delete folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "Pause to review changes." ansible.builtin.pause: prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" diff --git a/playbooks/demo/users-and-contacts.yml b/playbooks/demo/users-and-contacts.yml index 298492d61..cc0cfaea6 100644 --- a/playbooks/demo/users-and-contacts.yml +++ b/playbooks/demo/users-and-contacts.yml @@ -11,10 +11,10 @@ - name: "Create contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" @@ -24,10 +24,10 @@ - name: "Create users." user: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" fullname: "{{ item.fullname }}" auth_type: "{{ item.auth_type }}" @@ -39,21 +39,21 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_users }}" + loop: "{{ checkmk_var_users }}" - name: "Pause to review changes." ansible.builtin.pause: prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" @@ -62,22 +62,22 @@ - name: "Delete users." user: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_users }}" + loop: "{{ checkmk_var_users }}" - name: "Delete contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -89,14 +89,14 @@ prompt: | "Feel free to review the changes in your Checkmk site: {{ site }}." "Press to continue." - when: not run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - "{{ site }}" diff --git a/playbooks/roles.yml b/playbooks/roles.yml index 6412ef51a..bff23ca67 100644 --- a/playbooks/roles.yml +++ b/playbooks/roles.yml @@ -11,17 +11,17 @@ - name: "Create folders." tags: [agent] checkmk.general.folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" validate_certs: "{{ checkmk_agent_server_validate_certs }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "Run server role." tags: [server] diff --git a/playbooks/vars/auth.yml b/playbooks/vars/auth.yml index b367c6804..234c1e907 100644 --- a/playbooks/vars/auth.yml +++ b/playbooks/vars/auth.yml @@ -1,15 +1,15 @@ --- # Provice the URL and credentials to your Checkmk site here # -server_url: "http://localhost/" -site: "my_site" -automation_user: "cmkadmin" -automation_secret: "cmk" -checkmk_agent_user: "{{ automation_user }}" -checkmk_agent_pass: "{{ automation_secret }}" +checkmk_var_server_url: "http://localhost/" +checkmk_var_site: "my_site" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_automation_secret: "cmk" +checkmk_agent_user: "{{ checkmk_var_automation_user }}" +checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" -checkmk_version: "2.2.0b4" -checkmk_edition: "cre" +checkmk_var_version: "2.2.0b4" +checkmk_var_edition: "cre" ############################################################# # Set to true, to skip the break points: -run_unattended: false +checkmk_var_run_unattended: false diff --git a/playbooks/vars/folders.yml b/playbooks/vars/folders.yml index c50153368..f31a3fe48 100644 --- a/playbooks/vars/folders.yml +++ b/playbooks/vars/folders.yml @@ -1,5 +1,5 @@ --- -checkmk_folders: +checkmk_var_folders: - path: /test name: Test - path: /foo/ diff --git a/playbooks/vars/groups.yml b/playbooks/vars/groups.yml index 9b99729df..d298b7dc1 100644 --- a/playbooks/vars/groups.yml +++ b/playbooks/vars/groups.yml @@ -1,6 +1,6 @@ --- # Contact Groups ############################################ -checkmk_contact_groups: +checkmk_var_contact_groups: - name: "contacts_linux" title: "Linux Admins" - name: "contacts_windows" @@ -12,7 +12,7 @@ checkmk_contact_groups: ############################################################# # Host Groups ############################################### -checkmk_host_groups: +checkmk_var_host_groups: - name: "hosts_linux" title: "Linux Hosts" - name: "hosts_windows" @@ -24,7 +24,7 @@ checkmk_host_groups: ############################################################# # Tag Groups ############################################### -checkmk_tag_groups: +checkmk_var_tag_groups: - id: "operating_system" title: "Operating System" topic: "Technical" @@ -58,7 +58,7 @@ checkmk_tag_groups: ############################################################# # Service Groups ############################################ -checkmk_service_groups: +checkmk_var_service_groups: - name: "services_updates" title: "Operating System Updates" - name: "services_filesystems" diff --git a/playbooks/vars/rules.yml b/playbooks/vars/rules.yml index 167cdff9b..0f596b25b 100644 --- a/playbooks/vars/rules.yml +++ b/playbooks/vars/rules.yml @@ -1,5 +1,5 @@ --- -checkmk_rules: +checkmk_var_rules: - name: "Filesystem - Magic Factor." ruleset: "checkgroup_parameters:filesystem" diff --git a/playbooks/vars/users.yml b/playbooks/vars/users.yml index 830718812..dd28a0c20 100644 --- a/playbooks/vars/users.yml +++ b/playbooks/vars/users.yml @@ -1,5 +1,5 @@ --- -checkmk_users: +checkmk_var_users: - name: user1 fullname: User Eins password: "123" From 3a674705fa87667a4d8d4a7427bdf1d1c0aa0867 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 27 Oct 2023 10:32:21 +0200 Subject: [PATCH 11/25] Standardize variables for roles. --- roles/agent/defaults/main.yml | 6 ++-- roles/agent/molecule/2.0.0/group_vars/all.yml | 34 +++++++++---------- roles/agent/molecule/2.1.0/group_vars/all.yml | 34 +++++++++---------- roles/agent/molecule/2.2.0/group_vars/all.yml | 34 +++++++++---------- roles/agent/tasks/Linux.yml | 4 +-- roles/agent/tasks/Windows.yml | 4 +-- roles/agent/tasks/main.yml | 8 ++--- .../server/molecule/2.0.0/group_vars/all.yml | 34 +++++++++---------- roles/server/molecule/2.0.0/verify.yml | 6 ++-- .../server/molecule/2.1.0/group_vars/all.yml | 34 +++++++++---------- roles/server/molecule/2.1.0/verify.yml | 6 ++-- .../server/molecule/2.2.0/group_vars/all.yml | 34 +++++++++---------- roles/server/molecule/2.2.0/verify.yml | 6 ++-- roles/server/tasks/main.yml | 4 +-- 14 files changed, 124 insertions(+), 124 deletions(-) diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index db68fc926..2a998ab89 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -11,8 +11,8 @@ checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% checkmk_agent_user: "{{ automation_user | default('automation') }}" # Depending on which user you will be using, set the password or secret: -# checkmk_agent_pass: "{{ automation_secret }}" -# checkmk_agent_secret: "{{ automation_secret }}" +# checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" +# checkmk_agent_secret: "{{ checkmk_var_automation_secret }}" checkmk_agent_auto_activate: 'false' checkmk_agent_add_host: 'false' @@ -27,7 +27,7 @@ checkmk_agent_prep_legacy: 'false' checkmk_agent_delegate_api_calls: localhost checkmk_agent_delegate_download: "{{ inventory_hostname }}" checkmk_agent_host_name: "{{ inventory_hostname }}" -checkmk_agent_folder: "{{ checkmk_folder_path | default('/') }}" +checkmk_agent_folder: "{{ checkmk_var_folder_path | default('/') }}" checkmk_agent_force_foreign_changes: 'false' checkmk_agent_host_attributes: ipaddress: "{{ checkmk_agent_host_ip | default(omit) }}" diff --git a/roles/agent/molecule/2.0.0/group_vars/all.yml b/roles/agent/molecule/2.0.0/group_vars/all.yml index 09d0afb90..df16bf575 100644 --- a/roles/agent/molecule/2.0.0/group_vars/all.yml +++ b/roles/agent/molecule/2.0.0/group_vars/all.yml @@ -1,26 +1,26 @@ --- # General -checkmk_version: "2.0.0p39" -checkmk_edition: "cre" -checkmk_site: "my_site" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.0.0p39" +checkmk_var_edition: "cre" +checkmk_var_checkmk_site: "my_site" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_automation_secret: "d7589df1" # Agent Role -checkmk_agent_version: "{{ checkmk_version }}" -checkmk_agent_edition: "{{ checkmk_edition }}" +checkmk_agent_version: "{{ checkmk_var_version }}" +checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_protocol: http checkmk_agent_server: 127.0.0.1 -checkmk_agent_site: "{{ checkmk_site }}" +checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% endif %}" -checkmk_agent_user: "{{ automation_user | default('automation') }}" +checkmk_agent_user: "{{ checkmk_var_automation_user | default('automation') }}" # Depending on which user you will be using, set the password or secret: -checkmk_agent_pass: "{{ automation_secret }}" -# checkmk_agent_secret: "{{ automation_secret }}" +checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" +# checkmk_agent_secret: "{{ checkmk_var_automation_secret }}" checkmk_agent_auto_activate: 'true' checkmk_agent_add_host: 'true' @@ -34,7 +34,7 @@ checkmk_agent_prep_legacy: 'false' checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}" checkmk_agent_delegate_download: "{{ inventory_hostname }}" checkmk_agent_host_name: "{{ inventory_hostname }}" -checkmk_agent_folder: "{{ checkmk_folder_path | default('/') }}" +checkmk_agent_folder: "{{ checkmk_var_folder_path | default('/') }}" checkmk_agent_force_foreign_changes: 'false' checkmk_agent_host_attributes: ipaddress: 127.0.0.1 @@ -49,13 +49,13 @@ checkmk_agent_host_attributes: # Server Role -checkmk_server_edition: "{{ checkmk_edition }}" -checkmk_server_version: "{{ checkmk_version }}" +checkmk_server_edition: "{{ checkmk_var_edition }}" +checkmk_server_version: "{{ checkmk_var_version }}" checkmk_server_verify_setup: 'true' checkmk_server_sites: - - name: "{{ checkmk_site }}" - version: "{{ checkmk_version }}" + - name: "{{ checkmk_var_checkmk_site }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install 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 9b062e4e9..206f4d5fa 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -1,26 +1,26 @@ --- # General -checkmk_version: "2.1.0p35" -checkmk_edition: "cre" -checkmk_site: "my_site" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.1.0p35" +checkmk_var_edition: "cre" +checkmk_var_checkmk_site: "my_site" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_automation_secret: "d7589df1" # Agent Role -checkmk_agent_version: "{{ checkmk_version }}" -checkmk_agent_edition: "{{ checkmk_edition }}" +checkmk_agent_version: "{{ checkmk_var_version }}" +checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_protocol: http checkmk_agent_server: 127.0.0.1 -checkmk_agent_site: "{{ checkmk_site }}" +checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% endif %}" -checkmk_agent_user: "{{ automation_user | default('automation') }}" +checkmk_agent_user: "{{ checkmk_var_automation_user | default('automation') }}" # Depending on which user you will be using, set the password or secret: -checkmk_agent_pass: "{{ automation_secret }}" -# checkmk_agent_secret: "{{ automation_secret }}" +checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" +# checkmk_agent_secret: "{{ checkmk_var_automation_secret }}" checkmk_agent_auto_activate: 'true' checkmk_agent_add_host: 'true' @@ -34,7 +34,7 @@ checkmk_agent_prep_legacy: 'false' checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}" checkmk_agent_delegate_download: "{{ inventory_hostname }}" checkmk_agent_host_name: "{{ inventory_hostname }}" -checkmk_agent_folder: "{{ checkmk_folder_path | default('/') }}" +checkmk_agent_folder: "{{ checkmk_var_folder_path | default('/') }}" checkmk_agent_force_foreign_changes: 'false' checkmk_agent_host_attributes: ipaddress: 127.0.0.1 @@ -49,13 +49,13 @@ checkmk_agent_host_attributes: # Server Role -checkmk_server_edition: "{{ checkmk_edition }}" -checkmk_server_version: "{{ checkmk_version }}" +checkmk_server_edition: "{{ checkmk_var_edition }}" +checkmk_server_version: "{{ checkmk_var_version }}" checkmk_server_verify_setup: 'true' checkmk_server_sites: - - name: "{{ checkmk_site }}" - version: "{{ checkmk_version }}" + - name: "{{ checkmk_var_checkmk_site }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install 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 59c18e677..7fd403a37 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -1,26 +1,26 @@ --- # General -checkmk_version: "2.2.0p12" -checkmk_edition: "cre" -checkmk_site: "my_site" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.2.0p12" +checkmk_var_edition: "cre" +checkmk_var_checkmk_site: "my_site" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_automation_secret: "d7589df1" # Agent Role -checkmk_agent_version: "{{ checkmk_version }}" -checkmk_agent_edition: "{{ checkmk_edition }}" +checkmk_agent_version: "{{ checkmk_var_version }}" +checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_protocol: http checkmk_agent_server: 127.0.0.1 -checkmk_agent_site: "{{ checkmk_site }}" +checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' checkmk_agent_port: "{% if checkmk_agent_protocol == 'https' %}443{% else %}80{% endif %}" -checkmk_agent_user: "{{ automation_user | default('automation') }}" +checkmk_agent_user: "{{ checkmk_var_automation_user | default('automation') }}" # Depending on which user you will be using, set the password or secret: -checkmk_agent_pass: "{{ automation_secret }}" -# checkmk_agent_secret: "{{ automation_secret }}" +checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" +# checkmk_agent_secret: "{{ checkmk_var_automation_secret }}" checkmk_agent_auto_activate: 'true' checkmk_agent_add_host: 'true' @@ -34,7 +34,7 @@ checkmk_agent_prep_legacy: 'false' checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}" checkmk_agent_delegate_download: "{{ inventory_hostname }}" checkmk_agent_host_name: "{{ inventory_hostname }}" -checkmk_agent_folder: "{{ checkmk_folder_path | default('/') }}" +checkmk_agent_folder: "{{ checkmk_var_folder_path | default('/') }}" checkmk_agent_force_foreign_changes: 'false' checkmk_agent_host_attributes: ipaddress: 127.0.0.1 @@ -49,13 +49,13 @@ checkmk_agent_host_attributes: # Server Role -checkmk_server_edition: "{{ checkmk_edition }}" -checkmk_server_version: "{{ checkmk_version }}" +checkmk_server_edition: "{{ checkmk_var_edition }}" +checkmk_server_version: "{{ checkmk_var_version }}" checkmk_server_verify_setup: 'true' checkmk_server_sites: - - name: "{{ checkmk_site }}" - version: "{{ checkmk_version }}" + - name: "{{ checkmk_var_checkmk_site }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 5ceff1a26..004e7c071 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -21,10 +21,10 @@ dest: "{{ checkmk_agent_agent.file.cre }}" mode: '0640' when: checkmk_agent_edition | lower == "cre" - register: result + register: checkmk_agent_download_state retries: 3 delay: 10 - until: "not result.failed | bool" + until: "not checkmk_agent_download_state.failed | bool" delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 23f1c03d2..a1917056e 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -5,10 +5,10 @@ validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" dest: "{{ checkmk_agent_agent.file.cre }}" when: checkmk_agent_edition | lower == "cre" - register: result + register: checkmk_agent_download_state retries: 3 delay: 10 - until: "not result.failed | bool" + until: "not checkmk_agent_download_state.failed | bool" tags: - download-package diff --git a/roles/agent/tasks/main.yml b/roles/agent/tasks/main.yml index bd414bc8f..2b2c23b33 100644 --- a/roles/agent/tasks/main.yml +++ b/roles/agent/tasks/main.yml @@ -27,10 +27,10 @@ throttle: "{{ checkmk_agent_discover_max_parallel_tasks }}" delegate_to: "{{ checkmk_agent_delegate_api_calls }}" when: checkmk_agent_discover | bool - register: result + register: checkmk_agent_refresh_state retries: 3 delay: 10 - until: "result.changed | bool" + until: "checkmk_agent_refresh_state.changed | bool" - name: "Update monitored services and labels on host." become: false @@ -45,8 +45,8 @@ throttle: "{{ checkmk_agent_discover_max_parallel_tasks }}" delegate_to: "{{ checkmk_agent_delegate_api_calls }}" when: checkmk_agent_discover | bool - register: result + register: checkmk_agent_discovery_state retries: 3 delay: 10 - until: "result.changed | bool" + until: "checkmk_agent_discovery_state.changed | bool" notify: "activate changes" diff --git a/roles/server/molecule/2.0.0/group_vars/all.yml b/roles/server/molecule/2.0.0/group_vars/all.yml index 47f40f20f..13311b74f 100644 --- a/roles/server/molecule/2.0.0/group_vars/all.yml +++ b/roles/server/molecule/2.0.0/group_vars/all.yml @@ -1,15 +1,15 @@ --- # General -checkmk_version: "2.0.0p39" -checkmk_edition: "cre" -checkmk_site: "my_site" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.0.0p39" +checkmk_var_edition: "cre" +checkmk_var_checkmk_site: "my_site" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_automation_secret: "d7589df1" # Server Role -checkmk_server_edition: "{{ checkmk_edition }}" -checkmk_server_version: "{{ checkmk_version }}" +checkmk_server_edition: "{{ checkmk_var_edition }}" +checkmk_server_version: "{{ checkmk_var_version }}" checkmk_server_verify_setup: 'true' checkmk_server_configure_firewall: 'false' @@ -20,23 +20,23 @@ checkmk_server_backup_opts: '--no-past' checkmk_server_allow_downgrades: 'true' checkmk_server_sites: - - name: "{{ checkmk_site }}" - version: "{{ checkmk_version }}" + - name: "{{ checkmk_var_checkmk_site }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "stopped" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: stopped - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "present" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: present - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "absent" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: absent - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install diff --git a/roles/server/molecule/2.0.0/verify.yml b/roles/server/molecule/2.0.0/verify.yml index 6ced2f10a..74091c802 100644 --- a/roles/server/molecule/2.0.0/verify.yml +++ b/roles/server/molecule/2.0.0/verify.yml @@ -24,10 +24,10 @@ - name: "Test if we can talk to the REST API by activating changes." checkmk.general.activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ checkmk_site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true register: checkmk_server_api_state diff --git a/roles/server/molecule/2.1.0/group_vars/all.yml b/roles/server/molecule/2.1.0/group_vars/all.yml index 9c9a08914..15aca8c73 100644 --- a/roles/server/molecule/2.1.0/group_vars/all.yml +++ b/roles/server/molecule/2.1.0/group_vars/all.yml @@ -1,15 +1,15 @@ --- # General -checkmk_version: "2.1.0p35" -checkmk_edition: "cre" -checkmk_site: "my_site" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.1.0p35" +checkmk_var_edition: "cre" +checkmk_var_checkmk_site: "my_site" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_automation_secret: "d7589df1" # Server Role -checkmk_server_edition: "{{ checkmk_edition }}" -checkmk_server_version: "{{ checkmk_version }}" +checkmk_server_edition: "{{ checkmk_var_edition }}" +checkmk_server_version: "{{ checkmk_var_version }}" checkmk_server_verify_setup: 'true' checkmk_server_configure_firewall: 'false' @@ -20,23 +20,23 @@ checkmk_server_backup_opts: '--no-past' checkmk_server_allow_downgrades: 'true' checkmk_server_sites: - - name: "{{ checkmk_site }}" - version: "{{ checkmk_version }}" + - name: "{{ checkmk_var_checkmk_site }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "stopped" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: stopped - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "present" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: present - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "absent" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: absent - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install diff --git a/roles/server/molecule/2.1.0/verify.yml b/roles/server/molecule/2.1.0/verify.yml index 6ced2f10a..74091c802 100644 --- a/roles/server/molecule/2.1.0/verify.yml +++ b/roles/server/molecule/2.1.0/verify.yml @@ -24,10 +24,10 @@ - name: "Test if we can talk to the REST API by activating changes." checkmk.general.activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ checkmk_site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true register: checkmk_server_api_state 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 587a9c3aa..2ecfda19d 100644 --- a/roles/server/molecule/2.2.0/group_vars/all.yml +++ b/roles/server/molecule/2.2.0/group_vars/all.yml @@ -1,15 +1,15 @@ --- # General -checkmk_version: "2.2.0p12" -checkmk_edition: "cre" -checkmk_site: "my_site" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.2.0p12" +checkmk_var_edition: "cre" +checkmk_var_checkmk_site: "my_site" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_automation_secret: "d7589df1" # Server Role -checkmk_server_edition: "{{ checkmk_edition }}" -checkmk_server_version: "{{ checkmk_version }}" +checkmk_server_edition: "{{ checkmk_var_edition }}" +checkmk_server_version: "{{ checkmk_var_version }}" checkmk_server_verify_setup: 'true' checkmk_server_configure_firewall: 'false' @@ -20,23 +20,23 @@ checkmk_server_backup_opts: '--no-past' checkmk_server_allow_downgrades: 'true' checkmk_server_sites: - - name: "{{ checkmk_site }}" - version: "{{ checkmk_version }}" + - name: "{{ checkmk_var_checkmk_site }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "stopped" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: stopped - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "present" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: present - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "absent" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: absent - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install diff --git a/roles/server/molecule/2.2.0/verify.yml b/roles/server/molecule/2.2.0/verify.yml index 6ced2f10a..74091c802 100644 --- a/roles/server/molecule/2.2.0/verify.yml +++ b/roles/server/molecule/2.2.0/verify.yml @@ -24,10 +24,10 @@ - name: "Test if we can talk to the REST API by activating changes." checkmk.general.activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ checkmk_site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true register: checkmk_server_api_state diff --git a/roles/server/tasks/main.yml b/roles/server/tasks/main.yml index 757a09e1e..ee6c01d10 100644 --- a/roles/server/tasks/main.yml +++ b/roles/server/tasks/main.yml @@ -60,9 +60,9 @@ block: - name: "Import Checkmk GPG Key." ansible.builtin.command: "gpg --import /tmp/Check_MK-pubkey.gpg" - register: checkmk_gpg_import + register: checkmk_server_gpg_import when: checkmk_server_verify_setup | bool - changed_when: "'imported: 1' in checkmk_gpg_import" + changed_when: "'imported: 1' in checkmk_server_gpg_import" tags: - import-gpg-key From 210f16a979e82b9ca9ab648bea7e90d2812096f2 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 27 Oct 2023 10:32:47 +0200 Subject: [PATCH 12/25] Standardize variables for tests. --- .../targets/activation/tasks/test.yml | 48 +++--- .../integration/targets/bakery/tasks/test.yml | 42 +++--- .../integration/targets/bakery/vars/main.yml | 2 +- .../targets/contact_group/tasks/test.yml | 96 ++++++------ .../targets/discovery/tasks/test.yml | 120 +++++++-------- .../targets/downtime/tasks/test.yml | 138 +++++++++--------- .../integration/targets/folder/tasks/test.yml | 78 +++++----- .../integration/targets/folder/vars/main.yml | 2 +- tests/integration/targets/host/tasks/test.yml | 76 +++++----- tests/integration/targets/host/vars/main.yml | 2 +- .../targets/host_group/tasks/test.yml | 96 ++++++------ .../targets/lookup_folder/tasks/test.yml | 6 +- .../targets/lookup_folders/tasks/test.yml | 10 +- .../targets/lookup_folders/vars/main.yml | 2 +- .../targets/lookup_host/tasks/test.yml | 6 +- .../targets/lookup_hosts/tasks/test.yml | 6 +- .../targets/password/tasks/test.yml | 36 ++--- tests/integration/targets/rule/tasks/test.yml | 44 +++--- tests/integration/targets/rule/vars/main.yml | 2 +- .../targets/service_group/tasks/test.yml | 96 ++++++------ .../targets/tag_group/tasks/test.yml | 36 ++--- .../targets/timeperiod/tasks/test.yml | 54 +++---- tests/integration/targets/user/tasks/test.yml | 84 +++++------ tests/integration/targets/user/vars/main.yml | 2 +- 24 files changed, 542 insertions(+), 542 deletions(-) diff --git a/tests/integration/targets/activation/tasks/test.yml b/tests/integration/targets/activation/tasks/test.yml index 2b394fbfa..f3952d628 100644 --- a/tests/integration/targets/activation/tasks/test.yml +++ b/tests/integration/targets/activation/tasks/test.yml @@ -1,19 +1,19 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate without changes." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" attributes: @@ -26,19 +26,19 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate without explicit site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" state: "absent" @@ -48,20 +48,20 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate forcing foreign changes." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" attributes: @@ -74,10 +74,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate with explicit site." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'false' sites: - "{{ outer_item.site }}" @@ -86,10 +86,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" state: "absent" diff --git a/tests/integration/targets/bakery/tasks/test.yml b/tests/integration/targets/bakery/tasks/test.yml index d64c88876..61c2506de 100644 --- a/tests/integration/targets/bakery/tasks/test.yml +++ b/tests/integration/targets/bakery/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" attributes: @@ -17,10 +17,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -29,20 +29,20 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bake all agents." bakery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" state: "baked" delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Sign all agents." bakery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" signature_key_id: "{{ signature_key_id }}" signature_key_passphrase: "{{ signature_key_passphrase }}" state: "signed" @@ -51,10 +51,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bake and Sign all agents." bakery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" signature_key_id: "{{ signature_key_id }}" signature_key_passphrase: "{{ signature_key_passphrase }}" state: "baked_signed" @@ -63,10 +63,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" state: "absent" @@ -76,10 +76,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" sites: - "{{ outer_item.site }}" delegate_to: localhost diff --git a/tests/integration/targets/bakery/vars/main.yml b/tests/integration/targets/bakery/vars/main.yml index 85802d237..e60cc639f 100644 --- a/tests/integration/targets/bakery/vars/main.yml +++ b/tests/integration/targets/bakery/vars/main.yml @@ -24,7 +24,7 @@ checkmk_server_edition_mapping: cme: managed signature_key_id: 1 -signature_key_passphrase: "{{ automation_secret }}" +signature_key_passphrase: "{{ checkmk_var_automation_secret }}" checkmk_hosts: - name: test1.tld diff --git a/tests/integration/targets/contact_group/tasks/test.yml b/tests/integration/targets/contact_group/tasks/test.yml index 8fb30531e..aeda79cba 100644 --- a/tests/integration/targets/contact_group/tasks/test.yml +++ b/tests/integration/targets/contact_group/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" @@ -14,10 +14,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'groups', Create contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" groups: checkmk_contact_groups_create @@ -29,10 +29,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -41,10 +41,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify part of contact groups (also checks for idempotency!)." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name | default(item.name) }}" title: "{{ item.title }}" state: "present" @@ -54,10 +54,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -66,10 +66,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -78,10 +78,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -90,10 +90,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete contact groups that were created at the beginning (also check for idempotency)." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -102,10 +102,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -114,10 +114,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk create contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_contact_groups_create }}" state: "present" delegate_to: localhost @@ -125,10 +125,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'name', Bulk create contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_contact_groups_create }}" name: "test" state: "present" @@ -138,10 +138,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'title', Bulk create contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_contact_groups_create }}" title: "Test" state: "present" @@ -151,10 +151,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk modify part of contact groups (also checks for idempotency!)." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_contact_groups_modify }}" state: "present" delegate_to: localhost @@ -162,10 +162,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk delete contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_contact_groups_delete }}" state: "absent" delegate_to: localhost @@ -173,10 +173,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk delete contact groups that were created at the beginning (also check for idempotency)." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_contact_groups_create }}" state: "absent" delegate_to: localhost @@ -184,10 +184,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" diff --git a/tests/integration/targets/discovery/tasks/test.yml b/tests/integration/targets/discovery/tasks/test.yml index a85f8827d..7717fff66 100644 --- a/tests/integration/targets/discovery/tasks/test.yml +++ b/tests/integration/targets/discovery/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" attributes: @@ -19,10 +19,10 @@ block: - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Rescan services." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: "refresh" delegate_to: localhost @@ -31,10 +31,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update host labels." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: "only_host_labels" delegate_to: localhost @@ -43,10 +43,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Remove vanished services." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: "remove" delegate_to: localhost @@ -55,10 +55,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Add undecided services." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: "new" delegate_to: localhost @@ -67,10 +67,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Tabula Rasa. (New since 2.2)" discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: "tabula_rasa" delegate_to: localhost @@ -80,10 +80,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Discover hosts (fix_all)." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: "fix_all" delegate_to: localhost @@ -92,10 +92,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -104,10 +104,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" state: "absent" @@ -117,10 +117,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" sites: - "{{ outer_item.site }}" delegate_to: localhost @@ -131,10 +131,10 @@ block: - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" attributes: @@ -147,10 +147,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Rescan services." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" hosts: "{{ checkmk_host_names }}" state: "refresh" bulk_size: 5 @@ -158,10 +158,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Update host labels." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" hosts: "{{ checkmk_host_names }}" state: "only_host_labels" bulk_size: 5 @@ -169,10 +169,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Remove vanished services." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" hosts: "{{ checkmk_host_names }}" state: "remove" bulk_size: 5 @@ -180,10 +180,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Add undecided services to monitoring." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" hosts: "{{ checkmk_host_names }}" state: "new" bulk_size: 5 @@ -191,10 +191,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Tabula Rasa. (Only 2.2)." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" hosts: "{{ checkmk_host_names }}" state: "tabula_rasa" bulk_size: 5 @@ -203,10 +203,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Discover hosts (fix_all)." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" hosts: "{{ checkmk_host_names }}" state: "fix_all" bulk_size: 5 @@ -214,10 +214,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -226,10 +226,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" state: "absent" @@ -239,10 +239,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" sites: - "{{ outer_item.site }}" delegate_to: localhost diff --git a/tests/integration/targets/downtime/tasks/test.yml b/tests/integration/targets/downtime/tasks/test.yml index ff79e689e..cebd3d240 100644 --- a/tests/integration/targets/downtime/tasks/test.yml +++ b/tests/integration/targets/downtime/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" attributes: @@ -17,10 +17,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Discover hosts." discovery: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: "fix_all" delegate_to: localhost @@ -29,20 +29,20 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Run activation." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host without comment." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" start_time: 2024-03-25T20:39:28Z end_time: 2024-03-26T20:39:28Z @@ -51,10 +51,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete downtime on host without comment." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" start_time: 2024-03-25T20:39:28Z end_time: 2024-03-26T20:39:28Z @@ -63,10 +63,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on services with relative times." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on services with relative timestamps start_after: @@ -82,10 +82,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on services with relative times in strings." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on services with relative timestamps in strings start_after: @@ -101,10 +101,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on services with absolute timestamps." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on services with absolute timestamps start_time: 2024-03-25T20:39:28Z @@ -116,10 +116,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on services without timestamps." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on services without timestamps service_descriptions: @@ -131,10 +131,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host with relative times." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on host with relative timestamps start_after: @@ -147,10 +147,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host with absolute timestamps." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on host with absolute timestamps start_time: 2024-03-25T20:39:28Z @@ -159,10 +159,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host with absolute timestamps. Again." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on host with absolute timestamps start_time: 2024-03-25T20:39:28Z @@ -171,10 +171,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host with absolute timestamps. Again. With force." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" force: "yes" comment: Schedule downtime on host with absolute timestamps @@ -184,10 +184,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime forcibly on host with absolute timestamps." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on host with absolute timestamps start_time: 2024-03-25T20:39:28Z @@ -197,20 +197,20 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host without timestamps." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on host without timestamps loop: "{{ checkmk_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete service downtimes with comment." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on services with relative timestamps service_descriptions: @@ -221,10 +221,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete host downtimes with comment." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on host without timestamps state: absent @@ -232,10 +232,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete service downtimes with comment again." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on services with relative timestamps service_descriptions: @@ -246,10 +246,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete host downtimes with comment again." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on host without timestamps state: absent @@ -257,10 +257,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete service downtimes." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" service_descriptions: - "CPU load" @@ -272,20 +272,20 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete host downtimes." downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: absent loop: "{{ checkmk_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" state: "absent" @@ -295,10 +295,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Run activation." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/folder/tasks/test.yml b/tests/integration/targets/folder/tasks/test.yml index 3063a77a2..65eb9016f 100644 --- a/tests/integration/targets/folder/tasks/test.yml +++ b/tests/integration/targets/folder/tasks/test.yml @@ -4,23 +4,23 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -29,23 +29,23 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -54,10 +54,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folders for attributes test." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ checkmk_folder_attr_test.path }}" name: "{{ checkmk_folder_attr_test.name }}" attributes: "{{ checkmk_folder_attr_test.attributes }}" @@ -67,10 +67,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update folder attributes without specifying title (name)." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ checkmk_folder_attr_test.path }}" state: "present" update_attributes: @@ -81,10 +81,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check the idempotency of Update attributes." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ checkmk_folder_attr_test.path }}" update_attributes: tag_criticality: "test" @@ -96,10 +96,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update folder title (name)." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ checkmk_folder_attr_test.path }}" name: "{{ checkmk_folder_attr_test.name }} Modified" state: "present" @@ -108,10 +108,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Remove folder attributes without specifying title (name)." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ checkmk_folder_attr_test.path }}" state: "present" remove_attributes: @@ -121,10 +121,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check the idempotency of Remove attributes." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ checkmk_folder_attr_test.path }}" remove_attributes: - "tag_networking" @@ -136,23 +136,23 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" diff --git a/tests/integration/targets/folder/vars/main.yml b/tests/integration/targets/folder/vars/main.yml index eaffd2154..c94a7fc72 100644 --- a/tests/integration/targets/folder/vars/main.yml +++ b/tests/integration/targets/folder/vars/main.yml @@ -29,7 +29,7 @@ checkmk_server_edition_mapping: cce: cloud cme: managed -checkmk_folders: +checkmk_var_folders: - path: /test name: Test - path: /foo diff --git a/tests/integration/targets/host/tasks/test.yml b/tests/integration/targets/host/tasks/test.yml index 08d2937b3..89a904157 100644 --- a/tests/integration/targets/host/tasks/test.yml +++ b/tests/integration/targets/host/tasks/test.yml @@ -1,23 +1,23 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" attributes: @@ -30,10 +30,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -42,10 +42,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" state: "absent" @@ -55,10 +55,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -67,10 +67,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create host with update_attributes without folder." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" update_attributes: site: "{{ outer_item.site }}" @@ -85,10 +85,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check idempotency on update_attributes for only a subset of attributes." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" update_attributes: labels: @@ -101,10 +101,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Remove Attributes of host." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" remove_attributes: - alias @@ -115,10 +115,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check idempotency on remove_attributes." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" remove_attributes: - alias @@ -129,10 +129,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" state: "absent" @@ -142,23 +142,23 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete folders." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" diff --git a/tests/integration/targets/host/vars/main.yml b/tests/integration/targets/host/vars/main.yml index 5099289c3..fef6639e5 100644 --- a/tests/integration/targets/host/vars/main.yml +++ b/tests/integration/targets/host/vars/main.yml @@ -29,7 +29,7 @@ checkmk_server_edition_mapping: cce: cloud cme: managed -checkmk_folders: +checkmk_var_folders: - path: /foo name: Foo - path: /bar diff --git a/tests/integration/targets/host_group/tasks/test.yml b/tests/integration/targets/host_group/tasks/test.yml index 32b30e077..4d241c061 100644 --- a/tests/integration/targets/host_group/tasks/test.yml +++ b/tests/integration/targets/host_group/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" @@ -14,10 +14,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'groups', Create host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" groups: checkmk_host_groups_create @@ -29,10 +29,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -41,10 +41,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify part of host groups (also checks for idempotency!)." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name | default(item.name) }}" title: "{{ item.title }}" state: "present" @@ -54,10 +54,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -66,10 +66,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -78,10 +78,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -90,10 +90,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete host groups that were created at the beginning (also check for idempotency)." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -102,10 +102,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -114,10 +114,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk create host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_host_groups_create }}" state: "present" delegate_to: localhost @@ -125,10 +125,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'name', Bulk create host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_host_groups_create }}" name: "test" state: "present" @@ -138,10 +138,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'title', Bulk create host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_host_groups_create }}" title: "Test" state: "present" @@ -151,10 +151,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk modify part of host groups (also checks for idempotency!)." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_host_groups_modify }}" state: "present" delegate_to: localhost @@ -162,10 +162,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk delete host groups." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_host_groups_delete }}" state: "absent" delegate_to: localhost @@ -173,10 +173,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk delete host groups that were created at the beginning (also check for idempotency)." host_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_host_groups_create }}" state: "absent" delegate_to: localhost @@ -184,10 +184,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" diff --git a/tests/integration/targets/lookup_folder/tasks/test.yml b/tests/integration/targets/lookup_folder/tasks/test.yml index aaa73df55..73392e3c6 100644 --- a/tests/integration/targets/lookup_folder/tasks/test.yml +++ b/tests/integration/targets/lookup_folder/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folder." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ checkmk_folder.name }}" path: "{{ checkmk_folder.path }}" attributes: diff --git a/tests/integration/targets/lookup_folders/tasks/test.yml b/tests/integration/targets/lookup_folders/tasks/test.yml index e0f195fd7..4a89a11af 100644 --- a/tests/integration/targets/lookup_folders/tasks/test.yml +++ b/tests/integration/targets/lookup_folders/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folder." folder: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" path: "{{ item.path }}" update_attributes: @@ -12,7 +12,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_folders }}" + loop: "{{ checkmk_var_folders }}" - name: "Get all folders." ansible.builtin.debug: @@ -50,7 +50,7 @@ - name: "Verify number of folders." ansible.builtin.assert: # The looked up list contains the main folder, as well. - that: "( 1 + checkmk_folders|length ) == folders|length" + that: "( 1 + checkmk_var_folders|length ) == folders|length" vars: folders: "{{ lookup('checkmk.general.folders', '/', diff --git a/tests/integration/targets/lookup_folders/vars/main.yml b/tests/integration/targets/lookup_folders/vars/main.yml index c439f6940..74b6f5977 100644 --- a/tests/integration/targets/lookup_folders/vars/main.yml +++ b/tests/integration/targets/lookup_folders/vars/main.yml @@ -29,7 +29,7 @@ checkmk_server_edition_mapping: cce: cloud cme: managed -checkmk_folders: +checkmk_var_folders: - name: "Folder 1" path: "/folder1" criticality: "test" diff --git a/tests/integration/targets/lookup_host/tasks/test.yml b/tests/integration/targets/lookup_host/tasks/test.yml index 743e4868d..18f0ec807 100644 --- a/tests/integration/targets/lookup_host/tasks/test.yml +++ b/tests/integration/targets/lookup_host/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create host." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ checkmk_host.name }}" folder: "{{ checkmk_host.folder }}" attributes: diff --git a/tests/integration/targets/lookup_hosts/tasks/test.yml b/tests/integration/targets/lookup_hosts/tasks/test.yml index 5b479916b..e96c52e7a 100644 --- a/tests/integration/targets/lookup_hosts/tasks/test.yml +++ b/tests/integration/targets/lookup_hosts/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create host." host: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" folder: "{{ item.folder }}" attributes: diff --git a/tests/integration/targets/password/tasks/test.yml b/tests/integration/targets/password/tasks/test.yml index 49eede5d2..9ef2d8e60 100644 --- a/tests/integration/targets/password/tasks/test.yml +++ b/tests/integration/targets/password/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create new passwords." password: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title }}" comment: "{{ item.comment }}" @@ -19,10 +19,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -31,10 +31,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update passwords." password: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(omit) }}" comment: "{{ item.comment | default(omit) }}" @@ -49,10 +49,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -61,10 +61,10 @@ - name: "Delete a password." password: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -72,10 +72,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index 70d7d62fd..b2f13c23c 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -1,23 +1,23 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create rules." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "{{ item.ruleset }}" rule: "{{ item.rule }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_rules }}" + loop: "{{ checkmk_var_rules }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -26,17 +26,17 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create rules." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "{{ item.ruleset }}" rule: "{{ item.rule }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] register: rule_result - loop: "{{ checkmk_rules }}" + loop: "{{ checkmk_var_rules }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler ansible.builtin.fail: @@ -47,23 +47,23 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete rules." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "{{ item.ruleset }}" rule: "{{ item.rule }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_rules }}" + loop: "{{ checkmk_var_rules }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -72,17 +72,17 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete rules." rule: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "{{ item.ruleset }}" rule: "{{ item.rule }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] register: rule_result - loop: "{{ checkmk_rules }}" + loop: "{{ checkmk_var_rules }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler ansible.builtin.fail: diff --git a/tests/integration/targets/rule/vars/main.yml b/tests/integration/targets/rule/vars/main.yml index 7f49c8199..d0cb20365 100644 --- a/tests/integration/targets/rule/vars/main.yml +++ b/tests/integration/targets/rule/vars/main.yml @@ -26,7 +26,7 @@ checkmk_server_edition_mapping: cce: cloud cme: managed -checkmk_rules: +checkmk_var_rules: - name: "Filesystem - Magic Factor." ruleset: "checkgroup_parameters:filesystem" diff --git a/tests/integration/targets/service_group/tasks/test.yml b/tests/integration/targets/service_group/tasks/test.yml index 44c4a3e53..c9b79bcd2 100644 --- a/tests/integration/targets/service_group/tasks/test.yml +++ b/tests/integration/targets/service_group/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" @@ -14,10 +14,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'groups', Create service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" groups: checkmk_service_groups_create @@ -29,10 +29,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -41,10 +41,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify part of service groups (also checks for idempotency!)." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name | default(item.name) }}" title: "{{ item.title }}" state: "present" @@ -54,10 +54,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -66,10 +66,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -78,10 +78,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -90,10 +90,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete service groups that were created at the beginning (also check for idempotency)." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -102,10 +102,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -114,10 +114,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk create service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_service_groups_create }}" state: "present" delegate_to: localhost @@ -125,10 +125,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'name', Bulk create service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_service_groups_create }}" name: "test" state: "present" @@ -138,10 +138,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Should fail because of 'title', Bulk create service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_service_groups_create }}" title: "Test" state: "present" @@ -151,10 +151,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk modify part of service groups (also checks for idempotency!)." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_service_groups_modify }}" state: "present" delegate_to: localhost @@ -162,10 +162,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk delete service groups." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_service_groups_delete }}" state: "absent" delegate_to: localhost @@ -173,10 +173,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk delete service groups that were created at the beginning (also check for idempotency)." service_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" groups: "{{ checkmk_service_groups_create }}" state: "absent" delegate_to: localhost @@ -184,10 +184,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" diff --git a/tests/integration/targets/tag_group/tasks/test.yml b/tests/integration/targets/tag_group/tasks/test.yml index 175388eb8..4e1e98299 100644 --- a/tests/integration/targets/tag_group/tasks/test.yml +++ b/tests/integration/targets/tag_group/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create tag_group." tag_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" id: Virtualization title: Virtualization topic: My_Tag_Group @@ -24,19 +24,19 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate changes." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update tag_group." tag_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" id: Virtualization title: Hypervisors topic: My_Tag_Group @@ -54,19 +54,19 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate changes." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete tag_group." tag_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" id: Virtualization title: Hypervisors topic: My_Tag_Group @@ -84,9 +84,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate changes." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/timeperiod/tasks/test.yml b/tests/integration/targets/timeperiod/tasks/test.yml index cb0e95dea..159e91f5a 100644 --- a/tests/integration/targets/timeperiod/tasks/test.yml +++ b/tests/integration/targets/timeperiod/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create new time periods." timeperiod: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" alias: "{{ item.alias }}" active_time_ranges: "{{ item.active_time_ranges }}" @@ -17,10 +17,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -29,10 +29,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update time periods." timeperiod: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" alias: "{{ item.alias | default(omit) }}" active_time_ranges: "{{ item.active_time_ranges | default(omit) }}" @@ -46,10 +46,10 @@ # As this time period is equal to the existing one, no change should happen. - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update time equal periods." timeperiod: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" alias: "{{ item.alias | default(omit) }}" active_time_ranges: "{{ item.active_time_ranges | default(omit) }}" @@ -62,10 +62,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -75,10 +75,10 @@ # This should fail. - name: "Try to delete a time period which is used by another time period." timeperiod: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -87,10 +87,10 @@ - name: "Delete other time period first." timeperiod: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -98,10 +98,10 @@ - name: "Delete a time period." timeperiod: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost @@ -109,10 +109,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" diff --git a/tests/integration/targets/user/tasks/test.yml b/tests/integration/targets/user/tasks/test.yml index b445667e1..f516ed571 100644 --- a/tests/integration/targets/user/tasks/test.yml +++ b/tests/integration/targets/user/tasks/test.yml @@ -1,10 +1,10 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create contact groups." contact_group: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item }}" title: "{{ item }}" state: "present" @@ -14,10 +14,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -26,10 +26,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create users." user: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" fullname: "{{ item.fullname }}" auth_type: "{{ item.auth_type }}" @@ -41,14 +41,14 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_users }}" + loop: "{{ checkmk_var_users }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -57,10 +57,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create same users again." user: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" fullname: "{{ item.fullname }}" auth_type: "{{ item.auth_type }}" @@ -73,7 +73,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] register: rule_result - loop: "{{ checkmk_users }}" + loop: "{{ checkmk_var_users }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler ansible.builtin.fail: @@ -84,23 +84,23 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Edit users." user: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" contactgroups: "{{ item.contactgroups }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_users }}" + loop: "{{ checkmk_var_users }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -109,24 +109,24 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Change PW of users." user: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" password: "{{ item.newpassword }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] register: rule_result - loop: "{{ checkmk_users }}" + loop: "{{ checkmk_var_users }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -135,22 +135,22 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete users." user: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_users }}" + loop: "{{ checkmk_var_users }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: true sites: - "{{ outer_item.site }}" @@ -159,16 +159,16 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete same users again." user: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] register: rule_result - loop: "{{ checkmk_users }}" + loop: "{{ checkmk_var_users }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler ansible.builtin.fail: diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index 74cf1664d..922392bdb 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -31,7 +31,7 @@ checkmk_contact_groups: - team2 - team3 -checkmk_users: +checkmk_var_users: - name: user1 fullname: User Eins password: "123" From fe3a39a9a4cfd09787dd99b5078e0328f44164f7 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 27 Oct 2023 10:32:58 +0200 Subject: [PATCH 13/25] Update ansible-lint configuration. --- .ansible-lint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ansible-lint b/.ansible-lint index 25b780842..e40297c81 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -31,7 +31,7 @@ exclude_paths: # requirements, like avoiding python identifiers. To disable add `var-naming` # to skip_list. # var_naming_pattern: "^[a-z_][a-z0-9_]*$" -var_naming_pattern: "^checkmk_(server|agent)_.*$" +var_naming_pattern: "^checkmk_(server|agent|var)_.*$" use_default_rules: true # Load custom rules from this specific folder From f1d62a751ff1cbadc97281aef333d6a2c80688d2 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 27 Oct 2023 10:40:04 +0200 Subject: [PATCH 14/25] Extend roles standards to playbooks. --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6fca1756b..c46b488ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,8 +85,8 @@ There are different approaches to the module options, depending on the nature of It is possible to implement an alias for a module option. This should be used rather carefully to not clutter the options. However, they can be an option, if one is uncertain how to name an option, or to deprecate an option, before actually removing it. If in doubt, feel free to ask for review in your PR. -### Roles -The following are guidelines to keep in mind, when changing roles. +### Roles and Playbooks +The following are guidelines to keep in mind, when creating or changing roles and playbooks. - Variables - Use snake case (`snake_case_variable`) - Name variables after their purpose. @@ -95,7 +95,7 @@ The following are guidelines to keep in mind, when changing roles. - `checkmk_var_bat` for general variables - Do not prefix the variable with an underscore ( `_` ) - Tags - - When tagging roles, separate single words with dashes (`my-custom-tag`) + - When tagging roles or playbooks, separate single words with dashes (`my-custom-tag`) ## Tests We strive to provide the best possible quality with this collection, hence we have implemented tests, that verify different aspects of code quality. From e44df75d40bf27227e20a3ec5f6c1c80e5dabb5a Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 27 Oct 2023 10:41:31 +0200 Subject: [PATCH 15/25] Bugfix linting action. --- .github/workflows/ansible-lint.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ansible-lint.yaml b/.github/workflows/ansible-lint.yaml index df90cc215..29d060fb3 100644 --- a/.github/workflows/ansible-lint.yaml +++ b/.github/workflows/ansible-lint.yaml @@ -60,12 +60,12 @@ jobs: # Run the linting - name: Run yamllint on roles - run: yamllint -c ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.yamllint ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/roles/ - working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + run: yamllint -c ./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.yamllint ./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/roles/ + working-directory: ./ansible_collections/ - name: Run yamllint on playbooks - run: yamllint -c ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.yamllint ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/playbooks/ - working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + run: yamllint -c ./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.yamllint ./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/playbooks/ + working-directory: ./ansible_collections/ - name: Run ansible-lint on roles run: ansible-lint -c ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.ansible-lint ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/roles/ From 5c7a3f8e5efbbac4dcbabe26f0a0d6a2da5d0f07 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 9 Nov 2023 16:11:56 +0100 Subject: [PATCH 16/25] Update tests with aligned variable names. --- roles/agent/README.md | 4 ++-- roles/server/molecule/2.0.0/group_vars/all.yml | 8 ++++---- roles/server/molecule/2.1.0/group_vars/all.yml | 8 ++++---- roles/server/molecule/2.2.0/group_vars/all.yml | 8 ++++---- tests/integration/targets/activation/vars/main.yml | 6 +++--- tests/integration/targets/bakery/vars/main.yml | 6 +++--- tests/integration/targets/contact_group/vars/main.yml | 6 +++--- tests/integration/targets/discovery/vars/main.yml | 6 +++--- tests/integration/targets/downtime/vars/main.yml | 6 +++--- tests/integration/targets/folder/vars/main.yml | 6 +++--- tests/integration/targets/host/vars/main.yml | 6 +++--- tests/integration/targets/host_group/vars/main.yml | 6 +++--- tests/integration/targets/lookup_folder/vars/main.yml | 6 +++--- tests/integration/targets/lookup_folders/vars/main.yml | 6 +++--- tests/integration/targets/lookup_host/vars/main.yml | 6 +++--- tests/integration/targets/lookup_hosts/vars/main.yml | 6 +++--- tests/integration/targets/lookup_version/vars/main.yml | 6 +++--- tests/integration/targets/password/vars/main.yml | 6 +++--- tests/integration/targets/rule/vars/main.yml | 6 +++--- tests/integration/targets/service_group/vars/main.yml | 6 +++--- tests/integration/targets/tag_group/vars/main.yml | 6 +++--- tests/integration/targets/timeperiod/vars/main.yml | 6 +++--- tests/integration/targets/user/vars/main.yml | 6 +++--- 23 files changed, 71 insertions(+), 71 deletions(-) diff --git a/roles/agent/README.md b/roles/agent/README.md index 18075568a..9ee20eca2 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -65,12 +65,12 @@ The site you want to use for registration tasks (Agent updates and TLS encryptio The user used to authenticate against your Checkmk site. - checkmk_agent_pass: "{{ automation_secret }}" + checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" The password for the normal user used to authenticate against your Checkmk site. This is mutually exclusive with `checkmk_agent_secret`. - checkmk_agent_secret: "{{ automation_secret }}" + checkmk_agent_secret: "{{ checkmk_var_automation_secret }}" The secret for the automation user used to authenticate against your Checkmk site. This is mutually exclusive with `checkmk_agent_pass`. diff --git a/roles/server/molecule/2.0.0/group_vars/all.yml b/roles/server/molecule/2.0.0/group_vars/all.yml index 9c9cbcb82..abceac570 100644 --- a/roles/server/molecule/2.0.0/group_vars/all.yml +++ b/roles/server/molecule/2.0.0/group_vars/all.yml @@ -36,18 +36,18 @@ checkmk_server_sites: admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "enabled" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: enabled - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'true' omd_config: - var: AUTOSTART value: "on" - name: "disabled" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: disabled - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'false' omd_config: diff --git a/roles/server/molecule/2.1.0/group_vars/all.yml b/roles/server/molecule/2.1.0/group_vars/all.yml index 566e4331e..7e2b9ae8f 100644 --- a/roles/server/molecule/2.1.0/group_vars/all.yml +++ b/roles/server/molecule/2.1.0/group_vars/all.yml @@ -36,18 +36,18 @@ checkmk_server_sites: admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "enabled" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: enabled - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'true' omd_config: - var: AUTOSTART value: "on" - name: "disabled" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: disabled - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'false' omd_config: 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 01e0f6612..b55318f54 100644 --- a/roles/server/molecule/2.2.0/group_vars/all.yml +++ b/roles/server/molecule/2.2.0/group_vars/all.yml @@ -36,18 +36,18 @@ checkmk_server_sites: admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install - name: "enabled" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: enabled - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'true' omd_config: - var: AUTOSTART value: "on" - name: "disabled" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: disabled - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'false' omd_config: diff --git a/tests/integration/targets/activation/vars/main.yml b/tests/integration/targets/activation/vars/main.yml index 8fd25ced7..62943138f 100644 --- a/tests/integration/targets/activation/vars/main.yml +++ b/tests/integration/targets/activation/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/bakery/vars/main.yml b/tests/integration/targets/bakery/vars/main.yml index 934e561e9..5496a11cd 100644 --- a/tests/integration/targets/bakery/vars/main.yml +++ b/tests/integration/targets/bakery/vars/main.yml @@ -7,9 +7,9 @@ test_sites: edition: "cee" site: "old_ent" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/contact_group/vars/main.yml b/tests/integration/targets/contact_group/vars/main.yml index aa3de1fc4..2dadc0188 100644 --- a/tests/integration/targets/contact_group/vars/main.yml +++ b/tests/integration/targets/contact_group/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/discovery/vars/main.yml b/tests/integration/targets/discovery/vars/main.yml index 781df088c..939ad3ed6 100644 --- a/tests/integration/targets/discovery/vars/main.yml +++ b/tests/integration/targets/discovery/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/downtime/vars/main.yml b/tests/integration/targets/downtime/vars/main.yml index 8fd25ced7..62943138f 100644 --- a/tests/integration/targets/downtime/vars/main.yml +++ b/tests/integration/targets/downtime/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/folder/vars/main.yml b/tests/integration/targets/folder/vars/main.yml index 268d2fd20..d801922bb 100644 --- a/tests/integration/targets/folder/vars/main.yml +++ b/tests/integration/targets/folder/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/host/vars/main.yml b/tests/integration/targets/host/vars/main.yml index fe60afd6b..064cfd6fd 100644 --- a/tests/integration/targets/host/vars/main.yml +++ b/tests/integration/targets/host/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/host_group/vars/main.yml b/tests/integration/targets/host_group/vars/main.yml index 1a05512c9..b0eabe859 100644 --- a/tests/integration/targets/host_group/vars/main.yml +++ b/tests/integration/targets/host_group/vars/main.yml @@ -16,9 +16,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/lookup_folder/vars/main.yml b/tests/integration/targets/lookup_folder/vars/main.yml index bcb52d4bc..bc47bb817 100644 --- a/tests/integration/targets/lookup_folder/vars/main.yml +++ b/tests/integration/targets/lookup_folder/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/lookup_folders/vars/main.yml b/tests/integration/targets/lookup_folders/vars/main.yml index d243b87b8..b40b448e9 100644 --- a/tests/integration/targets/lookup_folders/vars/main.yml +++ b/tests/integration/targets/lookup_folders/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/lookup_host/vars/main.yml b/tests/integration/targets/lookup_host/vars/main.yml index d3f33b046..84a66729e 100644 --- a/tests/integration/targets/lookup_host/vars/main.yml +++ b/tests/integration/targets/lookup_host/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/lookup_hosts/vars/main.yml b/tests/integration/targets/lookup_hosts/vars/main.yml index 708d308a6..95b98db17 100644 --- a/tests/integration/targets/lookup_hosts/vars/main.yml +++ b/tests/integration/targets/lookup_hosts/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/lookup_version/vars/main.yml b/tests/integration/targets/lookup_version/vars/main.yml index 7af04d7d5..7abdbd7c4 100644 --- a/tests/integration/targets/lookup_version/vars/main.yml +++ b/tests/integration/targets/lookup_version/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/password/vars/main.yml b/tests/integration/targets/password/vars/main.yml index 36406746b..aada4dbc0 100644 --- a/tests/integration/targets/password/vars/main.yml +++ b/tests/integration/targets/password/vars/main.yml @@ -16,9 +16,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/rule/vars/main.yml b/tests/integration/targets/rule/vars/main.yml index 4742f360c..0d86af019 100644 --- a/tests/integration/targets/rule/vars/main.yml +++ b/tests/integration/targets/rule/vars/main.yml @@ -10,9 +10,9 @@ test_sites: edition: "cre" site: "old_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/service_group/vars/main.yml b/tests/integration/targets/service_group/vars/main.yml index 84a617d98..9bcf526a8 100644 --- a/tests/integration/targets/service_group/vars/main.yml +++ b/tests/integration/targets/service_group/vars/main.yml @@ -16,9 +16,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/tag_group/vars/main.yml b/tests/integration/targets/tag_group/vars/main.yml index 1ce595e5a..566e3a908 100644 --- a/tests/integration/targets/tag_group/vars/main.yml +++ b/tests/integration/targets/tag_group/vars/main.yml @@ -16,9 +16,9 @@ test_sites: edition: "cre" site: "ancient_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/timeperiod/vars/main.yml b/tests/integration/targets/timeperiod/vars/main.yml index 3094db997..309afbacb 100644 --- a/tests/integration/targets/timeperiod/vars/main.yml +++ b/tests/integration/targets/timeperiod/vars/main.yml @@ -10,9 +10,9 @@ test_sites: edition: "cre" site: "old_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index 6f330ee1f..e3f7d7a93 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -13,9 +13,9 @@ test_sites: edition: "cre" site: "old_raw" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_automation_user: "cmkadmin" +checkmk_var_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" From 4f5747fd0800efa8893a0b1b1b79dfbbaac97b7f Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Thu, 9 Nov 2023 16:43:26 +0100 Subject: [PATCH 17/25] Fix server_url variable. --- roles/server/molecule/2.0.0/verify.yml | 2 +- roles/server/molecule/2.1.0/verify.yml | 2 +- roles/server/molecule/2.2.0/verify.yml | 2 +- tests/integration/targets/activation/tasks/prep.yml | 2 +- tests/integration/targets/bakery/tasks/prep.yml | 2 +- tests/integration/targets/contact_group/tasks/prep.yml | 2 +- tests/integration/targets/discovery/tasks/prep.yml | 2 +- tests/integration/targets/downtime/tasks/prep.yml | 2 +- tests/integration/targets/folder/tasks/prep.yml | 2 +- tests/integration/targets/host/tasks/prep.yml | 2 +- tests/integration/targets/host_group/tasks/prep.yml | 2 +- tests/integration/targets/lookup_folder/tasks/prep.yml | 2 +- tests/integration/targets/lookup_folders/tasks/prep.yml | 2 +- tests/integration/targets/lookup_host/tasks/prep.yml | 2 +- tests/integration/targets/lookup_hosts/tasks/prep.yml | 2 +- tests/integration/targets/lookup_version/tasks/prep.yml | 2 +- tests/integration/targets/password/tasks/prep.yml | 2 +- tests/integration/targets/rule/tasks/prep.yml | 2 +- tests/integration/targets/service_group/tasks/prep.yml | 2 +- tests/integration/targets/tag_group/tasks/prep.yml | 2 +- tests/integration/targets/timeperiod/tasks/prep.yml | 2 +- tests/integration/targets/user/tasks/prep.yml | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/roles/server/molecule/2.0.0/verify.yml b/roles/server/molecule/2.0.0/verify.yml index e4ad4e38c..0fd00c42c 100644 --- a/roles/server/molecule/2.0.0/verify.yml +++ b/roles/server/molecule/2.0.0/verify.yml @@ -44,7 +44,7 @@ - name: "Test started site URL returns 200." ansible.builtin.uri: - url: "{{ server_url }}/started/" + url: "{{ checkmk_var_server_url }}/started/" register: checkmk_server_url_state - name: "Verify started site URL returns 200." diff --git a/roles/server/molecule/2.1.0/verify.yml b/roles/server/molecule/2.1.0/verify.yml index e4ad4e38c..0fd00c42c 100644 --- a/roles/server/molecule/2.1.0/verify.yml +++ b/roles/server/molecule/2.1.0/verify.yml @@ -44,7 +44,7 @@ - name: "Test started site URL returns 200." ansible.builtin.uri: - url: "{{ server_url }}/started/" + url: "{{ checkmk_var_server_url }}/started/" register: checkmk_server_url_state - name: "Verify started site URL returns 200." diff --git a/roles/server/molecule/2.2.0/verify.yml b/roles/server/molecule/2.2.0/verify.yml index e4ad4e38c..0fd00c42c 100644 --- a/roles/server/molecule/2.2.0/verify.yml +++ b/roles/server/molecule/2.2.0/verify.yml @@ -44,7 +44,7 @@ - name: "Test started site URL returns 200." ansible.builtin.uri: - url: "{{ server_url }}/started/" + url: "{{ checkmk_var_server_url }}/started/" register: checkmk_server_url_state - name: "Verify started site URL returns 200." diff --git a/tests/integration/targets/activation/tasks/prep.yml b/tests/integration/targets/activation/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/activation/tasks/prep.yml +++ b/tests/integration/targets/activation/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/bakery/tasks/prep.yml b/tests/integration/targets/bakery/tasks/prep.yml index ea0805c9c..bf196aa8d 100644 --- a/tests/integration/targets/bakery/tasks/prep.yml +++ b/tests/integration/targets/bakery/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/contact_group/tasks/prep.yml b/tests/integration/targets/contact_group/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/contact_group/tasks/prep.yml +++ b/tests/integration/targets/contact_group/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/discovery/tasks/prep.yml b/tests/integration/targets/discovery/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/discovery/tasks/prep.yml +++ b/tests/integration/targets/discovery/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/downtime/tasks/prep.yml b/tests/integration/targets/downtime/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/downtime/tasks/prep.yml +++ b/tests/integration/targets/downtime/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/folder/tasks/prep.yml b/tests/integration/targets/folder/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/folder/tasks/prep.yml +++ b/tests/integration/targets/folder/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/host/tasks/prep.yml b/tests/integration/targets/host/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/host/tasks/prep.yml +++ b/tests/integration/targets/host/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/host_group/tasks/prep.yml b/tests/integration/targets/host_group/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/host_group/tasks/prep.yml +++ b/tests/integration/targets/host_group/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/lookup_folder/tasks/prep.yml b/tests/integration/targets/lookup_folder/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/lookup_folder/tasks/prep.yml +++ b/tests/integration/targets/lookup_folder/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/lookup_folders/tasks/prep.yml b/tests/integration/targets/lookup_folders/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/lookup_folders/tasks/prep.yml +++ b/tests/integration/targets/lookup_folders/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/lookup_host/tasks/prep.yml b/tests/integration/targets/lookup_host/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/lookup_host/tasks/prep.yml +++ b/tests/integration/targets/lookup_host/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/lookup_hosts/tasks/prep.yml b/tests/integration/targets/lookup_hosts/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/lookup_hosts/tasks/prep.yml +++ b/tests/integration/targets/lookup_hosts/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/lookup_version/tasks/prep.yml b/tests/integration/targets/lookup_version/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/lookup_version/tasks/prep.yml +++ b/tests/integration/targets/lookup_version/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/password/tasks/prep.yml b/tests/integration/targets/password/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/password/tasks/prep.yml +++ b/tests/integration/targets/password/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/rule/tasks/prep.yml b/tests/integration/targets/rule/tasks/prep.yml index 7afe242fb..42fad828b 100644 --- a/tests/integration/targets/rule/tasks/prep.yml +++ b/tests/integration/targets/rule/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/service_group/tasks/prep.yml b/tests/integration/targets/service_group/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/service_group/tasks/prep.yml +++ b/tests/integration/targets/service_group/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/tag_group/tasks/prep.yml b/tests/integration/targets/tag_group/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/tag_group/tasks/prep.yml +++ b/tests/integration/targets/tag_group/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/timeperiod/tasks/prep.yml b/tests/integration/targets/timeperiod/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/timeperiod/tasks/prep.yml +++ b/tests/integration/targets/timeperiod/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" diff --git a/tests/integration/targets/user/tasks/prep.yml b/tests/integration/targets/user/tasks/prep.yml index 7f81d9051..5f2c8e874 100644 --- a/tests/integration/targets/user/tasks/prep.yml +++ b/tests/integration/targets/user/tasks/prep.yml @@ -17,7 +17,7 @@ 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 }}" + ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" loop: "{{ test_sites }}" From d93dcdf1371d8790b303bec86870e060b36a8546 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 10 Nov 2023 16:14:51 +0100 Subject: [PATCH 18/25] Clean up documentation. --- plugins/modules/downtime.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/plugins/modules/downtime.py b/plugins/modules/downtime.py index 16c05696b..34da60870 100644 --- a/plugins/modules/downtime.py +++ b/plugins/modules/downtime.py @@ -20,16 +20,6 @@ description: - Manage downtimes within Checkmk. -notes: - - Idempotency for creation was made for hostdowntimes by only using the hostname and comment attributes. - If this combination already exists as a downtime, the new downtime will not be created except using force. - The creation of servicedowntimes works accordingly, with hostname, service description and - comment. - -todo: - - Implement idempotency for deletion - - Fine tune deletion, so only delete dt by host and comment - extends_documentation_fragment: [checkmk.general.common] options: @@ -90,6 +80,11 @@ default: present choices: [present, absent] +notes: + - Idempotency for creation was made for host downtimes by only using the hostname and comment attributes. + If this combination already exists as a downtime, the new downtime will not be created except using the B(force) argument. + The creation of service downtimes works accordingly, with hostname, service description and comment. + author: - Oliver Gaida (@ogaida) - Lars Getwan (@lgetwan) @@ -98,10 +93,10 @@ EXAMPLES = r""" - name: "Schedule host downtime." checkmk.general.downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host start_after: minutes: 5 @@ -111,10 +106,10 @@ - name: "Schedule service downtimes for two given services." checkmk.general.downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host start_time: 2022-03-24T20:39:28Z end_time: 2022-03-24T20:40:28Z @@ -126,10 +121,10 @@ - name: "Delete all service downtimes for two given services." checkmk.general.downtime: - server_url: "{{ server_url }}" + server_url: "{{ checkmk_var_server_url }}" site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host service_descriptions: - "CPU utilization" From 4019062691d3d9b36b1a8c18888e321cedee0258 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 24 Nov 2023 10:29:49 +0100 Subject: [PATCH 19/25] Fix linting findings. --- roles/agent/tasks/Linux-files.yml | 4 ++-- roles/agent/tasks/Linux.yml | 1 - roles/agent/tasks/Win32NT-files.yml | 8 ++++---- roles/agent/tasks/Windows.yml | 1 + roles/server/defaults/main.yml | 22 +++++++++++----------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/roles/agent/tasks/Linux-files.yml b/roles/agent/tasks/Linux-files.yml index 7090787ed..94e7b8577 100644 --- a/roles/agent/tasks/Linux-files.yml +++ b/roles/agent/tasks/Linux-files.yml @@ -6,10 +6,10 @@ dest: "{{ checkmk_agent_agent.file.cre }}" mode: '0640' when: checkmk_agent_edition | lower == "cre" - register: result + register: checkmk_agent_vanilla_download_state retries: 3 delay: 10 - until: "not result.failed | bool" + until: "not checkmk_agent_vanilla_download_state.failed | bool" delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index a2377d227..112cbd10c 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -138,4 +138,3 @@ port: "{{ checkmk_agent_port }}" timeout: 60 when: checkmk_agent_mode == 'pull' - \ No newline at end of file diff --git a/roles/agent/tasks/Win32NT-files.yml b/roles/agent/tasks/Win32NT-files.yml index bcac2e30b..38a589bdf 100644 --- a/roles/agent/tasks/Win32NT-files.yml +++ b/roles/agent/tasks/Win32NT-files.yml @@ -9,10 +9,10 @@ dest: "{{ checkmk_agent_agent.file.cre }}" when: | checkmk_agent_edition | lower == "cre" - register: result + register: checkmk_agent_vanilla_download_state retries: 3 delay: 10 - until: "not result.failed | bool" + until: "not checkmk_agent_vanilla_download_state.failed | bool" - name: "{{ ansible_system }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: @@ -97,10 +97,10 @@ dest: "{{ checkmk_agent_agent.file.cre }}" when: | checkmk_agent_edition | lower == "cre" - register: result + register: checkmk_agent_vanilla_download_state retries: 3 delay: 10 - until: "not result.failed | bool" + until: "not checkmk_agent_vanilla_download_state.failed | bool" delegate_to: "{{ checkmk_agent_delegate_download }}" - name: "{{ ansible_system }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 09d9f28fa..182f8619d 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -1,3 +1,4 @@ +--- - name: "{{ ansible_os_family }}: Install host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: path: "{{ checkmk_agent_agent.file.host }}" diff --git a/roles/server/defaults/main.yml b/roles/server/defaults/main.yml index 407943d33..d89281dfd 100644 --- a/roles/server/defaults/main.yml +++ b/roles/server/defaults/main.yml @@ -32,17 +32,17 @@ checkmk_server_download_user: [] checkmk_server_download_pass: [] checkmk_server_sites: [] - # - name: mysite - # version: "{{ checkmk_server_version }}" - # state: started - # admin_pw: "{{ automation_secret | default(omit) }}" - # update_conflict_resolution: abort - # omd_auto_restart: 'false' - # omd_config: - # - var: LIVESTATUS_TCP - # value: "on" - # - var: LIVESTATUS_TCP_PORT - # value: "6557" +# - name: mysite +# version: "{{ checkmk_server_version }}" +# state: started +# admin_pw: "{{ automation_secret | default(omit) }}" +# update_conflict_resolution: abort +# omd_auto_restart: 'false' +# omd_config: +# - var: LIVESTATUS_TCP +# value: "on" +# - var: LIVESTATUS_TCP_PORT +# value: "6557" checkmk_server_configure_firewall: 'true' checkmk_server_backup_on_update: 'true' # Not recommended to disable this option From 6b3c4facfd8183aaaf7f62d13280587c180e187b Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 24 Nov 2023 10:30:03 +0100 Subject: [PATCH 20/25] Add molecule to testing.sh. --- scripts/testing.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/testing.sh b/scripts/testing.sh index de2a14d25..e8c0b3b95 100755 --- a/scripts/testing.sh +++ b/scripts/testing.sh @@ -6,16 +6,17 @@ # Run tests locally. # # Usage: -# Run Sanity Tests: ./testing.sh -s -# Run Integration Tests: ./testing.sh -i -t host -# Run Linting: ./testing.sh -s +# Run Sanity Tests: ./testing.sh -s +# Run Integration Tests: ./testing.sh -i -t host +# Run Linting: ./testing.sh -l +# Run Molecule for server role and Checkmk 2.2.0: ./testing.sh -m -r server -v 2.2.0 script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) collection_dir="${script_dir%/*}" mode="sanity" -while getopts 'silt:' OPTION; do +while getopts 'silmt:r:v:' OPTION; do case "$OPTION" in s) mode="sanity" ;; @@ -23,8 +24,14 @@ while getopts 'silt:' OPTION; do mode="integration" ;; l) mode="lint" ;; + m) + mode="molecule" ;; t) target="$OPTARG" ;; + r) + role="$OPTARG" ;; + v) + version="$OPTARG" ;; ?) echo "Unknown option!" exit 1 @@ -60,6 +67,14 @@ _run_linting() { echo "## ansible-lint done." } +_run_molecule() { + echo "## Running Molecule for ${role} role and Checkmk ${version}." + cd "./roles/${role}/" || exit 1 + molecule test -s "${version}" + cd - || exit 1 + echo "## Molecule done." +} + case "$mode" in sanity) _run_sanity ;; @@ -67,6 +82,8 @@ case "$mode" in _run_integration ;; lint) _run_linting ;; + molecule) + _run_molecule ;; ?) echo "Unknown mode!" exit 1 From 839627c32648c4299d548e851a67ec6dcc8f6d07 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 24 Nov 2023 11:01:52 +0100 Subject: [PATCH 21/25] Fix molecule tests. --- roles/agent/molecule/2.0.0/group_vars/all.yml | 1 + roles/agent/molecule/2.1.0/group_vars/all.yml | 1 + roles/agent/molecule/2.2.0/group_vars/all.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/roles/agent/molecule/2.0.0/group_vars/all.yml b/roles/agent/molecule/2.0.0/group_vars/all.yml index f022bd34c..234763e55 100644 --- a/roles/agent/molecule/2.0.0/group_vars/all.yml +++ b/roles/agent/molecule/2.0.0/group_vars/all.yml @@ -17,6 +17,7 @@ checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ checkmk_var_automation_user | default('automation') }}" +checkmk_agent_port: 6556 # Depending on which user you will be using, set the password or secret: checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" 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 d6e7434e3..d8de4f164 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -17,6 +17,7 @@ checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ checkmk_var_automation_user | default('automation') }}" +checkmk_agent_port: 6556 # Depending on which user you will be using, set the password or secret: checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" 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 7d74d6d3c..e13dc23c1 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -17,6 +17,7 @@ checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ checkmk_var_automation_user | default('automation') }}" +checkmk_agent_port: 6556 # Depending on which user you will be using, set the password or secret: checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" From 7bee5c721a68440a06486bfad97571dcd92f6502 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 24 Nov 2023 11:02:37 +0100 Subject: [PATCH 22/25] Improve module documentation. --- plugins/lookup/folder.py | 8 ++++---- plugins/lookup/folders.py | 16 ++++++++-------- plugins/lookup/host.py | 8 ++++---- plugins/lookup/hosts.py | 8 ++++---- plugins/lookup/version.py | 2 +- plugins/modules/discovery.py | 4 +++- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/plugins/lookup/folder.py b/plugins/lookup/folder.py index 8e6a95129..216dfeddb 100644 --- a/plugins/lookup/folder.py +++ b/plugins/lookup/folder.py @@ -43,10 +43,10 @@ attributes: "{{ lookup('checkmk.general.folder', '~tests', - server_url=server_url, - site=site, - automation_user=automation_user, - automation_secret=automation_secret, + server_url=my_server_url, + site=my_site, + automation_user=my_user, + automation_secret=my_secret, validate_certs=False ) }}" diff --git a/plugins/lookup/folders.py b/plugins/lookup/folders.py index 41bbfe809..00790ed69 100644 --- a/plugins/lookup/folders.py +++ b/plugins/lookup/folders.py @@ -55,10 +55,10 @@ '~', show_hosts=False, recursive=True, - server_url=server_url, - site=site, - automation_user=automation_user, - automation_secret=automation_secret, + server_url=my_server_url, + site=my_site, + automation_user=my_user, + automation_secret=my_secret, validate_certs=False ) }}" @@ -74,10 +74,10 @@ '~tests', show_hosts=True, recursive=True, - server_url=server_url, - site=site, - automation_user=automation_user, - automation_secret=automation_secret, + server_url=my_server_url, + site=my_site, + automation_user=my_user, + automation_secret=my_secret, validate_certs=False ) }}" diff --git a/plugins/lookup/host.py b/plugins/lookup/host.py index 5c581820b..a9f3d4bc4 100644 --- a/plugins/lookup/host.py +++ b/plugins/lookup/host.py @@ -49,10 +49,10 @@ lookup('checkmk.general.host', 'example.com', effective_attributes=True, - server_url=server_url, - site=site, - automation_user=automation_user, - automation_secret=automation_secret, + server_url=my_server_url, + site=my_site, + automation_user=my_user, + automation_secret=my_secret, validate_certs=False ) }}" diff --git a/plugins/lookup/hosts.py b/plugins/lookup/hosts.py index b84c7a539..3b9c75392 100644 --- a/plugins/lookup/hosts.py +++ b/plugins/lookup/hosts.py @@ -45,10 +45,10 @@ loop: "{{ lookup('checkmk.general.hosts', effective_attributes=True, - server_url=server_url, - site=site, - automation_user=automation_user, - automation_secret=automation_secret, + server_url=my_server_url, + site=my_site, + automation_user=my_user, + automation_secret=my_secret, validate_certs=False ) }}" diff --git a/plugins/lookup/version.py b/plugins/lookup/version.py index 0c71a7c55..1308f3542 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -42,7 +42,7 @@ version: "{{ lookup('checkmk.general.version', server_url + '/' + site, validate_certs=False, - automation_user=automation_user, + automation_user=my_user, automation_secret=automation_secret )}}" """ diff --git a/plugins/modules/discovery.py b/plugins/modules/discovery.py index 032f085b2..e75b46ac4 100644 --- a/plugins/modules/discovery.py +++ b/plugins/modules/discovery.py @@ -29,7 +29,9 @@ required: false type: str hosts: - description: The list of hosts the services of which you want to manage. Mutually exclusive with host_name. Bulk mode. + description: + - The list of hosts the services of which you want to manage. + Mutually exclusive with host_name. This enables bulk discovery mode. required: false type: list elements: str From b1d0eb1243ee78a907d4e7469707955d9803a0c7 Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 24 Nov 2023 11:25:13 +0100 Subject: [PATCH 23/25] Fix variables in demo playbooks. --- playbooks/demo/downtimes.yml | 38 +++++----- playbooks/demo/groups.yml | 64 ++++++++-------- playbooks/demo/hosts-and-folders.yml | 30 ++++---- playbooks/demo/lookup.yml | 87 ++++++++++++---------- playbooks/demo/rules.yml | 26 +++---- playbooks/demo/users-and-contacts.yml | 26 +++---- playbooks/hosts | 24 +++--- playbooks/roles.yml | 2 +- playbooks/usecases/remote-registration.yml | 2 +- playbooks/vars/config.yml.example | 14 ++-- 10 files changed, 159 insertions(+), 154 deletions(-) diff --git a/playbooks/demo/downtimes.yml b/playbooks/demo/downtimes.yml index 4d1e4c380..cd71d7f46 100644 --- a/playbooks/demo/downtimes.yml +++ b/playbooks/demo/downtimes.yml @@ -10,7 +10,7 @@ - name: "Create folders." folder: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" @@ -23,13 +23,13 @@ - name: "Create hosts." host: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" folder: "{{ checkmk_var_folder_path }}" attributes: - site: "{{ site }}" + site: "{{ checkmk_var_site }}" ipaddress: 127.0.0.1 state: "present" delegate_to: localhost @@ -37,19 +37,19 @@ - name: "Activate changes on site." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "Downtime 1 - on services with relative timestamps" downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" @@ -68,7 +68,7 @@ - name: "Downtime 2 - on services with absolute timestamps" downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" @@ -83,7 +83,7 @@ - name: "Downtime 3 - on services without timestamps" downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" @@ -98,7 +98,7 @@ - name: "Downtime 4 - on host with relative times" downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" @@ -114,7 +114,7 @@ - name: "Downtime 5 - on host with absolute timestamps" downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" @@ -126,7 +126,7 @@ - name: "Downtime 6 - on host without timestamps" downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" @@ -136,14 +136,14 @@ - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Downtime delete 1 - service downtimes" downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" @@ -156,7 +156,7 @@ - name: "Downtime delete 2 - host downtimes" downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ inventory_hostname }}" @@ -166,14 +166,14 @@ - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Delete Hosts." host: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" @@ -184,7 +184,7 @@ - name: "Delete folders." folder: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" @@ -197,11 +197,11 @@ - name: "Activate changes on site." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/playbooks/demo/groups.yml b/playbooks/demo/groups.yml index a520dbb2b..30f04db29 100644 --- a/playbooks/demo/groups.yml +++ b/playbooks/demo/groups.yml @@ -18,7 +18,7 @@ - name: "Create host groups." host_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" @@ -26,12 +26,12 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups }}" + loop: "{{ checkmk_var_host_groups }}" - name: "Create contact groups." contact_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" @@ -39,12 +39,12 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups }}" + loop: "{{ checkmk_var_contact_groups }}" - name: "Create tag groups." tag_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" id: "{{ item.id }}" @@ -59,7 +59,7 @@ - name: "Create service groups." service_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" @@ -67,12 +67,12 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups }}" + loop: "{{ checkmk_var_service_groups }}" - name: "Assign hosts to host groups." rule: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "host_groups" @@ -89,12 +89,12 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups }}" + loop: "{{ checkmk_var_host_groups }}" - name: "Assign hosts to contact groups." rule: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "host_contactgroups" @@ -111,12 +111,12 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups }}" + loop: "{{ checkmk_var_contact_groups }}" - name: "Assign services to service groups." rule: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "service_groups" @@ -133,31 +133,31 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups }}" + loop: "{{ checkmk_var_service_groups }}" - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Activate changes on site - Showcase creation of groups." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "Unassign hosts to host groups." rule: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "host_groups" @@ -174,12 +174,12 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups }}" + loop: "{{ checkmk_var_host_groups }}" - name: "Unassign hosts to contact groups." rule: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "host_contactgroups" @@ -196,12 +196,12 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups }}" + loop: "{{ checkmk_var_contact_groups }}" - name: "Unassign services to service groups." rule: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "service_groups" @@ -218,24 +218,24 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups }}" + loop: "{{ checkmk_var_service_groups }}" - name: "Delete service groups." service_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups }}" + loop: "{{ checkmk_var_service_groups }}" - name: "Delete tag groups." tag_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" id: "{{ item.id }}" @@ -247,42 +247,42 @@ - name: "Delete contact groups." contact_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups }}" + loop: "{{ checkmk_var_contact_groups }}" - name: "Delete host groups." host_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups }}" + loop: "{{ checkmk_var_host_groups }}" - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Activate changes on site - Showcase host and folders were deleted" activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/playbooks/demo/hosts-and-folders.yml b/playbooks/demo/hosts-and-folders.yml index 57292b08c..8bdccb7fc 100644 --- a/playbooks/demo/hosts-and-folders.yml +++ b/playbooks/demo/hosts-and-folders.yml @@ -11,7 +11,7 @@ - name: "Create folders." folder: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" @@ -24,13 +24,13 @@ - name: "Create hosts." host: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" folder: "{{ checkmk_var_folder_path }}" attributes: - site: "{{ site }}" + site: "{{ checkmk_var_site }}" ipaddress: 127.0.0.1 state: "present" delegate_to: localhost @@ -38,32 +38,32 @@ - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "Change host attributes." host: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" folder: "{{ checkmk_var_folder_path }}" attributes: - site: "{{ site }}" + site: "{{ checkmk_var_site }}" alias: "Important Server" ipaddress: 127.0.0.2 state: "present" @@ -72,7 +72,7 @@ - name: "Move host to another folder." host: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" @@ -83,14 +83,14 @@ - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Delete Hosts." host: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" @@ -101,7 +101,7 @@ - name: "Delete folders." folder: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" @@ -114,18 +114,18 @@ - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/playbooks/demo/lookup.yml b/playbooks/demo/lookup.yml index 9b4e65257..d31496d7a 100644 --- a/playbooks/demo/lookup.yml +++ b/playbooks/demo/lookup.yml @@ -4,7 +4,7 @@ strategy: linear gather_facts: false vars_files: - - ../vars/auth.yml # This vars file provides details about your site + - ../vars/auth.yml # This vars file provides details about your checkmk_var_site tasks: @@ -13,10 +13,10 @@ msg: "Version is {{ checkmk_var_version }}" vars: checkmk_var_version: "{{ lookup('checkmk.general.version', - server_url + '/' + site, + checkmk_var_server_url + '/' + checkmk_var_site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] @@ -25,13 +25,14 @@ ansible.builtin.debug: msg: "Folder tree: {{ item.id }}" loop: "{{ - lookup('checkmk.general.all_folders', + lookup('checkmk.general.folders', '~', show_hosts=False, recursive=True, - site_url=server_url + '/' + site, - automation_user=automation_user, - automation_secret=automation_secret, + server_url=checkmk_var_server_url, + site=checkmk_var_site, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret, validate_certs=False) }}" loop_control: @@ -39,37 +40,41 @@ delegate_to: localhost run_once: true # noqa run-once[task] - - name: "Get all hosts of the folder /test recursively" - ansible.builtin.debug: - msg: "Host found in {{ item.0.id }}: {{ item.1.title }}" - vars: - checkmk_var_looping: "{{ - lookup('checkmk.general.all_folders', - '~tests', - show_hosts=True, - recursive=True, - site_url=server_url + '/' + site, - automation_user=automation_user, - automation_secret=automation_secret, - validate_certs=False) - }}" - loop: "{{ checkmk_var_looping | subelements('members.hosts.value') }}" - loop_control: - label: "{{ item.0.id }}" - delegate_to: localhost - run_once: true # noqa run-once[task] +## TODO: @lgetwan: Please take a look at these tasks and fix them. Bonus: Add the new lookup modules. :) - - name: "Get the attributes of folder /tests" - ansible.builtin.debug: - msg: "Attributes of folder /network: {{ checkmk_var_attributes }}" - vars: - checkmk_var_attributes: "{{ - lookup('checkmk.general.folder', - '~tests', - site_url=server_url + '/' + site, - automation_user=automation_user, - automation_secret=automation_secret, - validate_certs=False) - }}" - delegate_to: localhost - run_once: true # noqa run-once[task] + # - name: "Get all hosts of the folder /test recursively" + # ansible.builtin.debug: + # msg: "Host found in {{ item.0.id }}: {{ item.1.title }}" + # vars: + # checkmk_var_looping: "{{ + # lookup('checkmk.general.folders', + # '~tests', + # show_hosts=True, + # recursive=True, + # server_url=checkmk_var_server_url, + # site=checkmk_var_site, + # automation_user=checkmk_var_automation_user, + # automation_secret=checkmk_var_automation_secret, + # validate_certs=False) + # }}" + # loop: "{{ checkmk_var_looping | subelements('members.hosts.value') }}" + # loop_control: + # label: "{{ item.0.id }}" + # delegate_to: localhost + # run_once: true # noqa run-once[task] + + # - name: "Get the attributes of folder /tests" + # ansible.builtin.debug: + # msg: "Attributes of folder /network: {{ checkmk_var_attributes }}" + # vars: + # checkmk_var_attributes: "{{ + # lookup('checkmk.general.folder', + # '~tests', + # server_url=checkmk_var_server_url, + # site=checkmk_var_site, + # automation_user=checkmk_var_automation_user, + # automation_secret=checkmk_var_automation_secret, + # validate_certs=False) + # }}" + # delegate_to: localhost + # run_once: true # noqa run-once[task] diff --git a/playbooks/demo/rules.yml b/playbooks/demo/rules.yml index 09845b3a8..531dc6107 100644 --- a/playbooks/demo/rules.yml +++ b/playbooks/demo/rules.yml @@ -18,7 +18,7 @@ - name: "Create folders." folder: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" @@ -31,13 +31,13 @@ - name: "Create hosts." host: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" folder: "{{ checkmk_var_folder_path }}" attributes: - site: "{{ site }}" + site: "{{ checkmk_var_site }}" ipaddress: 127.0.0.1 state: "present" delegate_to: localhost @@ -45,7 +45,7 @@ - name: "Create rules." rule: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "{{ item.ruleset }}" @@ -58,26 +58,26 @@ - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "Delete rules." rule: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" ruleset: "{{ item.ruleset }}" @@ -90,7 +90,7 @@ - name: "Delete Hosts." host: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ inventory_hostname }}" @@ -101,7 +101,7 @@ - name: "Delete folders." folder: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" path: "{{ item.path }}" @@ -114,18 +114,18 @@ - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/playbooks/demo/users-and-contacts.yml b/playbooks/demo/users-and-contacts.yml index cc0cfaea6..78e0b32de 100644 --- a/playbooks/demo/users-and-contacts.yml +++ b/playbooks/demo/users-and-contacts.yml @@ -12,7 +12,7 @@ - name: "Create contact groups." contact_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" @@ -20,12 +20,12 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups }}" + loop: "{{ checkmk_var_contact_groups }}" - name: "Create users." user: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" @@ -35,7 +35,7 @@ roles: - "guest" authorized_sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -44,26 +44,26 @@ - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "Delete users." user: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" @@ -75,30 +75,30 @@ - name: "Delete contact groups." contact_group: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups }}" + loop: "{{ checkmk_var_contact_groups }}" - name: "Pause to review changes." ansible.builtin.pause: prompt: | - "Feel free to review the changes in your Checkmk site: {{ site }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}." "Press to continue." when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" force_foreign_changes: 'true' sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/playbooks/hosts b/playbooks/hosts index 717cdbd23..b203118a0 100644 --- a/playbooks/hosts +++ b/playbooks/hosts @@ -1,20 +1,20 @@ [test] -test1.tld checkmk_folder_path="/test" -test2.tld checkmk_folder_path="/foo" -test3.tld checkmk_folder_path="/bar" -test4.tld checkmk_folder_path="/" -test5.tld checkmk_folder_path="/foo/bar" +test1.tld checkmk_var_folder_path="/test" +test2.tld checkmk_var_folder_path="/foo" +test3.tld checkmk_var_folder_path="/bar" +test4.tld checkmk_var_folder_path="/" +test5.tld checkmk_var_folder_path="/foo/bar" [linux] -ansibuntu ansible_host=192.168.56.61 checkmk_folder_path="/test" -debsible ansible_host=192.168.56.62 checkmk_folder_path="/foo" -anstream ansible_host=192.168.56.63 checkmk_folder_path="foo/bar" -ansuse ansible_host=192.168.56.64 checkmk_folder_path="/bar" -ansles ansible_host=192.168.56.65 checkmk_folder_path="/bar/foo" -ansoracle ansible_host=192.168.56.66 checkmk_folder_path="/foo" +ansibuntu ansible_host=192.168.56.61 checkmk_var_folder_path="/test" +debsible ansible_host=192.168.56.62 checkmk_var_folder_path="/foo" +anstream ansible_host=192.168.56.63 checkmk_var_folder_path="foo/bar" +ansuse ansible_host=192.168.56.64 checkmk_var_folder_path="/bar" +ansles ansible_host=192.168.56.65 checkmk_var_folder_path="/bar/foo" +ansoracle ansible_host=192.168.56.66 checkmk_var_folder_path="/foo" [windows] -ansidows ansible_host=192.168.56.67 checkmk_folder_path="/" +ansidows ansible_host=192.168.56.67 checkmk_var_folder_path="/" [windows:vars] ansible_shell_type = cmd diff --git a/playbooks/roles.yml b/playbooks/roles.yml index bff23ca67..77928c8c0 100644 --- a/playbooks/roles.yml +++ b/playbooks/roles.yml @@ -12,7 +12,7 @@ tags: [agent] checkmk.general.folder: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ checkmk_var_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" validate_certs: "{{ checkmk_agent_server_validate_certs }}" diff --git a/playbooks/usecases/remote-registration.yml b/playbooks/usecases/remote-registration.yml index 230b89449..c034127f3 100644 --- a/playbooks/usecases/remote-registration.yml +++ b/playbooks/usecases/remote-registration.yml @@ -41,7 +41,7 @@ checkmk_agent_delegate_api_calls: localhost checkmk_agent_delegate_download: "{{ inventory_hostname }}" checkmk_agent_host_name: "{{ inventory_hostname }}" - checkmk_agent_host_folder: "{{ site }}" + checkmk_agent_host_folder: "{{ checkmk_var_site }}" checkmk_agent_host_ip: "{{ ansible_host }}" checkmk_agent_host_attributes: ipaddress: "{{ checkmk_agent_host_ip | default(omit) }}" diff --git a/playbooks/vars/config.yml.example b/playbooks/vars/config.yml.example index bd49c6caa..ef732e97f 100644 --- a/playbooks/vars/config.yml.example +++ b/playbooks/vars/config.yml.example @@ -1,10 +1,10 @@ --- -server_url: "http://localhost/" -site: "my_site" -automation_user: "automation" -automation_secret: "$SECRET" +checkmk_var_server_url: "http://localhost/" +checkmk_var_site: "my_site" +checkmk_var_automation_user: "automation" +checkmk_var_automation_secret: "$SECRET" -checkmk_folders: +checkmk_var_folders: - path: /test title: Test - path: /foo @@ -18,9 +18,9 @@ checkmk_folders: - path: /foo/bar/treasure title: Treasure -checkmk_ruleset: "checkgroup_parameters:memory_percentage_used" +checkmk_var_ruleset: "checkgroup_parameters:memory_percentage_used" -checkmk_rule: +checkmk_var_rule: conditions: { "host_labels": [], "host_name": { From 2acf859d7ad1e2cac4c5a83b264fa742c4f963bd Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 24 Nov 2023 11:26:42 +0100 Subject: [PATCH 24/25] Fix variables in integration tests. --- .../targets/lookup_folder/tasks/test.yml | 18 +++++++++--------- .../targets/lookup_folders/tasks/test.yml | 18 +++++++++--------- .../targets/lookup_host/tasks/test.yml | 12 ++++++------ .../targets/lookup_hosts/tasks/test.yml | 12 ++++++------ .../targets/lookup_version/tasks/test.yml | 4 ++-- tests/integration/targets/user/tasks/test.yml | 2 +- tests/integration/targets/user/vars/main.yml | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/integration/targets/lookup_folder/tasks/test.yml b/tests/integration/targets/lookup_folder/tasks/test.yml index 73392e3c6..647dc014d 100644 --- a/tests/integration/targets/lookup_folder/tasks/test.yml +++ b/tests/integration/targets/lookup_folder/tasks/test.yml @@ -19,11 +19,11 @@ vars: folders: "{{ lookup('checkmk.general.folders', '/', - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] @@ -34,11 +34,11 @@ vars: extensions: "{{ lookup('checkmk.general.folder', checkmk_folder.path, - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] @@ -49,11 +49,11 @@ vars: extensions: "{{ lookup('checkmk.general.folder', checkmk_folder.path, - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_folders/tasks/test.yml b/tests/integration/targets/lookup_folders/tasks/test.yml index 4a89a11af..befebd766 100644 --- a/tests/integration/targets/lookup_folders/tasks/test.yml +++ b/tests/integration/targets/lookup_folders/tasks/test.yml @@ -21,11 +21,11 @@ folders: "{{ lookup('checkmk.general.folders', '/', recursive=True, - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] @@ -36,11 +36,11 @@ loop: "{{ lookup('checkmk.general.folders', '/', recursive=True, - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] @@ -55,11 +55,11 @@ folders: "{{ lookup('checkmk.general.folders', '/', recursive=True, - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_host/tasks/test.yml b/tests/integration/targets/lookup_host/tasks/test.yml index 18f0ec807..281d673a0 100644 --- a/tests/integration/targets/lookup_host/tasks/test.yml +++ b/tests/integration/targets/lookup_host/tasks/test.yml @@ -21,11 +21,11 @@ vars: extensions: "{{ lookup('checkmk.general.host', checkmk_host.name, - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] @@ -36,11 +36,11 @@ vars: extensions: "{{ lookup('checkmk.general.host', checkmk_host.name, - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_hosts/tasks/test.yml b/tests/integration/targets/lookup_hosts/tasks/test.yml index e96c52e7a..3e04d6b30 100644 --- a/tests/integration/targets/lookup_hosts/tasks/test.yml +++ b/tests/integration/targets/lookup_hosts/tasks/test.yml @@ -20,11 +20,11 @@ ansible.builtin.debug: msg: "Alias of {{ item.id }} is {{ item.extensions.attributes.alias }}" loop: "{{ lookup('checkmk.general.hosts', - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] @@ -36,11 +36,11 @@ that: "checkmk_hosts|length == hosts|length" vars: hosts: "{{ lookup('checkmk.general.hosts', - server_url=server_url, + server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_version/tasks/test.yml b/tests/integration/targets/lookup_version/tasks/test.yml index 552cc5e5e..fb033a073 100644 --- a/tests/integration/targets/lookup_version/tasks/test.yml +++ b/tests/integration/targets/lookup_version/tasks/test.yml @@ -6,8 +6,8 @@ version: "{{ lookup('checkmk.general.version', server_url + '/' + outer_item.site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret) + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost register: looked_up_version diff --git a/tests/integration/targets/user/tasks/test.yml b/tests/integration/targets/user/tasks/test.yml index 11f0080ae..2024c533d 100644 --- a/tests/integration/targets/user/tasks/test.yml +++ b/tests/integration/targets/user/tasks/test.yml @@ -21,7 +21,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups }}" + loop: "{{ checkmk_var_contact_groups }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index e3f7d7a93..666cedc8a 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -29,7 +29,7 @@ checkmk_server_edition_mapping: cce: cloud cme: managed -checkmk_contact_groups: +checkmk_var_contact_groups: - team1 - team2 - team3 From c5bc4bb70935fb27670a78df0662a8a68df120fe Mon Sep 17 00:00:00 2001 From: Robin Gierse Date: Fri, 24 Nov 2023 11:29:44 +0100 Subject: [PATCH 25/25] Cleanup modules documentation. --- plugins/lookup/version.py | 2 +- plugins/modules/activation.py | 18 +++++++------- plugins/modules/bakery.py | 18 +++++++------- plugins/modules/contact_group.py | 30 +++++++++++------------ plugins/modules/discovery.py | 24 +++++++++--------- plugins/modules/downtime.py | 6 ++--- plugins/modules/folder.py | 30 +++++++++++------------ plugins/modules/host.py | 42 ++++++++++++++++---------------- plugins/modules/host_group.py | 30 +++++++++++------------ plugins/modules/password.py | 12 ++++----- plugins/modules/rule.py | 24 +++++++++--------- plugins/modules/service_group.py | 30 +++++++++++------------ plugins/modules/tag_group.py | 4 +-- plugins/modules/timeperiod.py | 18 +++++++------- plugins/modules/user.py | 20 +++++++-------- 15 files changed, 154 insertions(+), 154 deletions(-) diff --git a/plugins/lookup/version.py b/plugins/lookup/version.py index 1308f3542..81d6e6719 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -43,7 +43,7 @@ server_url + '/' + site, validate_certs=False, automation_user=my_user, - automation_secret=automation_secret + automation_secret=my_secret )}}" """ diff --git a/plugins/modules/activation.py b/plugins/modules/activation.py index c0a7a2271..759467c18 100644 --- a/plugins/modules/activation.py +++ b/plugins/modules/activation.py @@ -40,28 +40,28 @@ EXAMPLES = r""" - name: "Activate changes on all sites." checkmk.general.activation: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" run_once: 'true' - name: "Activate changes on a specific site." checkmk.general.activation: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" sites: - "my_site" run_once: 'true' - name: "Activate changes including foreign changes." checkmk.general.activation: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" force_foreign_changes: 'true' run_once: 'true' """ diff --git a/plugins/modules/bakery.py b/plugins/modules/bakery.py index 1d1d32a5a..35b9a4d28 100644 --- a/plugins/modules/bakery.py +++ b/plugins/modules/bakery.py @@ -47,28 +47,28 @@ # Bake all agents without signing, as example in a fresh installation without a signature key. - name: "Bake all agents without signing." checkmk.general.bakery: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" state: "baked" # Sign all agents. - name: "Sign all agents." checkmk.general.bakery: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" signature_key_id: 1 signature_key_passphrase: "secretkey" state: "signed" # Bake and sign all agents. - name: "Bake and sign all agents." checkmk.general.bakery: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" signature_key_id: 1 signature_key_passphrase: "secretkey" state: "baked_signed" diff --git a/plugins/modules/contact_group.py b/plugins/modules/contact_group.py index fccc3c136..2887bc4b2 100644 --- a/plugins/modules/contact_group.py +++ b/plugins/modules/contact_group.py @@ -58,10 +58,10 @@ # Create a single contact group. - name: "Create a single contact group." checkmk.general.contact_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_contact_group" title: "My Contact Group" customer: "provider" @@ -70,10 +70,10 @@ # Create several contact groups. - name: "Create several contact groups." checkmk.general.contact_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" customer: "provider" groups: - name: "my_contact_group_one" @@ -87,10 +87,10 @@ # Create several contact groups. - name: "Create several contact groups." checkmk.general.contact_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" customer: "provider" groups: - name: "my_contact_group_one" @@ -102,20 +102,20 @@ # Delete a single contact group. - name: "Create a single contact group." checkmk.general.contact_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_contact_group" state: "absent" # Delete several contact groups. - name: "Delete several contact groups." checkmk.general.contact_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" groups: - name: "my_contact_group_one" - name: "my_contact_group_two" diff --git a/plugins/modules/discovery.py b/plugins/modules/discovery.py index e75b46ac4..d3ee860d5 100644 --- a/plugins/modules/discovery.py +++ b/plugins/modules/discovery.py @@ -63,34 +63,34 @@ # Create a single host. - name: "Add newly discovered services on host." checkmk.general.discovery: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" host_name: "my_host" state: "new" - name: "Add newly discovered services, update labels and remove vanished services on host." checkmk.general.discovery: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" host_name: "my_host" state: "fix_all" - name: "Add newly discovered services on hosts. (Bulk)" checkmk.general.discovery: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" hosts: "[my_host_0, my_host_1]" state: "new" - name: "Add newly discovered services, update labels and remove vanished services on host; 3 at once (Bulk)" checkmk.general.discovery: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" hosts: "[my_host_0, my_host_1, my_host_2, my_host_3, my_host_4, my_host_5]" state: "fix_all" bulk_size: 3 diff --git a/plugins/modules/downtime.py b/plugins/modules/downtime.py index 34da60870..4e3c3f93b 100644 --- a/plugins/modules/downtime.py +++ b/plugins/modules/downtime.py @@ -94,7 +94,7 @@ - name: "Schedule host downtime." checkmk.general.downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ my_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host @@ -107,7 +107,7 @@ - name: "Schedule service downtimes for two given services." checkmk.general.downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ my_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host @@ -122,7 +122,7 @@ - name: "Delete all service downtimes for two given services." checkmk.general.downtime: server_url: "{{ checkmk_var_server_url }}" - site: "{{ site }}" + site: "{{ my_site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host diff --git a/plugins/modules/folder.py b/plugins/modules/folder.py index 10fc8956b..e2f6a5c5e 100644 --- a/plugins/modules/folder.py +++ b/plugins/modules/folder.py @@ -74,10 +74,10 @@ # Create a single folder. - name: "Create a single folder." checkmk.general.folder: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" path: "/my_folder" name: "My Folder" state: "present" @@ -85,10 +85,10 @@ # Create a folder who's hosts should be hosted on a remote site. - name: "Create a single folder." checkmk.general.folder: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" path: "/my_remote_folder" name: "My Remote Folder" attributes: @@ -98,10 +98,10 @@ # Create a folder with Criticality set to a Test system and Networking Segment WAN (high latency)" - name: "Create a folder with tag_criticality test and tag_networking wan" checkmk.general.folder: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" path: "/my_remote_folder" attributes: tag_criticality: "test" @@ -111,10 +111,10 @@ # Update only specified attributes - name: "Update only specified attributes" checkmk.general.folder: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" path: "/my_folder" update_attributes: tag_networking: "dmz" @@ -123,10 +123,10 @@ # Remove specified attributes - name: "Remove specified attributes" checkmk.general.folder: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" path: "/my_folder" remove_attributes: - tag_networking diff --git a/plugins/modules/host.py b/plugins/modules/host.py index f5f221644..63301f621 100644 --- a/plugins/modules/host.py +++ b/plugins/modules/host.py @@ -67,10 +67,10 @@ # Create a host. - name: "Create a host." checkmk.general.host: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host" folder: "/" state: "present" @@ -78,10 +78,10 @@ # Create a host with IP. - name: "Create a host with IP address." checkmk.general.host: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host" attributes: alias: "My Host" @@ -92,10 +92,10 @@ # Create a host which is monitored on a distinct site. - name: "Create a host which is monitored on a distinct site." checkmk.general.host: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host" attributes: site: "my_remote_site" @@ -105,10 +105,10 @@ # Create a host with update_attributes. - name: "Create a host which is monitored on a distinct site." checkmk.general.host: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host" update_attributes: site: "my_remote_site" @@ -117,10 +117,10 @@ # Update only specified attributes - name: "Update only specified attributes" checkmk.general.host: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host" update_attributes: alias: "foo" @@ -129,10 +129,10 @@ # Remove specified attributes - name: "Remove specified attributes" checkmk.general.host: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host" remove_attributes: - alias @@ -141,10 +141,10 @@ # Add custom tags to a host (note the leading 'tag_') - name: "Remove specified attributes" checkmk.general.host: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host" update_attributes: - tag_my_tag_1: "Bar" diff --git a/plugins/modules/host_group.py b/plugins/modules/host_group.py index 24d4a0e33..80a53e44b 100644 --- a/plugins/modules/host_group.py +++ b/plugins/modules/host_group.py @@ -54,10 +54,10 @@ # Create a single host group. - name: "Create a single host group." checkmk.general.host_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host_group" title: "My Host Group" customer: "provider" @@ -66,10 +66,10 @@ # Create several host groups. - name: "Create several host groups." checkmk.general.host_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" customer: "provider" groups: - name: "my_host_group_one" @@ -83,10 +83,10 @@ # Create several host groups. - name: "Create several host groups." checkmk.general.host_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" customer: "provider" groups: - name: "my_host_group_one" @@ -98,20 +98,20 @@ # Delete a single host group. - name: "Create a single host group." checkmk.general.host_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_host_group" state: "absent" # Delete several host groups. - name: "Delete several host groups." checkmk.general.host_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" groups: - name: "my_host_group_one" - name: "my_host_group_two" diff --git a/plugins/modules/password.py b/plugins/modules/password.py index cdebb1e52..3146a0c13 100644 --- a/plugins/modules/password.py +++ b/plugins/modules/password.py @@ -78,10 +78,10 @@ # If passwords are configured, no_log should be set to true. - name: "Create a new password." checkmk.general.password: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "mypassword" title: "My Password" customer: "provider" @@ -96,10 +96,10 @@ no_log: true - name: "Delete a password." checkmk.general.password: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "mypassword" state: "absent" """ diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index bfa1769d5..57bb24347 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -94,10 +94,10 @@ # at the top of the main folder. - name: "Create a rule in checkgroup_parameters:memory_percentage_used." checkmk.general.rule: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { @@ -132,10 +132,10 @@ # and put it after the rule created above. - name: "Create a rule in checkgroup_parameters:memory_percentage_used." checkmk.general.rule: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { @@ -164,10 +164,10 @@ # Delete the first rule. - name: "Delete a rule." checkmk.general.rule: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { @@ -193,10 +193,10 @@ # Create a rule rule matching a host label - name: "Create a rule matching a label." checkmk.general.rule: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" ruleset: "checkgroup_parameters:memory_percentage_used" rule: conditions: { diff --git a/plugins/modules/service_group.py b/plugins/modules/service_group.py index 99a4e0d61..4901f2764 100644 --- a/plugins/modules/service_group.py +++ b/plugins/modules/service_group.py @@ -58,10 +58,10 @@ # Create a single service group. - name: "Create a single service group." checkmk.general.service_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_service_group" title: "My Service Group" customer: "provider" @@ -70,10 +70,10 @@ # Create several service groups. - name: "Create several service groups." checkmk.general.service_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" customer: "provider" groups: - name: "my_service_group_one" @@ -87,10 +87,10 @@ # Create several service groups. - name: "Create several service groups." checkmk.general.service_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" customer: "provider" groups: - name: "my_service_group_one" @@ -102,20 +102,20 @@ # Delete a single service group. - name: "Create a single service group." checkmk.general.service_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "my_service_group" state: "absent" # Delete several service groups. - name: "Delete several service groups." checkmk.general.service_group: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" groups: - name: "my_service_group_one" - name: "my_service_group_two" diff --git a/plugins/modules/tag_group.py b/plugins/modules/tag_group.py index 4160cd1aa..5e3868158 100644 --- a/plugins/modules/tag_group.py +++ b/plugins/modules/tag_group.py @@ -58,8 +58,8 @@ checkmk.general.tag_group: server_url: "https://localhost/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" id: Virtualization title: Virtualization topic: My_Tags diff --git a/plugins/modules/timeperiod.py b/plugins/modules/timeperiod.py index 3f3fa15c2..86401991d 100644 --- a/plugins/modules/timeperiod.py +++ b/plugins/modules/timeperiod.py @@ -62,10 +62,10 @@ # Creating and Updating is the same. - name: "Create a new time period. (Attributes in one line)" checkmk.general.timeperiod: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "worktime" title: "Worktime" active_time_ranges: '[{"day": "all", "time_ranges": [{"start": "09:00:00", "end": "17:00:00"}]}]' @@ -75,10 +75,10 @@ - name: "Create a new time period. (Attributes in multiple lines)" checkmk.general.timeperiod: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "worktime" title: "Worktime" active_time_ranges: [ @@ -110,10 +110,10 @@ - name: "Delete a time period." checkmk.general.timeperiod: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "my_site" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "worktime" state: "absent" """ diff --git a/plugins/modules/user.py b/plugins/modules/user.py index ef185c838..dc0487f58 100644 --- a/plugins/modules/user.py +++ b/plugins/modules/user.py @@ -93,10 +93,10 @@ # Create a user. - name: "Create a user." checkmk.general.user: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "local" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "krichards" fullname: "Keith Richards" customer: "provider" @@ -112,10 +112,10 @@ # Create an automation user. - name: "Create an automation user." checkmk.general.user: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "local" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "registration" fullname: "Registration User" customer: "provider" @@ -128,10 +128,10 @@ # Create a detailed user. - name: "Create a detailed user." checkmk.general.user: - server_url: "http://localhost/" + server_url: "http://my_server/" site: "local" - automation_user: "automation" - automation_secret: "$SECRET" + automation_user: "my_user" + automation_secret: "my_secret" name: "horst" fullname: "Horst Schlämmer" customer: "provider" @@ -150,7 +150,7 @@ roles: - "user" authorized_sites: - - "{{ site }}" + - "{{ my_site }}" state: "present" """