Skip to content

Commit 17038da

Browse files
Merge pull request #204 from tribe29/devel
Release 0.14.0
2 parents 8db342f + 2518769 commit 17038da

File tree

11 files changed

+96
-69
lines changed

11 files changed

+96
-69
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Major Changes
1616
Minor Changes
1717
-------------
1818

19-
- Agent role - Now supports new password hashing according to L(Werk 14391,https://checkmk.com/werk/14391)
19+
- Agent role - Now supports new password hashing according to Werk 14391: https://checkmk.com/werk/14391
2020

2121
v0.12.0
2222
=======

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ Name | Description
6262
Name | Description | Tests
6363
--- | --- | ---
6464
[tribe29.checkmk.activation](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/activation.py)|Activate changes.|[![Integration Tests for Activation Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-activation.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-activation.yaml)
65+
[tribe29.checkmk.contact_group](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/contact_group.py)|Manage contact groups.|[![Integration Tests for Contact Group Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-contact_group.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-contact_group.yaml)
6566
[tribe29.checkmk.discovery](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/discovery.py)|Discover services on hosts.|[![Integration Tests for Discovery Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-discovery.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-discovery.yaml)
6667
[tribe29.checkmk.downtime](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/downtime.py)|Schedule downtimes on hosts and services.|[![Integration Tests for Downtime Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-downtime.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-downtime.yaml)
6768
[tribe29.checkmk.folder](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/folder.py)|Manage folders.|[![Integration Tests for Folder Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-folder.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-folder.yaml)
69+
[tribe29.checkmk.host_group](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/host_group.py)|Manage host groups.|[![Integration Tests for Host Group Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-host_group.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-host_group.yaml)
6870
[tribe29.checkmk.host](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/host.py)|Manage hosts.|[![Integration Tests for Host Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-host.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-host.yaml)
6971
[tribe29.checkmk.rule](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/rule.py)|Manage rules.|[![Integration Tests for Rule Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-rule.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-rule.yaml)
72+
[tribe29.checkmk.service_group](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/service_group.py)|Manage service groups.|[![Integration Tests for Service Group Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-service_group.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-service_group.yaml)
73+
[tribe29.checkmk.tag_group](https://github.com/tribe29/ansible-collection-tribe29.checkmk/blob/main/plugins/modules/tag_group.py)|Manage tag groups.|[![Integration Tests for Tag Group Module](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-tag_group.yaml/badge.svg)](https://github.com/tribe29/ansible-collection-tribe29.checkmk/actions/workflows/ans-int-test-tag_group.yaml)
7074

7175
### Roles
7276
Name | Description | Tests

SECURITY.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Security Policy
22

3+
## Disambiguation
4+
This policy solely applies to the Checkmk Ansible Collection, not Checkmk itself!
5+
For Checkmk itself, please refer to [this Vulnerability disclosure policy](https://checkmk.com/responsible-disclosure-policy)
36
## Supported Versions
47

58
Please always use the latest available version!
6-
Versions in here are used solely for stability, so your Ansible configuration
9+
Versions in this repository are used solely for stability, so your Ansible configuration
710
does not break.
811
However, we cannot and will not support older versions, especially security-wise.
912
If you find a vulnerability, please report it as stated below,

SUPPORT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ Collection Version | Checkmk Versions | Remarks
1515
--- | --- | ---
1616
0.12.0 | 2.1.0p11, 2.0.0p28 | None
1717
0.13.0 | 2.1.0p17, 2.0.0p31 | None
18+
0.14.0 | 2.1.0p17, 2.0.0p31 | None

changelogs/archive/0.13.0/new-passwd-hashing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to
22

33
minor_changes:
4-
- Agent role - Now supports new password hashing according to L(Werk 14391,https://checkmk.com/werk/14391)
4+
- Agent role - Now supports new password hashing according to Werk 14391: https://checkmk.com/werk/14391
55

66
## Line Format
77

changelogs/changelog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ releases:
117117
major_changes:
118118
- Add service_group module.
119119
minor_changes:
120-
- Agent role - Now supports new password hashing according to L(Werk 14391,https://checkmk.com/werk/14391)
120+
- Agent role - Now supports new password hashing according to Werk 14391: https://checkmk.com/werk/14391
121121
fragments:
122122
- new-passwd-hashing.yml
123123
- service_group_module.yml

galaxy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name: checkmk
1010

1111
# The version of the collection. Must be compatible with semantic versioning
1212

13-
version: 0.13.0
13+
version: 0.14.0
1414

1515
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
1616
readme: README.md
@@ -37,7 +37,7 @@ license_file: LICENSE
3737

3838
# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
3939
# requirements as 'namespace' and 'name'
40-
tags: [tribe29, checkmk, monitoring]
40+
tags: [tribe29, checkmk, monitoring, check_mk, check, discovery]
4141

4242
# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
4343
# collection label 'namespace.name'. The value is a version range

plugins/modules/host_group.py

Lines changed: 65 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,20 @@
2424
extends_documentation_fragment: [tribe29.checkmk.common]
2525
2626
options:
27-
host_group_name:
27+
name:
2828
description: The name of the host group to be created/modified/deleted.
2929
type: str
30+
aliases: [host_group_name]
3031
title:
31-
description: The title (alias) of your host group. If omitted defaults to the host_group_name.
32+
description: The title (alias) of your host group. If omitted defaults to the name.
3233
type: str
33-
host_groups:
34+
groups:
3435
description:
35-
- instead of 'host_group_name', 'title' a list of dicts with elements of host group name and title (alias) to be created/modified/deleted.
36+
- instead of 'name', 'title' a list of dicts with elements of host group name and title (alias) to be created/modified/deleted.
3637
If title is omitted in entry, it defaults to the host group name.
3738
default: []
3839
type: raw
40+
aliases: [host_groups]
3941
state:
4042
description: The state of your host group.
4143
type: str
@@ -54,7 +56,7 @@
5456
site: "my_site"
5557
automation_user: "automation"
5658
automation_secret: "$SECRET"
57-
host_group_name: "my_host_group"
59+
name: "my_host_group"
5860
title: "My Host Group"
5961
state: "present"
6062
@@ -65,7 +67,7 @@
6567
site: "my_site"
6668
automation_user: "automation"
6769
automation_secret: "$SECRET"
68-
host_groups:
70+
groups:
6971
- name: "my_host_group_one"
7072
title: "My Host Group One"
7173
- name: "my_host_group_two"
@@ -81,7 +83,7 @@
8183
site: "my_site"
8284
automation_user: "automation"
8385
automation_secret: "$SECRET"
84-
host_groups:
86+
groups:
8587
- name: "my_host_group_one"
8688
title: "My Host Group One"
8789
- name: "my_host_group_two"
@@ -95,7 +97,7 @@
9597
site: "my_site"
9698
automation_user: "automation"
9799
automation_secret: "$SECRET"
98-
host_group_name: "my_host_group"
100+
name: "my_host_group"
99101
state: "absent"
100102
101103
# Delete several host groups.
@@ -105,7 +107,7 @@
105107
site: "my_site"
106108
automation_user: "automation"
107109
automation_secret: "$SECRET"
108-
host_groups:
110+
groups:
109111
- name: "my_host_group_one"
110112
- name: "my_host_group_two"
111113
state: "absent"
@@ -145,9 +147,9 @@ def get_current_single_host_group(module, base_url, headers):
145147
current_state = "unknown"
146148
current_title = ""
147149
etag = ""
148-
host_group_name = module.params["host_group_name"]
150+
name = module.params["name"]
149151

150-
api_endpoint = "/objects/host_group_config/" + host_group_name
152+
api_endpoint = "/objects/host_group_config/" + name
151153
url = base_url + api_endpoint
152154

153155
response, info = fetch_url(module, url, data=None, headers=headers, method="GET")
@@ -156,7 +158,7 @@ def get_current_single_host_group(module, base_url, headers):
156158
body = json.loads(response.read())
157159
current_state = "present"
158160
etag = info.get("etag", "")
159-
current_title = body.get("title", host_group_name)
161+
current_title = body.get("title", name)
160162

161163
elif info["status"] == 404:
162164
current_state = "absent"
@@ -200,11 +202,11 @@ def get_current_host_groups(module, base_url, headers):
200202

201203

202204
def update_single_host_group(module, base_url, headers):
203-
host_group_name = module.params["host_group_name"]
205+
name = module.params["name"]
204206

205-
api_endpoint = "/objects/host_group_config/" + host_group_name
207+
api_endpoint = "/objects/host_group_config/" + name
206208
params = {
207-
"alias": module.params.get("title", host_group_name),
209+
"alias": module.params.get("title", name),
208210
}
209211
url = base_url + api_endpoint
210212

@@ -220,7 +222,7 @@ def update_single_host_group(module, base_url, headers):
220222
)
221223

222224

223-
def update_host_groups(module, base_url, host_groups, headers):
225+
def update_host_groups(module, base_url, groups, headers):
224226
api_endpoint = "/domain-types/host_group_config/actions/bulk-update/invoke"
225227
params = {
226228
"entries": [
@@ -230,7 +232,7 @@ def update_host_groups(module, base_url, host_groups, headers):
230232
"alias": el.get("title", el.get("name")),
231233
},
232234
}
233-
for el in host_groups
235+
for el in groups
234236
],
235237
}
236238
url = base_url + api_endpoint
@@ -248,12 +250,12 @@ def update_host_groups(module, base_url, host_groups, headers):
248250

249251

250252
def create_single_host_group(module, base_url, headers):
251-
host_group_name = module.params["host_group_name"]
253+
name = module.params["name"]
252254

253255
api_endpoint = "/domain-types/host_group_config/collections/all"
254256
params = {
255-
"name": host_group_name,
256-
"alias": module.params.get("title", host_group_name),
257+
"name": name,
258+
"alias": module.params.get("title", name),
257259
}
258260
url = base_url + api_endpoint
259261

@@ -269,15 +271,15 @@ def create_single_host_group(module, base_url, headers):
269271
)
270272

271273

272-
def create_host_groups(module, base_url, host_groups, headers):
274+
def create_host_groups(module, base_url, groups, headers):
273275
api_endpoint = "/domain-types/host_group_config/actions/bulk-create/invoke"
274276
params = {
275277
"entries": [
276278
{
277279
"name": el.get("name"),
278280
"alias": el.get("title", el.get("name")),
279281
}
280-
for el in host_groups
282+
for el in groups
281283
],
282284
}
283285
url = base_url + api_endpoint
@@ -295,7 +297,7 @@ def create_host_groups(module, base_url, host_groups, headers):
295297

296298

297299
def delete_single_host_group(module, base_url, headers):
298-
api_endpoint = "/objects/host_group_config/" + module.params["host_group_name"]
300+
api_endpoint = "/objects/host_group_config/" + module.params["name"]
299301
url = base_url + api_endpoint
300302

301303
response, info = fetch_url(module, url, data=None, headers=headers, method="DELETE")
@@ -308,10 +310,10 @@ def delete_single_host_group(module, base_url, headers):
308310
)
309311

310312

311-
def delete_host_groups(module, base_url, host_groups, headers):
313+
def delete_host_groups(module, base_url, groups, headers):
312314
api_endpoint = "/domain-types/host_group_config/actions/bulk-delete/invoke"
313315
params = {
314-
"entries": [el["name"] for el in host_groups],
316+
"entries": [el["name"] for el in groups],
315317
}
316318
url = base_url + api_endpoint
317319

@@ -334,19 +336,42 @@ def run_module():
334336
validate_certs=dict(type="bool", required=False, default=True),
335337
automation_user=dict(type="str", required=True),
336338
automation_secret=dict(type="str", required=True, no_log=True),
337-
host_group_name=dict(type="str", required=False),
339+
name=dict(
340+
type="str",
341+
required=False,
342+
aliases=["host_group_name"],
343+
deprecated_aliases=[
344+
{
345+
"name": "host_group_name",
346+
"date": "2023-03-01",
347+
"collection_name": "tribe29.checkmk",
348+
}
349+
],
350+
),
338351
title=dict(type="str", required=False),
339-
host_groups=dict(type="raw", required=False, default=[]),
352+
groups=dict(
353+
type="raw",
354+
required=False,
355+
default=[],
356+
aliases=["host_groups"],
357+
deprecated_aliases=[
358+
{
359+
"name": "host_groups",
360+
"date": "2023-03-01",
361+
"collection_name": "tribe29.checkmk",
362+
}
363+
],
364+
),
340365
state=dict(type="str", default="present", choices=["present", "absent"]),
341366
)
342367

343368
module = AnsibleModule(
344369
argument_spec=module_args,
345370
mutually_exclusive=[
346-
("host_groups", "host_group_name"),
371+
("groups", "name"),
347372
],
348373
required_one_of=[
349-
("host_groups", "host_group_name"),
374+
("groups", "name"),
350375
],
351376
supports_check_mode=False,
352377
)
@@ -371,31 +396,29 @@ def run_module():
371396
state = module.params.get("state", "present")
372397

373398
if (
374-
"host_groups" in module.params
375-
and module.params.get("host_groups")
376-
and len(module.params.get("host_groups", [])) > 0
399+
"groups" in module.params
400+
and module.params.get("groups")
401+
and len(module.params.get("groups", [])) > 0
377402
):
378403
if "title" in module.params and module.params.get("title", ""):
379404
exit_failed(
380405
module,
381-
"'title' has only effect when 'host_group_name' is defined and not 'host_groups'",
406+
"'title' has only effect when 'name' (deprecated alias 'host_group_name') is defined and not 'groups' (deprecated alias 'host_groups')",
382407
)
383408

384-
host_groups = module.params.get("host_groups")
409+
groups = module.params.get("groups")
385410

386-
# Determine which host groups do already exest
411+
# Determine which host groups do already exist
387412
current_groups = get_current_host_groups(module, base_url, headers)
388413

389414
# Determine intersection and difference with input, according to 'name' only
390-
if len(set([el.get("name") for el in host_groups])) != len(host_groups):
415+
if len(set([el.get("name") for el in groups])) != len(groups):
391416
exit_failed(module, "two or more entries with the same name!")
392417

393418
listofnames = set([el.get("name") for el in current_groups])
394419

395-
intersection_list = [el for el in host_groups if el.get("name") in listofnames]
396-
difference_list = [
397-
el for el in host_groups if not el.get("name") in listofnames
398-
]
420+
intersection_list = [el for el in groups if el.get("name") in listofnames]
421+
difference_list = [el for el in groups if not el.get("name") in listofnames]
399422

400423
# Handle the host group accordingly to above findings and desired state
401424
if state == "present":
@@ -452,9 +475,7 @@ def run_module():
452475

453476
else:
454477
exit_failed(module, "Unknown error")
455-
elif "host_group_name" in module.params and module.params.get(
456-
"host_group_name", ""
457-
):
478+
elif "name" in module.params and module.params.get("name", ""):
458479
# Determine the current state of this particular host group
459480
(
460481
current_state,
@@ -490,9 +511,7 @@ def run_module():
490511
else:
491512
exit_failed(module, "Unknown error")
492513
else:
493-
exit_failed(
494-
module, "One shoudl define either 'host_groups' or 'host_group_name'"
495-
)
514+
exit_failed(module, "One should define either 'groups' or 'name'")
496515

497516

498517
def main():

plugins/modules/service_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def run_module():
340340
automation_secret=dict(type="str", required=True, no_log=True),
341341
name=dict(type="str", required=False),
342342
title=dict(type="str", required=False),
343-
groups=dict(type="raw", required=False),
343+
groups=dict(type="raw", required=False, default=[]),
344344
state=dict(type="str", default="present", choices=["present", "absent"]),
345345
)
346346

requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
collections:
33
- name: tribe29.checkmk
4-
version: 0.13.0
4+
version: 0.14.0

0 commit comments

Comments
 (0)