1
0
forked from infra/ansible

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" changed_when: "'for these changes to take effect' in features_result.stdout"
notify: Restart icinga2 notify: Restart icinga2
- name: Configure known hosts for icinga - name: Ensure directory for host snippets exists
template: src=icinga2/conf.d/hosts.conf.j2 dest=/etc/icinga2/conf.d/hosts.conf owner={{ icinga_user }} group={{ icinga_group }} file:
notify: Restart icinga2 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 - name: Create group icingaweb2
group: name=icingaweb2 system=yes group: name=icingaweb2 system=yes

View File

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

View File

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