Skip to content

Commit c1a69ed

Browse files
Merge pull request #854 from Checkmk/feature/dcd_module
Add the DCD module donated by Atruvia AG
2 parents ae6b174 + 4f302e5 commit c1a69ed

File tree

11 files changed

+912
-0
lines changed

11 files changed

+912
-0
lines changed

.github/labels-issues.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ module:bakery:
2323
module:contact_group:
2424
- 'Component Name: contact_group'
2525

26+
module:dcd:
27+
- 'Component Name: dcd'
28+
2629
module:discovery:
2730
- 'Component Name: discovery'
2831

.github/labels-prs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ module:contact_group:
3434
- changed-files:
3535
- any-glob-to-any-file: 'plugins/modules/contact_group.py'
3636

37+
module:dcd:
38+
- any:
39+
- changed-files:
40+
- any-glob-to-any-file: 'plugins/modules/dcd.py'
41+
3742
module:discovery:
3843
- any:
3944
- changed-files:
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# README:
2+
# - When changing the module name, it needs to be changed in 'env:MODULE_NAME' and in 'on:pull_requests:path'!
3+
#
4+
# Resources:
5+
# - Template for this file: https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml
6+
# - About Ansible integration tests: https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html
7+
8+
env:
9+
NAMESPACE: checkmk
10+
COLLECTION_NAME: general
11+
MODULE_NAME: dcd
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
name: Ansible Integration Tests for DCD Module
18+
on:
19+
workflow_dispatch:
20+
schedule:
21+
- cron: '0 0 * * 0'
22+
pull_request:
23+
branches:
24+
- main
25+
- devel
26+
paths:
27+
- 'plugins/modules/dcd.py'
28+
push:
29+
paths:
30+
- '.github/workflows/ans-int-test-dcd.yaml'
31+
- 'plugins/modules/dcd.py'
32+
- 'tests/integration/files/includes/'
33+
- 'tests/integration/targets/activation/'
34+
35+
jobs:
36+
37+
integration:
38+
runs-on: ubuntu-24.04
39+
name: Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
ansible:
44+
- stable-2.17
45+
- stable-2.18
46+
- stable-2.19
47+
- devel
48+
python:
49+
- '3.11'
50+
- '3.12'
51+
exclude:
52+
# Exclude unsupported sets.
53+
- ansible: devel
54+
python: '3.11'
55+
56+
services:
57+
old_cme:
58+
image: checkmk/check-mk-managed:2.3.0p38
59+
ports:
60+
- 5323:5000
61+
env:
62+
CMK_SITE_ID: "old_cme"
63+
CMK_PASSWORD: "Sup3rSec4et!"
64+
stable_cme:
65+
image: checkmk/check-mk-managed:2.4.0p13
66+
ports:
67+
- 5324:5000
68+
env:
69+
CMK_SITE_ID: "stable_cme"
70+
CMK_PASSWORD: "Sup3rSec4et!"
71+
72+
steps:
73+
- name: Check out code
74+
uses: actions/checkout@v5
75+
with:
76+
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
77+
78+
- name: "Install uv and set the python version."
79+
uses: astral-sh/setup-uv@v7
80+
with:
81+
python-version: ${{ matrix.python }}
82+
enable-cache: true
83+
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/
84+
85+
- name: "Setup uv venv."
86+
run: uv venv
87+
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
88+
89+
- name: Install ansible-base (${{ matrix.ansible }})
90+
run: uv pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz
91+
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
92+
93+
- name: Run integration test
94+
run: uv run ansible-test integration ${{env.MODULE_NAME}} -v --color --continue-on-error --diff --python ${{ matrix.python }}
95+
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}

changelogs/fragments/dcd.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- DCD module - Add DCD module.

meta/runtime.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ action_groups:
55
- activation
66
- bakery
77
- contact_group
8+
- dcd
89
- discovery
910
- downtime
1011
- folder

