Skip to content

Commit

Permalink
Merge pull request #654 from Checkmk/feature/module-distributed
Browse files Browse the repository at this point in the history
Implement module "site" for configuring distributed monitoring
  • Loading branch information
robin-checkmk authored Oct 9, 2024
2 parents bce7606 + 585a317 commit ddd5b50
Show file tree
Hide file tree
Showing 12 changed files with 1,740 additions and 1 deletion.
77 changes: 77 additions & 0 deletions .github/workflows/ans-int-test-site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# README:
# - When changing the module name, it needs to be changed in 'env:MODULE_NAME' and in 'on:pull_requests:path'!
#
# Resources:
# - Template for this file: https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml
# - About Ansible integration tests: https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html

env:
NAMESPACE: checkmk
COLLECTION_NAME: general
MODULE_NAME: site

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Site Management Module
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
pull_request:
branches:
- main
- devel
paths:
- 'plugins/modules/site.py'
push:
paths:
- 'plugins/modules/site.py'

jobs:

integration:
runs-on: ubuntu-22.04
name: Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}
strategy:
fail-fast: false
matrix:
ansible:
- stable-2.15
- stable-2.16
- stable-2.17
- devel
python:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
exclude:
# Exclude unsupported sets.
- ansible: stable-2.15
python: '3.12'

steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check

- name: Provide secrets file
run: echo "${{ secrets.CHECKMK_DOWNLOAD_PW }}" > ./tests/integration/files/.dl-secret
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
env:
CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }}

- name: Run integration test
run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker default
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Name | Description | Tests
[checkmk.general.host](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/host.py)|Manage hosts.|[![Integration Tests for Host Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-host.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-host.yaml)
[checkmk.general.rule](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rule.py)|Manage rules.|[![Integration Tests for Rule Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-rule.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-rule.yaml)
[checkmk.general.service_group](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/service_group.py)|Manage service groups.|[![Integration Tests for Service Group Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-service_group.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-service_group.yaml)
[checkmk.general.site](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/site.py)|Manage sites.|[![Integration Tests for Site Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-site.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-site.yaml)
[checkmk.general.tag_group](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/tag_group.py)|Manage tag groups.|[![Integration Tests for Tag Group Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-tag_group.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-tag_group.yaml)
[checkmk.general.user](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/user.py)|Manage users.|[![Integration Tests for User Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-user.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-user.yaml)

Expand Down Expand Up @@ -152,7 +153,6 @@ Please do **not** consider it a concrete planning document!
- Setup
- Agents
- BI
- Distributed Monitoring
- Notification Rules
- OMD Module
Expand Down
9 changes: 9 additions & 0 deletions changelogs/fragments/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
major_changes:
- Site module - Added a module for distributed monitoring.
Refer to the module documentation for further details.

known_issues:
- Site module - To completely enable a site, the livestatus certificate
needs to be trusted. This cannot be done with the site module.
As of now, there is no automatic way to do this, so you need to log into
the site and add the certificate to the trusted certificates manually.
81 changes: 81 additions & 0 deletions playbooks/usecases/setup-distributed-monitoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
# This playbook uses the inventory from the 'playbooks/hosts' file and expects
# The VM 'debsible' to be running.

- name: "Install a Central and Remote Site and connect them."
hosts: debsible
strategy: linear
vars:
checkmk_server_version: "2.3.0p14"
checkmk_server_edition: "cre"
checkmk_server_admin_pass: "password"
checkmk_server_sites:
- name: central
version: "{{ checkmk_server_version }}"
state: started
admin_pw: "{{ checkmk_server_admin_pass }}"
update_conflict_resolution: install
- name: remote
version: "{{ checkmk_server_version }}"
state: started
admin_pw: "{{ checkmk_server_admin_pass }}"
update_conflict_resolution: install
omd_auto_restart: 'true'
omd_config:
- var: LIVESTATUS_TCP
value: "on"
- var: LIVESTATUS_TCP_TLS
value: "on"
- var: LIVESTATUS_TCP_PORT
value: "6558"
tasks:
- name: "Install Checkmk and create Sites."
ansible.builtin.import_role:
name: checkmk.general.server
- name: "Connect Central Site to Remote Site."
checkmk.general.site:
server_url: "http://localhost/"
site: "central"
automation_user: "cmkadmin"
automation_secret: "{{ checkmk_server_admin_pass }}"
site_id: "remote"
site_connection:
site_config:
status_connection:
connection:
socket_type: tcp
port: 6558
encrypted: true
host: localhost
verify: true
proxy:
use_livestatus_daemon: "direct"
connect_timeout: 2
status_host:
status_host_set: "disabled"
url_prefix: "/remote/"
configuration_connection:
enable_replication: true
url_of_remote_site: "http://localhost/remote/check_mk/"
basic_settings:
site_id: "remote"
alias: "My Remote Site"
state: "present"
- name: "Log in to Remote Site."
checkmk.general.site:
server_url: "http://localhost/"
site: "central"
automation_user: "cmkadmin"
automation_secret: "{{ checkmk_server_admin_pass }}"
site_id: "remote"
site_connection:
authentication:
username: "cmkadmin"
password: "{{ checkmk_server_admin_pass }}"
state: "login"
- name: "Activate Changes on all Sites."
checkmk.general.activation:
server_url: "http://localhost/"
site: "central"
automation_user: "cmkadmin"
automation_secret: "{{ checkmk_server_admin_pass }}"
Loading

0 comments on commit ddd5b50

Please sign in to comment.