Skip to content

Commit 55f6421

Browse files
authored
Merge pull request #24 from T-Systems-MMS/integrationtesting
Integration testing
2 parents 8d9badd + 550ad64 commit 55f6421

40 files changed

Lines changed: 482 additions & 99 deletions

.github/workflows/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,25 @@ jobs:
3939

4040
- name: Run tox linting
4141
run: tox -elinters
42+
43+
integration-tests:
44+
runs-on: ubuntu-latest
45+
container: rndmh3ro/docker-centos8-ansible:latest
46+
services:
47+
icinga:
48+
image: jordan/icinga2
49+
ports:
50+
- 80:80
51+
steps:
52+
- name: Check out code
53+
uses: actions/checkout@v2
54+
55+
- name: Check out code to collections-folder, so ansible finds it
56+
uses: actions/checkout@v2
57+
with:
58+
path: ansible-collection-icinga-director/collections/ansible_collections/t_systems_mms/icinga_director
59+
60+
- name: Run integration tests
61+
run: ansible-playbook tests/integration/test.yml --diff -v
62+
env:
63+
ANSIBLE_COLLECTIONS_PATHS: ansible-collection-icinga-director/collections/:../../ansible-collection-icinga-director/collections/:collections/

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ If the following error is thrown, check if you're behind a proxy and use `force_
7878
fatal: [localhost]: FAILED! => {"changed": false, "msg": "bad return code while creating: -1. Error message: Request failed: <urlopen error Tunnel connection failed: 302 Found>"}
7979
```
8080

81+
Local Testing
82+
-------------
83+
84+
* Linting with tox
85+
86+
```
87+
> tox -elinters
88+
```
89+
90+
* Integration tests with docker
91+
92+
```
93+
# run icinga in a container and forward port 80
94+
> docker run -it -p 80:80 jordan/icinga2
95+
96+
# run the ansible-playbook against the container
97+
> ansible-playbook tests/integration/test.yml -e icinga_url=http://127.0.0.1/icingaweb2
98+
```
99+
81100
License
82101
-------
83102

examples/icinga_command.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- name: create command
33
icinga_command:
44
state: present
5-
url: "https://example.com"
5+
url: "{{ icinga_url }}"
66
url_username: "{{ icinga_user }}"
77
url_password: "{{ icinga_pass }}"
88
arguments:
@@ -41,8 +41,12 @@
4141
'--warning':
4242
value: $centreon_warning$
4343
command: "/opt/centreon-plugins/centreon_plugins.pl"
44-
object_name: centreon-plugins-neu
44+
command_type: "PluginCheck"
4545
disabled: false
46+
object_name: centreon-plugins
47+
imports:
48+
- centreon-plugins-template
49+
timeout: "1m"
4650
vars:
4751
centreon_maxrepetitions: 20
4852
centreon_subsetleef: 20

examples/icinga_command_template.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- name: create command template
33
icinga_command_template:
44
state: present
5-
url: "https://example.com"
5+
url: "{{ icinga_url }}"
66
url_username: "{{ icinga_user }}"
77
url_password: "{{ icinga_pass }}"
88
arguments:
@@ -41,7 +41,9 @@
4141
'--warning':
4242
value: $centreon_warning$
4343
command: "/opt/centreon-plugins/centreon_plugins.pl"
44-
object_name: centreon-plugins-neu
44+
command_type: "PluginCheck"
45+
object_name: centreon-plugins-template
46+
timeout: "2m"
4547
disabled: false
4648
vars:
4749
centreon_maxrepetitions: 20

examples/icinga_host.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
- name: create a host in icinga
33
icinga_host:
44
state: present
5-
url: "https://example.com"
5+
url: "{{ icinga_url }}"
66
url_username: "{{ icinga_user }}"
77
url_password: "{{ icinga_pass }}"
8-
object_name: "{{ ansible_hostname }}"
9-
address: "{{ ansible_default_ipv4.address }}"
10-
display_name: "{{ ansible_hostname }}"
8+
disabled: false
9+
object_name: "foohost"
10+
address: "127.0.0.1"
11+
display_name: "foohost"
1112
groups:
12-
- "foo"
13+
- "foohostgroup"
1314
imports:
14-
- "StandardServer"
15+
- "foohosttemplate"
1516
vars:
1617
dnscheck: "no"
18+
check_command: dummy_check

examples/icinga_host_template.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
22
- name: create host template
3-
tags: hosttemplate
43
icinga_host_template:
54
state: present
6-
url: "https://example.com"
5+
url: "{{ icinga_url }}"
76
url_username: "{{ icinga_user }}"
87
url_password: "{{ icinga_pass }}"
9-
object_name: template-empty-host
10-
display_name: template-empty-host
8+
object_name: foohosttemplate
9+
display_name: foohosttemplate
10+
disabled: false
11+
check_command: dummy
12+
groups:
13+
- "foohostgroup"
1114
imports:
1215
- ''
13-
check_command: dummy

examples/icinga_hostgroup.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
- name: create hostgroup
33
icinga_hostgroup:
44
state: present
5-
url: "https://example.com"
5+
url: "{{ icinga_url }}"
66
url_username: "{{ icinga_user }}"
77
url_password: "{{ icinga_pass }}"
8-
object_name: customer-hostgroup
9-
assign_filter: 'host.name="cust-*"'
8+
object_name: foohostgroup
9+
display_name: foohostgroup
10+
assign_filter: 'host.name="foohost"'

examples/icinga_notification.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
- name: create notification
33
icinga_notification:
44
state: present
5-
url: "https://example.com"
5+
url: "{{ icinga_url }}"
66
url_username: "{{ icinga_user }}"
77
url_password: "{{ icinga_pass }}"
88
apply_to: host
9-
assign_filter: '"ABLE_E-Mail"=host.vars.enabled_notifications'
9+
assign_filter: 'host.name="foohost"'
1010
imports:
11-
- host
11+
- foonotificationtemplate
1212
notification_interval: '0'
13-
object_name: able_E-Mail_host
13+
object_name: E-Mail_host
1414
types:
1515
- Problem
1616
- Recovery
1717
users:
18-
- ABLE_E-Mail
18+
- rb

examples/icinga_service_apply.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
- name: Add service apply rule to icinga
33
icinga_service_apply:
44
state: present
5-
url: "https://example.com"
6-
url_username: ""
7-
url_password: ""
8-
object_name: "SERVICE_promtail"
9-
assign_filter: 'host.vars.HostOS="Linux"&host.name="sbk-pilot-api*'
5+
url: "{{ icinga_url }}"
6+
url_username: "{{ icinga_user }}"
7+
url_password: "{{ icinga_pass }}"
8+
object_name: "SERVICE_dummy"
9+
assign_filter: 'host.vars.HostOS="Linux"'
1010
apply_for: "host.vars.enabled_notifications"
11-
display_name: "Promtail process"
11+
display_name: "dummy process"
1212
imports:
13-
- http
13+
- fooservicetemplate
1414
groups:
15-
- sbk
15+
- fooservicegroup
1616
vars:
1717
http_address: "$address$"
1818
http_port: "9080"

examples/icinga_service_template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
- name: create servicetemplate
33
tags: servicetemplate
44
icinga_service_template:
5-
url: "https://example.com"
5+
url: "{{ icinga_url }}"
66
url_username: "{{ icinga_user }}"
77
url_password: "{{ icinga_pass }}"
8-
object_name: Consul
8+
object_name: fooservicetemplate
99
use_agent: true
1010
vars:
1111
procs_argument: consul

0 commit comments

Comments
 (0)