icinga: icinga-monitor: implement http host check
This commit is contained in:
parent
792d7dcc90
commit
b87119a1df
4
roles/icinga-monitor/defaults/main.yml
Normal file
4
roles/icinga-monitor/defaults/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
icinga_user: nagios
|
||||
icinga_group: nagios
|
5
roles/icinga-monitor/handlers/main.yml
Normal file
5
roles/icinga-monitor/handlers/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
- name: Restart icinga2
|
||||
service: name=icinga2 state=restarted
|
||||
delegate_to: "{{ icinga_server }}"
|
17
roles/icinga-monitor/tasks/http.yml
Normal file
17
roles/icinga-monitor/tasks/http.yml
Normal 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 }}"
|
13
roles/icinga-monitor/templates/http.j2
Normal file
13
roles/icinga-monitor/templates/http.j2
Normal 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 }}"
|
||||
}
|
@ -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
|
||||
|
2
roles/icinga/templates/icinga2/conf.d/hosts.footer.j2
Normal file
2
roles/icinga/templates/icinga2/conf.d/hosts.footer.j2
Normal file
@ -0,0 +1,2 @@
|
||||
}
|
||||
|
@ -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 %}
|
Loading…
Reference in New Issue
Block a user