Skip to content

Commit 2c462c0

Browse files
authored
Merge pull request #28 from T-Systems-MMS/ansible_icinga_role
Ansible icinga role
2 parents e9a32ce + 5c3d701 commit 2c462c0

19 files changed

Lines changed: 626 additions & 5 deletions

.yamllint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ rules:
1313
brackets:
1414
max-spaces-inside: 1
1515
level: error
16+
line-length:
17+
ignore: |
18+
roles/ansible-icinga/tasks

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ Icinga Director Collection for Ansible
22
=========
33

44
[![ci-ansible-test](https://github.com/T-Systems-MMS/ansible-collection-icinga-director/workflows/ansible-test/badge.svg)](https://github.com/T-Systems-MMS/ansible-collection-icinga-director/actions?query=workflow%3Aansible-test)
5-
[![ci-ansible-lint](https://github.com/T-Systems-MMS/ansible-collection-icinga-director/workflows/Ansible%20Lint/badge.svg)](https://github.com/T-Systems-MMS/ansible-collection-icinga-director/actions?query=workflow%3A%22Ansible+Lint%22)
65

7-
This collection contains Ansible modules to change objects in Icinga 2 using the director API.
6+
This collection contains Ansible [modules](plugins/modules/) and a [role](roles/ansible-icinga/) to change objects in Icinga 2 using the director API.
87

98
Required Ansible version: 2.9
109

@@ -42,8 +41,8 @@ collections:
4241
- t_systems_mms.icinga_director
4342
```
4443

45-
Examples
46-
--------
44+
Examples using the modules
45+
--------------------------
4746

4847
See the `examples` directory for a complete list of examples.
4948

@@ -69,6 +68,11 @@ See the `examples` directory for a complete list of examples.
6968
dnscheck: "no"
7069
```
7170

71+
Examples using the role
72+
-----------------------
73+
74+
Please see the [README](roles/ansible-icinga/README.md) of the role.
75+
7276
Troubleshooting
7377
---------------
7478

@@ -107,3 +111,4 @@ Author Information
107111

108112
* Sebastian Gumprich
109113
* Lars Krahl
114+
* Michaela Mattes

roles/ansible-icinga/README.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# Ansible Icinga
2+
3+
This role is used to configure an Icinga Instance over its Icinga Director.
4+
5+
## Installation
6+
7+
* create a `requirements.yml`:
8+
9+
```bash
10+
---
11+
collections:
12+
- name: t_systems_mms.icinga_director
13+
src: https://github.com/T-Systems-MMS/ansible-collection-icinga-director
14+
version: 1.2.2
15+
```
16+
17+
* install the collections:
18+
19+
```bash
20+
ansible-galaxy collection install -r requirements.yml -p collections/
21+
```
22+
23+
## Dependencies
24+
25+
collections:
26+
t_systems_mms.icinga_director >= 1.2.2
27+
28+
## Role Variables
29+
30+
| Variable | Required | Default
31+
|----------------------------|----------|---------
32+
| **icinga**
33+
| url | yes |
34+
| use_proxy | no |
35+
| validate_certs | no |
36+
| url_username | yes |
37+
| url_password | yes |
38+
| force_basic_auth | no |
39+
| client_cert | no |
40+
| client_key | no |
41+
| **icinga_timeperiod**
42+
| icinga_timeperiods | no | []
43+
| display_name | no |
44+
| imports | no |
45+
| ranges | no |
46+
| **icinga_user_template**
47+
| icinga_user_templates | no | []
48+
| imports | no |
49+
| period | no |
50+
| enable_notifications | no |
51+
| **icinga_user**
52+
| icinga_users | no | []
53+
| display_name | no |
54+
| imports | yes | []
55+
| pager | no |
56+
| period | no |
57+
| disabled | no |
58+
| email | yes | null
59+
| **icinga_hostgroup**
60+
| icinga_hostgroups | no | []
61+
| display_name | no |
62+
| assign_filter | no | `host.name="hostgroup.1-*"`
63+
| **icinga_host_template**
64+
| icinga_host_templates | no | []
65+
| display_name | no |
66+
| address | no |
67+
| groups | no |
68+
| check_command | no |
69+
| disabled | no |
70+
| imports | no |
71+
| zone | no |
72+
| vars | no |
73+
| **icinga_host**
74+
| icinga_hosts | no | []
75+
| display_name | no |
76+
| address | no |
77+
| groups | no |
78+
| disabled | no |
79+
| imports | yes | []
80+
| zone | no |
81+
| vars | no |
82+
| **icinga_command_template**
83+
| icinga_command_templates | no | []
84+
| display_name | no |
85+
| command | no |
86+
| methods_execute | yes | PluginCheck
87+
| timeout | no |
88+
| imports | no |
89+
| disabled | no |
90+
| zone | no |
91+
| vars | no |
92+
| arguments | no |
93+
| **icinga_command**
94+
| icinga_commands | no | []
95+
| command_type | yes | PluginCheck
96+
| disabled | yes | false
97+
| imports | no |
98+
| zone | no |
99+
| vars | no |
100+
| **icinga_service_template**
101+
| icinga_service_templates | no | []
102+
| display_name | no |
103+
| disabled | no |
104+
| check_command | no |
105+
| check_interval | no |
106+
| check_period | no |
107+
| check_timeout | no |
108+
| enable_active_checks | no |
109+
| enable_event_handler | no |
110+
| enable_notifications | no |
111+
| enable_passive_checks | no |
112+
| enable_perfdata | no |
113+
| groups | no |
114+
| imports | no |
115+
| max_check_attempts | no |
116+
| notes | no |
117+
| retry_interval | no |
118+
| use_agent | no |
119+
| vars | no |
120+
| volatile | no |
121+
| **icinga_service_apply**
122+
| icinga_service_applys | no | []
123+
| display_name | no |
124+
| groups | no |
125+
| apply_for | no |
126+
| assign_filter | no |
127+
| imports | no |
128+
| vars | no |
129+
| notes | no |
130+
| notes_url | no |
131+
| **icinga_servicegroup**
132+
| icinga_servicegroups | no | []
133+
| display_name | no |
134+
| assign_filter | no |
135+
| **icinga_notification**
136+
| icinga_notifications | no | []
137+
| notification_interval | no |
138+
| types | no |
139+
| users | no |
140+
| apply_to | no |
141+
| assign_filter | no |
142+
| imports | no |
143+
144+
## Example Playbook
145+
146+
```bash
147+
---
148+
- hosts: localhost
149+
gather_facts: false
150+
collections:
151+
- t_systems_mms.icinga_director
152+
roles:
153+
- ansible-icinga
154+
vars:
155+
icinga_url: "https://example.com"
156+
icinga_user: "{{ icinga_user }}"
157+
icinga_pass: "{{ icinga_pass }}"
158+
icinga_timeperiods:
159+
- timeperiod_object:
160+
- "8x5"
161+
ranges:
162+
monday: "09:00-17:00"
163+
tuesday: "09:00-17:00"
164+
wednesday: "09:00-17:00"
165+
thursday: "09:00-17:00"
166+
friday: "09:00-17:00"
167+
- timeperiod_object:
168+
- "24x7"
169+
ranges:
170+
monday: "00:00-24:00"
171+
tuesday: "00:00-24:00"
172+
wednesday: "00:00-24:00"
173+
thursday: "00:00-24:00"
174+
friday: "00:00-24:00"
175+
saturday: "00:00-24:00"
176+
sunday: "00:00-24:00"
177+
icinga_users:
178+
- user_object:
179+
- "service_abbreviation_email_24x7"
180+
pager: "SIP/xxx"
181+
email: "service_abbreviation@example.com"
182+
- user_object:
183+
- "service_abbreviation_8x5"
184+
email: "service_abbreviation@example.com"
185+
icinga_hostgroups:
186+
- hostgroup_object:
187+
- "service_abbreviation-environement"
188+
- "service_abbreviation-environement-web"
189+
icinga_hosts:
190+
- host_object:
191+
- "service_abbreviation-environement-web01"
192+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
# icinga_timeperiod
3+
icinga_timeperiods: []
4+
5+
# icinga_user_template
6+
icinga_user_templates: []
7+
8+
# icinga_user
9+
icinga_users: []
10+
icinga_user_imports: []
11+
icinga_user_disabled: false
12+
icinga_user_email: null
13+
14+
# icinga_hostgroup
15+
icinga_hostgroups: []
16+
17+
# icinga_host_template
18+
icinga_host_templates: []
19+
20+
# icinga_host
21+
icinga_hosts: []
22+
icinga_host_imports: []
23+
24+
# icinga_command_template
25+
icinga_command_templates: []
26+
icinga_command_template_command_type: PluginCheck
27+
28+
# icinga_command
29+
icinga_commands: []
30+
icinga_command_type: PluginCheck
31+
icinga_command_disabled: false
32+
33+
# icinga_service_template
34+
icinga_service_templates: []
35+
36+
# icinga_service_apply
37+
icinga_service_applies: []
38+
39+
# servicegroup
40+
icinga_sservicegroups: []
41+
42+
# icinga_notification
43+
icinga_notifications: []

roles/ansible-icinga/meta/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
collections:
3+
- t_systems_mms.icinga_director
4+
galaxy_info:
5+
author: t_systems_mms
6+
description: icinga configuration
7+
license: GPLv3
8+
min_ansible_version: 2.9
9+
galaxy_tags:
10+
- icinga
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# command.1 = command array
3+
# command.0 = icinga_command attribute
4+
- name: icinga_command
5+
icinga_command:
6+
url: "{{ icinga_url }}"
7+
use_proxy: "{{ icinga_use_proxy | default(omit) }}"
8+
validate_certs: "{{ icinga_validate_certs | default(omit) }}"
9+
url_username: "{{ icinga_user }}"
10+
url_password: "{{ icinga_pass }}"
11+
force_basic_auth: "{{ icinga_force_basic_auth | default(omit) }}"
12+
client_cert: "{{ icinga_client_cert | default(omit) }}"
13+
client_key: "{{ icinga_client_key | default(omit) }}"
14+
state: "{{ command.0.state | default(omit) }}"
15+
command: "{{ command.0 }}"
16+
command_type: "{{ command.0.command_type | default(icinga_command_type) }}"
17+
disabled: "{{ command.0.disabled | default(icinga_command_disabled) }}"
18+
object_name: "{{ command.0 }}"
19+
imports: "{{ command.0.imports | default(omit) }}"
20+
zone: "{{ command.0.zone | default(omit) }}"
21+
vars: "{{ command.0.vars | default(omit) }}"
22+
arguments: "{{ command.0.arguments | default(omit) }}"
23+
loop: "{{ icinga_commands|subelements('command_object') }}"
24+
loop_control:
25+
loop_var: command
26+
tags: command
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# command_template.1 = command_template array
3+
# command_template.0 = icinga_command_template attribute
4+
- name: icinga_command_template
5+
icinga_command_template:
6+
url: "{{ icinga_url }}"
7+
use_proxy: "{{ icinga_use_proxy | default(omit) }}"
8+
validate_certs: "{{ icinga_validate_certs | default(omit) }}"
9+
url_username: "{{ icinga_user }}"
10+
url_password: "{{ icinga_pass }}"
11+
force_basic_auth: "{{ icinga_force_basic_auth | default(omit) }}"
12+
client_cert: "{{ icinga_client_cert | default(omit) }}"
13+
client_key: "{{ icinga_client_key | default(omit) }}"
14+
state: "{{ command_template.0.state | default(omit) }}"
15+
object_name: "{{ command_template.1 }}"
16+
display_name: "{{ command_template.0.display_name | default(omit) }}"
17+
command: "{{ command_template.0.command | default(omit) }}"
18+
command_type: "{{ command_template.0.command_type | default(icinga_command_template_command_type) }}"
19+
timeout: "{{ command_template.0.timeout | default(omit) }}"
20+
imports: "{{ command_template.0.imports | default(omit) }}"
21+
disabled: "{{ command_template.0.disabled | default(omit) }}"
22+
zone: "{{ command_template.0.zone | default(omit) }}"
23+
vars: "{{ command_template.0.vars | default(omit) }}"
24+
arguments: "{{ command_template.0.arguments | default(omit) }}"
25+
loop: "{{ icinga_command_templates|subelements('command_template_object') }}"
26+
loop_control:
27+
loop_var: command_template
28+
tags: command_template
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# host.1 = host array
3+
# host.0 = icinga_host attribute
4+
- name: icinga_host
5+
icinga_host:
6+
url: "{{ icinga_url }}"
7+
use_proxy: "{{ icinga_use_proxy | default(omit) }}"
8+
validate_certs: "{{ icinga_validate_certs | default(omit) }}"
9+
url_username: "{{ icinga_user }}"
10+
url_password: "{{ icinga_pass }}"
11+
force_basic_auth: "{{ icinga_force_basic_auth | default(omit) }}"
12+
client_cert: "{{ icinga_client_cert | default(omit) }}"
13+
client_key: "{{ icinga_client_key | default(omit) }}"
14+
state: "{{ host.0.state | default(omit) }}"
15+
object_name: "{{ host.1 }}"
16+
display_name: "{{ host.0.display_name | default(omit) }}"
17+
address: "{{ host.0.address | default(omit) }}"
18+
groups: "{{ host.0.groups | default(omit) }}"
19+
disabled: "{{ host.0.disabled | default(omit) }}"
20+
imports: "{{ host.0.imports | default(icinga_host_imports) }}"
21+
zone: "{{ host.0.zone | default(omit) }}"
22+
vars: "{{ host.0.vars | default(omit) }}"
23+
loop: "{{ icinga_hosts|subelements('host_object') }}"
24+
loop_control:
25+
loop_var: host
26+
tags: host

0 commit comments

Comments
 (0)