Skip to content

Commit aaa12d8

Browse files
authored
Merge pull request #56 from mmslkr/feature/notes
Add support for notes and notes_url to all relevant objects
2 parents d98942a + e519dbd commit aaa12d8

9 files changed

Lines changed: 72 additions & 2 deletions

File tree

plugins/modules/icinga_host.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@
151151
you still have to supply a check_command in a host or host-template
152152
required: false
153153
type: str
154+
notes:
155+
description:
156+
- Additional notes for this object
157+
required: false
158+
type: str
159+
notes_url:
160+
description:
161+
- An URL pointing to additional notes for this object.
162+
- Separate multiple urls like this "'http://url1' 'http://url2'".
163+
- Max length 255 characters
164+
required: false
165+
type: str
154166
"""
155167

156168
EXAMPLES = """
@@ -172,6 +184,8 @@
172184
vars:
173185
dnscheck: "no"
174186
check_command: hostalive
187+
notes: "example note"
188+
notes_url: "'http://url1' 'http://url2'"
175189
"""
176190

177191
from ansible.module_utils.basic import AnsibleModule
@@ -204,6 +218,8 @@ def main():
204218
zone=dict(required=False, default=None),
205219
vars=dict(type="dict", default=None),
206220
check_command=dict(required=False),
221+
notes=dict(type="str", required=False),
222+
notes_url=dict(type="str", required=False),
207223
)
208224

209225
# When deleting objects, only the name is necessary, so we cannot use
@@ -230,6 +246,8 @@ def main():
230246
"zone": module.params["zone"],
231247
"vars": module.params["vars"],
232248
"check_command": module.params["check_command"],
249+
"notes": module.params["notes"],
250+
"notes_url": module.params["notes_url"],
233251
}
234252

235253
icinga_object = Icinga2APIObject(module=module, path="/host", data=data)

plugins/modules/icinga_host_template.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@
152152
- Custom properties of the host
153153
required: false
154154
type: "dict"
155+
notes:
156+
description:
157+
- Additional notes for this object
158+
required: false
159+
type: str
160+
notes_url:
161+
description:
162+
- An URL pointing to additional notes for this object.
163+
- Separate multiple urls like this "'http://url1' 'http://url2'".
164+
- Max length 255 characters
165+
required: false
166+
type: str
155167
"""
156168

157169
EXAMPLES = """
@@ -169,6 +181,8 @@
169181
- "foohostgroup"
170182
imports:
171183
- ''
184+
notes: "example note"
185+
notes_url: "'http://url1' 'http://url2'"
172186
"""
173187

174188
from ansible.module_utils.basic import AnsibleModule
@@ -201,6 +215,8 @@ def main():
201215
address6=dict(required=False),
202216
zone=dict(required=False, default=None),
203217
vars=dict(type="dict", default=None),
218+
notes=dict(type="str", required=False),
219+
notes_url=dict(type="str", required=False),
204220
)
205221

206222
# Define the main module
@@ -220,6 +236,8 @@ def main():
220236
"address6": module.params["address6"],
221237
"zone": module.params["zone"],
222238
"vars": module.params["vars"],
239+
"notes": module.params["notes"],
240+
"notes_url": module.params["notes_url"],
223241
}
224242

225243
icinga_object = Icinga2APIObject(module=module, path="/host", data=data)

plugins/modules/icinga_service.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@
172172
- Additional notes for this object
173173
required: false
174174
type: str
175+
notes_url:
176+
description:
177+
- An URL pointing to additional notes for this object.
178+
- Separate multiple urls like this "'http://url1' 'http://url2'".
179+
- Max length 255 characters
180+
required: false
181+
type: str
175182
retry_interval:
176183
description:
177184
- Retry interval, will be applied after a state change unless the next hard state is reached
@@ -217,6 +224,8 @@
217224
procs_argument: consul
218225
procs_critical: '1:'
219226
procs_warning: '1:'
227+
notes: "example note"
228+
notes_url: "'http://url1' 'http://url2'"
220229
"""
221230

222231
from ansible.module_utils.basic import AnsibleModule
@@ -336,7 +345,8 @@ def main():
336345
groups=dict(type="list", elements="str", default=[], required=False),
337346
imports=dict(type="list", elements="str", default=[], required=False),
338347
max_check_attempts=dict(required=False),
339-
notes=dict(required=False),
348+
notes=dict(type="str", required=False),
349+
notes_url=dict(type="str", required=False),
340350
retry_interval=dict(required=False),
341351
use_agent=dict(type="bool", required=False),
342352
vars=dict(type="dict", default={}, required=False),
@@ -366,6 +376,7 @@ def main():
366376
"imports": module.params["imports"],
367377
"max_check_attempts": module.params["max_check_attempts"],
368378
"notes": module.params["notes"],
379+
"notes_url": module.params["notes_url"],
369380
"retry_interval": module.params["retry_interval"],
370381
"use_agent": module.params["use_agent"],
371382
"vars": module.params["vars"],

plugins/modules/icinga_service_template.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@
167167
- Additional notes for this object
168168
required: false
169169
type: str
170+
notes_url:
171+
description:
172+
- An URL pointing to additional notes for this object.
173+
- Separate multiple urls like this "'http://url1' 'http://url2'".
174+
- Max length 255 characters
175+
required: false
176+
type: str
170177
retry_interval:
171178
description:
172179
- Retry interval, will be applied after a state change unless the next hard state is reached
@@ -209,6 +216,8 @@
209216
procs_argument: consul
210217
procs_critical: '1:'
211218
procs_warning: '1:'
219+
notes: "example note"
220+
notes_url: "'http://url1' 'http://url2'"
212221
"""
213222

