icinga: icinga-monitor: implement http host check

This commit is contained in:
Markus 2022-06-06 20:25:38 +02:00
parent 792d7dcc90
commit b87119a1df
7 changed files with 57 additions and 8 deletions

View File

@ -0,0 +1,4 @@
---
icinga_user: nagios
icinga_group: nagios

View File

@ -0,0 +1,5 @@
---
- name: Restart icinga2
service: name=icinga2 state=restarted
delegate_to: "{{ icinga_server }}"

View File

@ -0,0 +1,17 @@
---
- name: Configure monitoring for vhost
template:
src: http.j2
dest: /etc/icinga2/conf.d/hosts/{{ inventory_hostname }}.http_{{ vhost }}
owner: "{{ icinga_user }}"
group: "{{ icinga_group }}"
delegate_to: "{{ icinga_server }}"
- name: Regenerate hosts.conf
assemble:
src: /etc/icinga2/conf.d/hosts
dest: /etc/icinga2/conf.d/hosts.conf
# validate: /usr/sbin/icinga2 daemon -c %s --validate
notify: Restart icinga2
delegate_to: "{{ icinga_server }}"

View File

@ -0,0 +1,13 @@
vars.http_vhosts["{{ vhost }}"] = {
http_sni = "true"
http_ssl = "true"
http_vhost = "{{ vhost }}"
}
vars.http_vhosts["{{ vhost }} cert"] = {
http_certificate = "25,15"
http_sni = "true"
http_ssl = "true"
http_vhost = "{{ vhost }}"
}

View File

@ -62,9 +62,20 @@
changed_when: "'for these changes to take effect' in features_result.stdout"
notify: Restart icinga2
- name: Configure known hosts for icinga
template: src=icinga2/conf.d/hosts.conf.j2 dest=/etc/icinga2/conf.d/hosts.conf owner={{ icinga_user }} group={{ icinga_group }}
notify: Restart icinga2
- name: Ensure directory for host snippets exists
file:
path: /etc/icinga2/conf.d/hosts
state: directory
owner: "{{ icinga_user }}"
group: "{{ icinga_group }}"
- name: Prepare host snippets
template: src=icinga2/conf.d/hosts.header.j2 dest=/etc/icinga2/conf.d/hosts/{{ item }}.00_header owner={{ icinga_user }} group={{ icinga_group }}
loop: "{{ groups['all'] }}"
- name: Prepare host snippets
template: src=icinga2/conf.d/hosts.footer.j2 dest=/etc/icinga2/conf.d/hosts/{{ item }}.zz_footer owner={{ icinga_user }} group={{ icinga_group }}
loop: "{{ groups['all'] }}"
- name: Create group icingaweb2
group: name=icingaweb2 system=yes

View File

@ -0,0 +1,2 @@
}

View File

@ -1,12 +1,9 @@
{% for host in groups['all'] %}
object Host "{{ host }}" {
object Host "{{ item }}" {
/* Import the default host template defined in `templates.conf`. */
import "generic-host"
/* Specify the address attributes for checks e.g. `ssh` or `http`. */
address = "{{ host }}"
address = "{{ item }}"
/* Set custom variable `os` for hostgroup assignment in `groups.conf`. */
vars.os = "Linux"
}
{% endfor %}