Skip to content

Commit fd4816c

Browse files
authored
Merge pull request #9 from T-Systems-MMS/add_ubuntu_to_tests
added Debian to test coverage
2 parents bdc4d7b + 1f44558 commit fd4816c

5 files changed

Lines changed: 121 additions & 15 deletions

File tree

.github/workflows/CI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
distro:
6767
- centos7
6868
- rockylinux8
69+
- debian11
6970

7071
steps:
7172
- name: Check out code

roles/icinga_agent/defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ icinga_agent_api_conf: |
1414
accept_commands = true
1515
1616
icinga_agent_repositoryd_directory: false
17+
18+
icinga2_user:
19+
Debian: nagios
20+
RedHat: icinga
21+
icinga2_group:
22+
Debian: nagios
23+
RedHat: icinga

roles/icinga_agent/molecule/default/converge.yml

Lines changed: 104 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,53 @@
2323
tags:
2424
- molecule-idempotence-notest
2525

26+
- name: install icinga2 basic packages
27+
apt:
28+
name: gnupg
29+
state: present
30+
update_cache: true
31+
when: ansible_os_family == 'Debian'
32+
tags:
33+
- molecule-idempotence-notest
34+
35+
- name: add icinga2 repo key
36+
apt_key:
37+
url: "http://packages.icinga.com/icinga.key"
38+
state: present
39+
when: ansible_os_family == 'Debian'
40+
tags:
41+
- molecule-idempotence-notest
42+
43+
- name: add icinga2 repository
44+
apt_repository:
45+
repo: "{{ item }}"
46+
state: present
47+
update_cache: true
48+
with_items:
49+
- deb http://packages.icinga.com/debian icinga-bullseye main
50+
- deb-src http://packages.icinga.com/debian icinga-bullseye main
51+
when: ansible_os_family == 'Debian'
52+
tags:
53+
- molecule-idempotence-notest
54+
55+
- name: install icinga2 build dependencies
56+
apt:
57+
pkg: "icinga2"
58+
state: "build-dep"
59+
update_cache: true
60+
when: ansible_os_family == 'Debian'
61+
tags:
62+
- molecule-idempotence-notest
63+
64+
- name: install icinga2 basic packages
65+
apt:
66+
name: "icinga2"
67+
state: "present"
68+
update_cache: true
69+
when: ansible_os_family == 'Debian'
70+
tags:
71+
- molecule-idempotence-notest
72+
2673
collections:
2774
- t_systems_mms.ansible_collection_icinga
2875

@@ -51,58 +98,109 @@
5198
state: file
5299
register: result_icinga2_conf
53100

54-
- name: validate icinga2.conf results
101+
- name: validate icinga2.conf results for RedHat based Distributions
55102
assert:
56103
that:
57104
- "result_icinga2_conf.state == 'file'"
58105
- "result_icinga2_conf.mode == '0640'"
59106
- "result_icinga2_conf.owner == 'icinga'"
60107
- "result_icinga2_conf.group == 'icinga'"
108+
when: ansible_os_family == 'RedHat'
109+
110+
- name: validate icinga2.conf results for Debian based Distributions
111+
assert:
112+
that:
113+
- "result_icinga2_conf.state == 'file'"
114+
- "result_icinga2_conf.mode == '0640'"
115+
- "result_icinga2_conf.owner == 'nagios'"
116+
- "result_icinga2_conf.group == 'nagios'"
117+
when: ansible_os_family == 'Debian'
61118

62119
- name: verify that constants.conf exists
63120
file:
64121
path: /etc/icinga2/constants.conf
65122
state: file
66123
register: result_constants_conf
67124

68-
- name: validate constants.conf results
125+
- name: validate constants.conf results for RedHat based Distributions
69126
assert:
70127
that:
71128
- "result_constants_conf.state == 'file'"
72129
- "result_constants_conf.mode == '0640'"
73130
- "result_constants_conf.owner == 'icinga'"
74131
- "result_constants_conf.group == 'icinga'"
132+
when: ansible_os_family == 'RedHat'
133+
134+
- name: validate constants.conf results for Debian based Distributions
135+
assert:
136+
that:
137+
- "result_constants_conf.state == 'file'"
138+
- "result_constants_conf.mode == '0640'"
139+
- "result_constants_conf.owner == 'nagios'"
140+
- "result_constants_conf.group == 'nagios'"
141+
when: ansible_os_family == 'Debian'
75142

76143
- name: verify that zones.conf exists
77144
file:
78145
path: /etc/icinga2/zones.conf
79146
state: file
80147
register: result_zones_conf
81148