214223
from ansible.module_utils.basic import AnsibleModule
@@ -245,7 +254,8 @@ def main():
245254
groups=dict(type="list", elements="str", default=[], required=False),
246255
imports=dict(type="list", elements="str", default=[], required=False),
247256
max_check_attempts=dict(required=False),
248-
notes=dict(required=False),
257+
notes=dict(type="str", required=False),
258+
notes_url=dict(type="str", required=False),
249259
retry_interval=dict(required=False),
250260
use_agent=dict(type="bool", required=False),
251261
vars=dict(type="dict", default={}, required=False),
@@ -274,6 +284,7 @@ def main():
274284
"imports": module.params["imports"],
275285
"max_check_attempts": module.params["max_check_attempts"],
276286
"notes": module.params["notes"],
287+
"notes_url": module.params["notes_url"],
277288
"retry_interval": module.params["retry_interval"],
278289
"use_agent": module.params["use_agent"],
279290
"vars": module.params["vars"],

roles/ansible_icinga/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ t_systems_mms.icinga_director >= 1.2.2
8181
| imports | no |
8282
| zone | no |
8383
| vars | no |
84+
| notes | no |
85+
| notes_url | no |
8486
| **icinga_host**
8587
| icinga_hosts | no | []
8688
| display_name | no |
@@ -91,6 +93,8 @@ t_systems_mms.icinga_director >= 1.2.2
9193
| imports | yes | []
9294
| zone | no |
9395
| vars | no |
96+
| notes | no |
97+
| notes_url | no |
9498
| **icinga_command_template**
9599
| icinga_command_templates | no | []
96100
| display_name | no |
@@ -127,6 +131,7 @@ t_systems_mms.icinga_director >= 1.2.2
127131
| imports | no |
128132
| max_check_attempts | no |
129133
| notes | no |
134+
| notes_url | no |
130135
| retry_interval | no |
131136
| use_agent | no |
132137
| vars | no |
@@ -148,6 +153,7 @@ t_systems_mms.icinga_director >= 1.2.2
148153
| imports | no |
149154
| max_check_attempts | no |
150155
| notes | no |
156+
| notes_url | no |
151157
| retry_interval | no |
152158
| use_agent | no |
153159
| vars | no |

roles/ansible_icinga/tasks/icinga_host.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
imports: "{{ host.0.imports | default(icinga_host_imports) }}"
2222
zone: "{{ host.0.zone | default(omit) }}"
2323
vars: "{{ host.0.vars | default(omit) }}"
24+
notes: "{{ host.0.notes | default(omit) }}"
25+
notes_url: "{{ host.0.notes_url | default(omit) }}"
2426
loop: "{{ icinga_hosts|subelements('host_object') }}"
2527
loop_control:
2628
loop_var: host

roles/ansible_icinga/tasks/icinga_host_template.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
imports: "{{ host_template.0.imports | default(omit) }}"
2323
zone: "{{ host_template.0.zone | default(omit) }}"
2424
vars: "{{ host_template.0.vars | default(omit) }}"
25+
notes: "{{ host_template.0.notes | default(omit) }}"
26+
notes_url: "{{ host_template.0.notes_url | default(omit) }}"
2527
loop: "{{ icinga_host_templates|subelements('host_template_object') }}"
2628
loop_control:
2729
loop_var: host_template

roles/ansible_icinga/tasks/icinga_service.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
imports: "{{ service.0.imports | default(omit) }}"
3030
max_check_attempts: "{{ service.0.max_check_attempts | default(omit) }}"
3131
notes: "{{ service.0.notes | default(omit) }}"
32+
notes_url: "{{ service.0.notes_url | default(omit) }}"
3233
retry_interval: "{{ service.0.retry_interval | default(omit) }}"
3334
use_agent: "{{ service.0.use_agent | default(omit) }}"
3435
vars: "{{ service.0.vars | default(omit) }}"

roles/ansible_icinga/tasks/icinga_service_template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
imports: "{{ service_template.0.imports | default(omit) }}"
2929
max_check_attempts: "{{ service_template.0.max_check_attempts | default(omit) }}"
3030
notes: "{{ service_template.0.notes | default(omit) }}"
31+
notes_url: "{{ service_template.0.notes_url | default(omit) }}"
3132
retry_interval: "{{ service_template.0.retry_interval | default(omit) }}"
3233
use_agent: "{{ service_template.0.use_agent | default(omit) }}"
3334
vars: "{{ service_template.0.vars | default(omit) }}"

0 commit comments

Comments
 (0)