playbooks/demo/dcd.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
- name: "Showcase dcd module."
3+
hosts: test
4+
strategy: linear
5+
gather_facts: false
6+
vars_files:
7+
- ../vars/auth.yml # This vars file provides details about your site
8+
- ../vars/folders.yml # This vars file contains the folders to manage
9+
- ../vars/dcd.yml # This vars file contains the groups to manage
10+
tasks:
11+
# - name: "Gather Date and Time Facts on localhost."
12+
# ansible.builtin.setup:
13+
# gather_subset:
14+
# - date_time
15+
# delegate_to: localhost
16+
# run_once: true # noqa run-once[task]
17+
18+
- name: "Create folders."
19+
folder:
20+
server_url: "{{ checkmk_var_server_url }}"
21+
site: "{{ checkmk_var_site }}"
22+
automation_user: "{{ checkmk_var_automation_user }}"
23+
automation_secret: "{{ checkmk_var_automation_secret }}"
24+
path: "{{ item.path }}"
25+
name: "{{ item.name }}"
26+
state: "present"
27+
delegate_to: localhost
28+
run_once: true # noqa run-once[task]
29+
loop: "{{ checkmk_var_folders }}"
30+
31+
- name: "Create hosts."
32+
host:
33+
server_url: "{{ checkmk_var_server_url }}"
34+
site: "{{ checkmk_var_site }}"
35+
automation_user: "{{ checkmk_var_automation_user }}"
36+
automation_secret: "{{ checkmk_var_automation_secret }}"
37+
name: "{{ inventory_hostname }}"
38+
folder: "{{ checkmk_var_folder_path }}"
39+
attributes:
40+
site: "{{ checkmk_var_site }}"
41+
ipaddress: 127.0.0.1
42+
state: "present"
43+
delegate_to: localhost
44+
45+
- name: "Create DCD Configuration."
46+
dcd:
47+
server_url: "{{ checkmk_var_server_url }}"
48+
site: "{{ checkmk_var_site }}"
49+
automation_user: "{{ checkmk_var_automation_user }}"
50+
automation_secret: "{{ checkmk_var_automation_secret }}"
51+
dcd_config: "{{ item }}"
52+
state: "present"
53+
loop: "{{ checkmk_var_dcd }}"
54+
run_once: true # noqa run-once[task]
55+
delegate_to: localhost
56+
57+
- name: "Pause to review changes." # noqa name[unique]
58+
ansible.builtin.pause:
59+
prompt: |
60+
"Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}."
61+
"Press <Enter> to continue."
62+
when: not checkmk_var_run_unattended | bool
63+
64+
- name: "Activate changes on site." # noqa name[unique]
65+
activation:
66+
server_url: "{{ checkmk_var_server_url }}"
67+
site: "{{ checkmk_var_site }}"
68+
automation_user: "{{ checkmk_var_automation_user }}"
69+
automation_secret: "{{ checkmk_var_automation_secret }}"
70+
force_foreign_changes: 'true'
71+
sites:
72+
- "{{ checkmk_var_site }}"
73+
delegate_to: localhost
74+
run_once: true # noqa run-once[task]
75+
76+
- name: "Delete DCD Configuration."
77+
dcd:
78+
server_url: "{{ checkmk_var_server_url }}"
79+
site: "{{ checkmk_var_site }}"
80+
automation_user: "{{ checkmk_var_automation_user }}"
81+
automation_secret: "{{ checkmk_var_automation_secret }}"
82+
dcd_config: "{{ item }}"
83+
state: "absent"
84+
loop: "{{ checkmk_var_dcd }}"
85+
run_once: true # noqa run-once[task]
86+
delegate_to: localhost
87+
88+
- name: "Delete Hosts."
89+
host:
90+
server_url: "{{ checkmk_var_server_url }}"
91+
site: "{{ checkmk_var_site }}"
92+
automation_user: "{{ checkmk_var_automation_user }}"
93+
automation_secret: "{{ checkmk_var_automation_secret }}"
94+
name: "{{ inventory_hostname }}"
95+
folder: "{{ checkmk_var_folder_path }}"
96+
state: "absent"
97+
delegate_to: localhost
98+
99+
- name: "Delete folders."
100+
folder:
101+
server_url: "{{ checkmk_var_server_url }}"
102+
site: "{{ checkmk_var_site }}"
103+
automation_user: "{{ checkmk_var_automation_user }}"
104+
automation_secret: "{{ checkmk_var_automation_secret }}"
105+
path: "{{ item.path }}"
106+
name: "{{ item.name }}"
107+
state: "absent"
108+
delegate_to: localhost
109+
run_once: true # noqa run-once[task]
110+
loop: "{{ checkmk_var_folders }}"
111+
112+
- name: "Pause to review changes." # noqa name[unique]
113+
ansible.builtin.pause:
114+
prompt: |
115+
"Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}."
116+
"Press <Enter> to continue."
117+
when: not checkmk_var_run_unattended | bool
118+
119+
- name: "Activate changes on site." # noqa name[unique]
120+
activation:
121+
server_url: "{{ checkmk_var_server_url }}"
122+
site: "{{ checkmk_var_site }}"
123+
automation_user: "{{ checkmk_var_automation_user }}"
124+
automation_secret: "{{ checkmk_var_automation_secret }}"
125+
force_foreign_changes: 'true'
126+
sites:
127+
- "{{ checkmk_var_site }}"
128+
delegate_to: localhost
129+
run_once: true # noqa run-once[task]

playbooks/vars/dcd.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
checkmk_var_dcd:
3+
4+
- title: "vSphere"
5+
dcd_id: "vsphere"
6+
comment: "Main vSphere Connector"
7+
# site: "mysite"
8+
connector:
9+
connector_type: "piggyback"
10+
interval: 60
11+
creation_rules:
12+
- folder_path: "/"
13+
delete_hosts: false
14+
host_attributes:
15+
tag_address_family: "no-ip"
16+
tag_agent: "special-agents"
17+
tag_piggyback: "piggyback"
18+
tag_snmp_ds: "no-snmp"
19+
discover_on_creation: true
20+
restrict_source_hosts: "localhost"

0 commit comments

Comments
 (0)