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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1d54fc293..c46b488ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,13 +85,17 @@ 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. + - `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`) + - 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. diff --git a/playbooks/demo/downtimes.yml b/playbooks/demo/downtimes.yml index e3b301b2b..cd71d7f46 100644 --- a/playbooks/demo/downtimes.yml +++ b/playbooks/demo/downtimes.yml @@ -9,49 +9,49 @@ tasks: - name: "Create folders." folder: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" attributes: - site: "{{ site }}" + site: "{{ checkmk_var_site }}" ipaddress: 127.0.0.1 state: "present" delegate_to: localhost - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" host_name: "{{ inventory_hostname }}" comment: downtime 6 - on host without timestamps delegate_to: localhost @@ -136,16 +136,16 @@ - 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 run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Downtime delete 1 - service downtimes" downtime: - server_url: "{{ server_url }}" - site: "{{ 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 }}" host_name: "{{ inventory_hostname }}" service_descriptions: - "Check_MK" @@ -155,10 +155,10 @@ - name: "Downtime delete 2 - host downtimes" downtime: - server_url: "{{ server_url }}" - site: "{{ 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 }}" host_name: "{{ inventory_hostname }}" state: absent delegate_to: localhost @@ -166,43 +166,42 @@ - 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 run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Delete Hosts." host: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 3493b28cf..30f04db29 100644 --- a/playbooks/demo/groups.yml +++ b/playbooks/demo/groups.yml @@ -17,36 +17,36 @@ - name: "Create host groups." host_group: - server_url: "{{ server_url }}" - site: "{{ 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 }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" 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: "{{ server_url }}" - site: "{{ 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 }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" 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: "{{ server_url }}" - site: "{{ 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 }}" id: "{{ item.id }}" title: "{{ item.title | default(item.id) }}" topic: "{{ item.topic }}" @@ -54,27 +54,27 @@ 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 }}" - site: "{{ 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 }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" 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: "{{ server_url }}" - site: "{{ 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 }}" ruleset: "host_groups" rule: location: @@ -89,14 +89,14 @@ 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: "{{ server_url }}" - site: "{{ 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 }}" ruleset: "host_contactgroups" rule: location: @@ -111,14 +111,14 @@ 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: "{{ server_url }}" - site: "{{ 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 }}" ruleset: "service_groups" rule: location: @@ -133,33 +133,33 @@ 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 run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site - Showcase creation of groups." activation: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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: "{{ server_url }}" - site: "{{ 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 }}" ruleset: "host_groups" rule: location: @@ -174,14 +174,14 @@ 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: "{{ server_url }}" - site: "{{ 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 }}" ruleset: "host_contactgroups" rule: location: @@ -196,14 +196,14 @@ 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: "{{ server_url }}" - site: "{{ 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 }}" ruleset: "service_groups" rule: location: @@ -218,71 +218,71 @@ 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: "{{ server_url }}" - site: "{{ 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 }}" 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: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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: "{{ server_url }}" - site: "{{ 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 }}" 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 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 }}" - site: "{{ 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 }}" 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 2e0c7f203..8bdccb7fc 100644 --- a/playbooks/demo/hosts-and-folders.yml +++ b/playbooks/demo/hosts-and-folders.yml @@ -10,27 +10,27 @@ - name: "Create folders." folder: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + 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 run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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: "{{ server_url }}" - site: "{{ 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 }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" attributes: - site: "{{ site }}" + site: "{{ checkmk_var_site }}" alias: "Important Server" ipaddress: 127.0.0.2 state: "present" @@ -71,10 +71,10 @@ - name: "Move host to another folder." host: - server_url: "{{ server_url }}" - site: "{{ 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 }}" name: "{{ inventory_hostname }}" folder: "/bar" state: "present" @@ -83,50 +83,49 @@ - 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 run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Delete Hosts." host: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_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 }}" - site: "{{ 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 }}" 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 96545907d..d31496d7a 100644 --- a/playbooks/demo/lookup.yml +++ b/playbooks/demo/lookup.yml @@ -4,19 +4,19 @@ 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: - name: "Get Checkmk version." ansible.builtin.debug: - msg: "Version is {{ version }}" + msg: "Version is {{ checkmk_var_version }}" vars: - version: "{{ lookup('checkmk.general.version', - server_url + '/' + site, + checkmk_var_version: "{{ lookup('checkmk.general.version', + 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: - 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: "{{ 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: {{ attributes }}" - vars: - 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 25ce1498c..531dc6107 100644 --- a/playbooks/demo/rules.yml +++ b/playbooks/demo/rules.yml @@ -17,115 +17,115 @@ - name: "Create folders." folder: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" name: "{{ inventory_hostname }}" - folder: "{{ checkmk_folder_path }}" + folder: "{{ checkmk_var_folder_path }}" attributes: - site: "{{ site }}" + site: "{{ checkmk_var_site }}" ipaddress: 127.0.0.1 state: "present" delegate_to: localhost - name: "Create rules." rule: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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 - 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 run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_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 }}" - site: "{{ 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 }}" 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 298492d61..78e0b32de 100644 --- a/playbooks/demo/users-and-contacts.yml +++ b/playbooks/demo/users-and-contacts.yml @@ -11,23 +11,23 @@ - name: "Create contact groups." contact_group: - server_url: "{{ server_url }}" - site: "{{ 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 }}" name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" 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: "{{ server_url }}" - site: "{{ 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 }}" name: "{{ item.name }}" fullname: "{{ item.fullname }}" auth_type: "{{ item.auth_type }}" @@ -35,70 +35,70 @@ roles: - "guest" authorized_sites: - - "{{ site }}" + - "{{ checkmk_var_site }}" 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 }}." + "Feel free to review the changes in your Checkmk site: {{ checkmk_var_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 }}" - site: "{{ 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 }}" 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: "{{ server_url }}" - site: "{{ 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 }}" 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 }}" - site: "{{ 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 }}" 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 run_unattended | bool + when: not checkmk_var_run_unattended | bool - name: "Activate changes on site." activation: - server_url: "{{ server_url }}" - site: "{{ 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 }}" 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 6412ef51a..77928c8c0 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 }}" - site: "{{ 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: "{{ 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/usecases/remote-registration.yml b/playbooks/usecases/remote-registration.yml index a4b204786..c034127f3 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. @@ -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/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/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": { 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" 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..81d6e6719 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -42,8 +42,8 @@ version: "{{ lookup('checkmk.general.version', server_url + '/' + site, validate_certs=False, - automation_user=automation_user, - automation_secret=automation_secret + automation_user=my_user, + 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 032f085b2..d3ee860d5 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 @@ -61,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 16c05696b..4e3c3f93b 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 }}" - site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + server_url: "{{ checkmk_var_server_url }}" + site: "{{ my_site }}" + 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 }}" - site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + server_url: "{{ checkmk_var_server_url }}" + site: "{{ my_site }}" + 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 }}" - site: "{{ site }}" - automation_user: "{{ automation_user }}" - automation_secret: "{{ automation_secret }}" + server_url: "{{ checkmk_var_server_url }}" + site: "{{ my_site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" host_name: my_host service_descriptions: - "CPU utilization" 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" """ diff --git a/roles/agent/README.md b/roles/agent/README.md index 18075568a..9210baeb1 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. @@ -65,16 +65,25 @@ 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`. + 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/defaults/main.yml b/roles/agent/defaults/main.yml index 06f2ca1a6..3d107bc83 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -1,18 +1,19 @@ --- checkmk_agent_version: "2.2.0p14" 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') }}" +checkmk_agent_port: 6556 # 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,8 +28,9 @@ 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_port_check: 'true' checkmk_agent_host_attributes: ipaddress: "{{ checkmk_agent_host_ip | default(omit) }}" checkmk_agent_mode: pull 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 }}" 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..234763e55 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,27 @@ --- # 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_protocol: http +checkmk_agent_version: "{{ checkmk_var_version }}" +checkmk_agent_edition: "{{ checkmk_var_edition }}" +checkmk_agent_server_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_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: "{{ 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 +35,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 +50,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.0.0/verify.yml b/roles/agent/molecule/2.0.0/verify.yml index 868935aaa..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_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_port.port == 6556) and (checkmk_agent_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/group_vars/all.yml b/roles/agent/molecule/2.1.0/group_vars/all.yml index df95cf1b3..d8de4f164 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,27 @@ --- # General -checkmk_version: "2.1.0p36" -checkmk_edition: "cre" -checkmk_site: "my_site" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.1.0p36" +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_protocol: http +checkmk_agent_version: "{{ checkmk_var_version }}" +checkmk_agent_edition: "{{ checkmk_var_edition }}" +checkmk_agent_server_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_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: "{{ 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 +35,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 +50,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/verify.yml b/roles/agent/molecule/2.1.0/verify.yml index 79fce6e30..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_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_port.port == 6556) and (checkmk_agent_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/group_vars/all.yml b/roles/agent/molecule/2.2.0/group_vars/all.yml index 9446a6fba..e13dc23c1 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,27 @@ --- # General -checkmk_version: "2.2.0p14" -checkmk_edition: "cre" -checkmk_site: "my_site" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.2.0p14" +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_protocol: http +checkmk_agent_version: "{{ checkmk_var_version }}" +checkmk_agent_edition: "{{ checkmk_var_edition }}" +checkmk_agent_server_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_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: "{{ 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 +35,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 +50,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/verify.yml b/roles/agent/molecule/2.2.0/verify.yml index 79fce6e30..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_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_port.port == 6556) and (checkmk_agent_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/Debian.yml b/roles/agent/tasks/Debian.yml index 508a67ccc..78df40bb1 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: diff --git a/roles/agent/tasks/Linux-files.yml b/roles/agent/tasks/Linux-files.yml new file mode 100644 index 000000000..94e7b8577 --- /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: checkmk_agent_vanilla_download_state + retries: 3 + delay: 10 + until: "not checkmk_agent_vanilla_download_state.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: "{{ 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 }} + +- 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: "{{ 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 }} + +- 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 78e03d2a8..112cbd10c 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -8,8 +8,25 @@ - name: "{{ ansible_system }}: Populate service facts." ansible.builtin.service_facts: -- name: "{{ ansible_system }}: Import Legacy agent tasks." - ansible.builtin.include_tasks: "legacy.yml" +- name: "{{ ansible_system }}: Import Legacy agent tasks." # noqa key-order[task] + 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 @@ -21,10 +38,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 @@ -34,9 +51,9 @@ 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 }}/" + 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 }}" @@ -116,8 +133,8 @@ 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 + port: "{{ checkmk_agent_port }}" timeout: 60 when: checkmk_agent_mode == 'pull' diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index 2d10f88fd..ada672a3b 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: @@ -151,7 +57,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/Suse.yml b/roles/agent/tasks/Suse.yml index 87de4863b..fe0ceb277 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: diff --git a/roles/agent/tasks/Win32NT-files.yml b/roles/agent/tasks/Win32NT-files.yml new file mode 100644 index 000000000..38a589bdf --- /dev/null +++ b/roles/agent/tasks/Win32NT-files.yml @@ -0,0 +1,199 @@ +--- +- 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." + 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: checkmk_agent_vanilla_download_state + retries: 3 + delay: 10 + 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: + 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: "{{ 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 }} + + - 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: "{{ 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 }} + + - 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: "{{ 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)." + 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: checkmk_agent_vanilla_download_state + retries: 3 + delay: 10 + 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)." + 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: "{{ 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 }} + + - 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: "{{ 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 }} + + - 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 4d28662c1..44d78e1b1 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -1,12 +1,12 @@ --- -- 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 }}/" + 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 }}" @@ -39,15 +39,15 @@ 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 }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" register: checkmk_agent_update_state @@ -60,10 +60,10 @@ 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 }} \ + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ -U {{ checkmk_agent_user }} -S {{ checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" register: checkmk_agent_update_state @@ -79,7 +79,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 }} \ @@ -93,7 +93,8 @@ 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 + port: "{{ checkmk_agent_port }}" timeout: 60 + when: checkmk_agent_port_check | bool diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 23f1c03d2..182f8619d 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -1,41 +1,4 @@ --- -- name: "{{ ansible_os_family }}: Download Vanilla agent." - ansible.windows.win_get_url: - url: "{{ checkmk_agent_agent.url.cre }}" - validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - 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/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 diff --git a/roles/agent/tasks/main.yml b/roles/agent/tasks/main.yml index d015fbf57..92714b688 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: @@ -22,7 +28,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 }}" @@ -32,15 +38,15 @@ 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 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 }}" @@ -50,8 +56,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/agent/vars/main.yml b/roles/agent/vars/main.yml index 6211fb2a7..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] @@ -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 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 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 bf30f3b3d..abceac570 100644 --- a/roles/server/molecule/2.0.0/group_vars/all.yml +++ b/roles/server/molecule/2.0.0/group_vars/all.yml @@ -1,14 +1,14 @@ --- # General -checkmk_version: "2.0.0p39" -checkmk_edition: "cre" -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_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,9 +20,9 @@ checkmk_server_allow_downgrades: 'true' checkmk_server_sites: - name: "started" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'true' omd_config: @@ -31,39 +31,39 @@ checkmk_server_sites: - var: LIVESTATUS_TCP_PORT value: "6557" - 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: "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: - var: AUTOSTART value: "off" - 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 omd_auto_restart: 'false' omd_config: - var: LIVESTATUS_TCP value: "on" - 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 f475fd806..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." @@ -53,10 +53,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: "started" - 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 ff57e23ab..7e2b9ae8f 100644 --- a/roles/server/molecule/2.1.0/group_vars/all.yml +++ b/roles/server/molecule/2.1.0/group_vars/all.yml @@ -1,14 +1,14 @@ --- # General -checkmk_version: "2.1.0p36" -checkmk_edition: "cre" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.1.0p36" +checkmk_var_edition: "cre" +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,9 +20,9 @@ checkmk_server_allow_downgrades: 'true' checkmk_server_sites: - name: "started" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'true' omd_config: @@ -31,39 +31,39 @@ checkmk_server_sites: - var: LIVESTATUS_TCP_PORT value: "6557" - 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: "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: - var: AUTOSTART value: "off" - 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 omd_auto_restart: 'false' omd_config: - var: LIVESTATUS_TCP value: "on" - 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 f475fd806..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." @@ -53,10 +53,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: "started" - 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 5c2374d58..b55318f54 100644 --- a/roles/server/molecule/2.2.0/group_vars/all.yml +++ b/roles/server/molecule/2.2.0/group_vars/all.yml @@ -1,14 +1,14 @@ --- # General -checkmk_version: "2.2.0p14" -checkmk_edition: "cre" -server_url: "http://127.0.0.1/" -automation_user: "cmkadmin" -automation_secret: "d7589df1" +checkmk_var_version: "2.2.0p14" +checkmk_var_edition: "cre" +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,9 +20,9 @@ checkmk_server_allow_downgrades: 'true' checkmk_server_sites: - name: "started" - version: "{{ checkmk_version }}" + version: "{{ checkmk_var_version }}" state: started - admin_pw: "{{ automation_secret }}" + admin_pw: "{{ checkmk_var_automation_secret }}" update_conflict_resolution: install omd_auto_restart: 'true' omd_config: @@ -31,39 +31,39 @@ checkmk_server_sites: - var: LIVESTATUS_TCP_PORT value: "6557" - 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: "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: - var: AUTOSTART value: "off" - 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 omd_auto_restart: 'false' omd_config: - var: LIVESTATUS_TCP value: "on" - 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 f475fd806..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." @@ -53,10 +53,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: "started" - 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 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 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/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/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/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/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 947d4c9e7..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" @@ -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/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/contact_group/tasks/test.yml b/tests/integration/targets/contact_group/tasks/test.yml index 5bdc8d3d8..d91aec55a 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 }} - Test for mutually exclusive module args: 'groups|name'." 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 @@ -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 }} - 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" @@ -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 }} - 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 @@ -79,10 +79,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 }}" @@ -91,10 +91,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 @@ -103,10 +103,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 }}" @@ -115,10 +115,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 @@ -126,10 +126,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for mutually exclusive module args: 'groups|name'." 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" @@ -140,10 +140,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for uneffective module args: 'groups' and 'title'." 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" @@ -155,10 +155,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 @@ -166,10 +166,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 @@ -177,10 +177,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk delete contact groups checking 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 @@ -188,10 +188,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/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/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/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/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/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/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/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/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/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 20170db82..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" @@ -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/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/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 f313ef3d1..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" @@ -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/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/host_group/tasks/test.yml b/tests/integration/targets/host_group/tasks/test.yml index 3d77e27bd..30f73a6eb 100644 --- a/tests/integration/targets/host_group/tasks/test.yml +++ b/tests/integration/targets/host_group/tasks/test.yml @@ -11,10 +11,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" @@ -25,10 +25,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for mutually exclusive module args: 'groups|name'." 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" @@ -42,10 +42,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 }}" @@ -54,10 +54,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name | default(item.name) }}" title: "{{ item.title }}" @@ -68,10 +68,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 }}" @@ -80,10 +80,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" @@ -93,10 +93,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 }}" @@ -105,10 +105,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" @@ -118,10 +118,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 }}" @@ -130,10 +130,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_host_groups_create }}" state: "present" @@ -142,10 +142,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for mutually exclusive module args: 'groups|name'." 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_host_groups_create }}" name: "test" @@ -157,10 +157,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for uneffective module args: 'groups' and 'title'." 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_host_groups_create }}" title: "Test" @@ -173,10 +173,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_host_groups_modify }}" state: "present" @@ -185,10 +185,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_host_groups_delete }}" state: "absent" @@ -197,10 +197,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_host_groups_create }}" state: "absent" @@ -209,10 +209,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/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/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_folder/tasks/test.yml b/tests/integration/targets/lookup_folder/tasks/test.yml index aaa73df55..647dc014d 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: @@ -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_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/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_folders/tasks/test.yml b/tests/integration/targets/lookup_folders/tasks/test.yml index e0f195fd7..befebd766 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: @@ -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] @@ -50,16 +50,16 @@ - 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', '/', 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_folders/vars/main.yml b/tests/integration/targets/lookup_folders/vars/main.yml index 47f3c20ca..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" @@ -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/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_host/tasks/test.yml b/tests/integration/targets/lookup_host/tasks/test.yml index 743e4868d..281d673a0 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: @@ -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_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/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_hosts/tasks/test.yml b/tests/integration/targets/lookup_hosts/tasks/test.yml index 5b479916b..3e04d6b30 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: @@ -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_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/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/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/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/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/password/tasks/test.yml b/tests/integration/targets/password/tasks/test.yml index 7c88b92ca..2299dedb7 100644 --- a/tests/integration/targets/password/tasks/test.yml +++ b/tests/integration/targets/password/tasks/test.yml @@ -11,10 +11,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title }}" @@ -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 }} - 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(omit) }}" @@ -61,10 +61,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 }}" @@ -73,10 +73,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" @@ -85,10 +85,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/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/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/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 655810f28..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" @@ -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/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/service_group/tasks/test.yml b/tests/integration/targets/service_group/tasks/test.yml index cc2e392ce..2cb0bf457 100644 --- a/tests/integration/targets/service_group/tasks/test.yml +++ b/tests/integration/targets/service_group/tasks/test.yml @@ -11,10 +11,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" @@ -25,10 +25,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for mutually exclusive module args: 'groups|name'." 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" @@ -42,10 +42,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 }}" @@ -54,10 +54,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name | default(item.name) }}" title: "{{ item.title }}" @@ -68,10 +68,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 }}" @@ -80,10 +80,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" @@ -93,10 +93,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 }}" @@ -105,10 +105,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" @@ -118,10 +118,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 }}" @@ -130,10 +130,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_service_groups_create }}" state: "present" @@ -142,10 +142,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for mutually exclusive module args: 'groups|name'." 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_service_groups_create }}" name: "test" @@ -157,10 +157,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for uneffective module args: 'groups' and 'title'." 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_service_groups_create }}" title: "Test" @@ -173,10 +173,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_service_groups_modify }}" state: "present" @@ -185,10 +185,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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_service_groups_delete }}" state: "absent" @@ -197,10 +197,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk delete service groups checking 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 groups: "{{ checkmk_service_groups_create }}" state: "absent" @@ -209,10 +209,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/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/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/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/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/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/timeperiod/tasks/test.yml b/tests/integration/targets/timeperiod/tasks/test.yml index aab01ffdb..430473bf2 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: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test that a timeperiod which is still in use cannot be deleted." 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 @@ -88,10 +88,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - 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 @@ -99,10 +99,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - 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 @@ -110,10 +110,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/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/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 }}" diff --git a/tests/integration/targets/user/tasks/test.yml b/tests/integration/targets/user/tasks/test.yml index 9d2369b12..2024c533d 100644 --- a/tests/integration/targets/user/tasks/test.yml +++ b/tests/integration/targets/user/tasks/test.yml @@ -11,24 +11,24 @@ - 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item }}" title: "{{ item }}" 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: - 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 }}" @@ -37,10 +37,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create users." user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module - 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" fullname: "{{ item.fullname }}" @@ -53,14 +53,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 }}" @@ -69,10 +69,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create same users again." user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module - 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" fullname: "{{ item.fullname }}" @@ -86,7 +86,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: @@ -97,24 +97,24 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Edit users." user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module - 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 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 }}" @@ -123,10 +123,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Change PW of users." user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module - 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 }}" customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 name: "{{ item.name }}" password: "{{ item.newpassword }}" @@ -134,14 +134,14 @@ 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 }}" @@ -150,22 +150,22 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete users." user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module - 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 }}" @@ -174,16 +174,16 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete same users again." user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module - 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 ca1e1af9c..666cedc8a 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" @@ -29,12 +29,12 @@ checkmk_server_edition_mapping: cce: cloud cme: managed -checkmk_contact_groups: +checkmk_var_contact_groups: - team1 - team2 - team3 -checkmk_users: +checkmk_var_users: - name: admin1 fullname: Admin Eins password: "123"