82-
- name: validate zones.conf results
149+
- name: validate zones.conf results for RedHat based Distributions
83150
assert:
84151
that:
85152
- "result_zones_conf.state == 'file'"
86153
- "result_zones_conf.mode == '0640'"
87154
- "result_zones_conf.owner == 'icinga'"
88155
- "result_zones_conf.group == 'icinga'"
156+
when: ansible_os_family == 'RedHat'
157+
158+
- name: validate zones.conf results for Debian based Distributions
159+
assert:
160+
that:
161+
- "result_zones_conf.state == 'file'"
162+
- "result_zones_conf.mode == '0640'"
163+
- "result_zones_conf.owner == 'nagios'"
164+
- "result_zones_conf.group == 'nagios'"
165+
when: ansible_os_family == 'Debian'
89166

90167
- name: verify that api.conf exists
91168
file:
92169
path: /etc/icinga2/features-available/api.conf
93170
state: file
94171
register: result_api_conf
95172

96-
- name: validate api.conf results
173+
- name: validate api.conf results for RedHat based Distributions
97174
assert:
98175
that:
99176
- "result_api_conf.state == 'file'"
100177
- "result_api_conf.mode == '0640'"
101178
- "result_api_conf.owner == 'icinga'"
102179
- "result_api_conf.group == 'icinga'"
180+
when: ansible_os_family == 'RedHat'
181+
182+
- name: validate api.conf results for Debian based Distributions
183+
assert:
184+
that:
185+
- "result_api_conf.state == 'file'"
186+
- "result_api_conf.mode == '0640'"
187+
- "result_api_conf.owner == 'nagios'"
188+
- "result_api_conf.group == 'nagios'"
189+
when: ansible_os_family == 'Debian'
190+
191+
# - name: verify that icinga2 package is installed
192+
# yum:
193+
# name: icinga2
194+
# state: present
195+
# when: ansible_os_family == 'RedHat'
196+
197+
# - name: verify that icinga2 package is installed for Debian based systems
198+
# apt:
199+
# name: icinga2
200+
# state: present
201+
# when: ansible_os_family == 'Debian'
103202

104203
- name: verify that icinga2 package is installed
105-
yum:
204+
ansible.builtin.package:
106205
name: icinga2
107206
state: present
108-
when: ansible_os_family == 'RedHat'

roles/icinga_agent/molecule/default/molecule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ platforms:
1010
- /sys/fs/cgroup:/sys/fs/cgroup:rw
1111
privileged: true
1212
pre_build_image: true
13-
command: "/usr/sbin/init"
13+
command: ""
1414
provisioner:
1515
name: ansible

roles/icinga_agent/tasks/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
- name: create /etc/icinga2/repository.d
1010
ansible.builtin.file:
1111
dest: "/etc/icinga2/repository.d"
12-
owner: icinga
13-
group: icinga
12+
owner: "{{ icinga2_user[ansible_os_family] }}"
13+
group: "{{ icinga2_group[ansible_os_family] }}"
1414
state: directory
1515
when:
1616
- icinga_agent_repositoryd_directory is defined
@@ -19,8 +19,8 @@
1919
ansible.builtin.template:
2020
src: "{{ item }}"
2121
dest: "/etc/icinga2/{{ item | basename | regex_replace('.j2', '') }}"
22-
owner: icinga
23-
group: icinga
22+
owner: "{{ icinga2_user[ansible_os_family] }}"
23+
group: "{{ icinga2_group[ansible_os_family] }}"
2424
mode: 0640
2525
with_fileglob:
2626
- "../templates/configuration/*"
@@ -31,8 +31,8 @@
3131
ansible.builtin.template:
3232
src: "{{ item }}"
3333
dest: "/etc/icinga2/features-available/{{ item | basename | regex_replace('.j2', '') }}"
34-
owner: icinga
35-
group: icinga
34+
owner: "{{ icinga2_user[ansible_os_family] }}"
35+
group: "{{ icinga2_group[ansible_os_family] }}"
3636
mode: 0640
3737
with_fileglob:
3838
- "../templates/features/*"
@@ -43,8 +43,8 @@
4343
ansible.builtin.template:
4444
src: "{{ item }}"
4545
dest: "/etc/icinga2/features-available/{{ item | basename | regex_replace('.j2', '') }}"
46-
owner: icinga
47-
group: icinga
46+
owner: "{{ icinga2_user[ansible_os_family] }}"
47+
group: "{{ icinga2_group[ansible_os_family] }}"
4848
mode: 0640
4949
with_fileglob:
5050
- "{{ icinga_agent_custom_features_template_path }}"

0 commit comments

Comments
 (0)