update: monitoring master stucture

This commit is contained in:
2023-01-04 03:44:47 +01:00
parent fe5391a5c2
commit f8806f30d9
4 changed files with 123 additions and 94 deletions

View File

@@ -8,4 +8,4 @@
- hosts: monitoring
roles:
- { role : monitoring-master, tags : [ "monitoring-master" ] }
- { role : monitoring-master, tags : [ "monitoring-master", "icinga", "grafana" ] }

View File

@@ -0,0 +1,16 @@
- name: Create Compose Directory
file:
path: /opt/
state: directory
- name: Create Data Volume Directory
file:
path: /var/grafana/
state: directory
owner: 472 # grafana docker uid
group: root
- name: Copy Grafana Compose file
template:
src: grafana.yaml.j2
dest: /opt/

View File

@@ -0,0 +1,94 @@
- name: Install Dependecies
apt:
name: git
state: present
- name: Clone Passive Monitoring
git:
repo: https://github.com/FAUSheppy/icinga-passive-checks-monitoring
dest: "/etc/monitoring/"
version: master
- name: Clone Monitoring tools
git:
repo: https://github.com/FAUSheppy/monitoring-tools
dest: "/etc/monitoring-tools/"
version: master
- name: Set monitoring tools permissions
file:
dest: /etc/monitoring-tools/
owner: root
mode: u=rwX,g=rX,o=rX
recurse: yes
- name: Set monitoring permissions
file:
dest: /etc/monitoring/
owner: root
mode: u=rwX,g=rX,o=rX
recurse: yes
- name: Copy nsca-ng and send_nsca to /bin/
copy:
src: nsca-ng
dest: /bin/nsca-ng
mode: 0755
- name: Copy nsca-ng and send_nsca to /bin/
copy:
src: send_nsca
dest: /bin/send_nsca
mode: 0755
- name: Create nsca server directory
file:
path: /etc/nsca-ng/
mode: 0750
owner: root
group: nagios
- name: Copy nsca server config
copy:
src: nsca_server.conf
dest: /etc/nsca-ng/nsca-ng.cfg
owner: root
group: nagios
mode: 0644
- name: Copy nsca systemd unit
copy:
src: nsca-ng.service
dest: /etc/systemd/user/nsca-ng.service
mode: 0644
notify:
- nsca-ng service reload
- name: Enable and start nsca-ng
systemd:
name: nsca-ng.service
state: started
enabled: yes
- name: Copy icinga configuration
copy:
src: "{{ item }}"
dest: /etc/icinga2/conf.d/
owner: root
group: nagios
mode: 0640
with_items:
- icinga_master_hosts.conf
- services_vhosts_http_checks.conf
- services_passive.conf
- services_passive_mail_extern.conf
- services_async.conf
notify:
- restart icinga
- name: Signal command loaded from monitoring tools
lineinfile:
path: /etc/icinga2/icinga2.conf
line: '"include /etc/monitoring-tools/commands.d/signal-notify.conf"'
notify:
- restart icinga

View File

@@ -1,94 +1,13 @@
- name: Install Dependecies
apt:
name: git
state: present
- name: Icinga
include: icinga.yaml
when: monitoring_master
tags:
- icinga
- monitoring-master
- name: Clone Passive Monitoring
git:
repo: https://github.com/FAUSheppy/icinga-passive-checks-monitoring
dest: "/etc/monitoring/"
version: master
- name: Clone Monitoring tools
git:
repo: https://github.com/FAUSheppy/monitoring-tools
dest: "/etc/monitoring-tools/"
version: master
- name: Set monitoring tools permissions
file:
dest: /etc/monitoring-tools/
owner: root
mode: u=rwX,g=rX,o=rX
recurse: yes
- name: Set monitoring permissions
file:
dest: /etc/monitoring/
owner: root
mode: u=rwX,g=rX,o=rX
recurse: yes
- name: Copy nsca-ng and send_nsca to /bin/
copy:
src: nsca-ng
dest: /bin/nsca-ng
mode: 0755
- name: Copy nsca-ng and send_nsca to /bin/
copy:
src: send_nsca
dest: /bin/send_nsca
mode: 0755
- name: Create nsca server directory
file:
path: /etc/nsca-ng/
mode: 0750
owner: root
group: nagios
- name: Copy nsca server config
copy:
src: nsca_server.conf
dest: /etc/nsca-ng/nsca-ng.cfg
owner: root
group: nagios
mode: 0644
- name: Copy nsca systemd unit
copy:
src: nsca-ng.service
dest: /etc/systemd/user/nsca-ng.service
mode: 0644
notify:
- nsca-ng service reload
- name: Enable and start nsca-ng
systemd:
name: nsca-ng.service
state: started
enabled: yes
- name: Copy icinga configuration
copy:
src: "{{ item }}"
dest: /etc/icinga2/conf.d/
owner: root
group: nagios
mode: 0640
with_items:
- icinga_master_hosts.conf
- services_vhosts_http_checks.conf
- services_passive.conf
- services_passive_mail_extern.conf
- services_async.conf
notify:
- restart icinga
- name: Signal command loaded from monitoring tools
lineinfile:
path: /etc/icinga2/icinga2.conf
line: '"include /etc/monitoring-tools/commands.d/signal-notify.conf"'
notify:
- restart icinga
- name: Grafana.yaml
include: icinga.yaml
when: monitoring_master
tags:
- grafana
- monitoring-master