ansible/playbooks/tasks/web/nagios.yml

84 lines
2.8 KiB
YAML

# vim:ft=ansible:
- name: assure data directory for nagios
file: path=/data/nagios state=directory mode=0755
tags: [ nagios ]
- name: template out config for nagios
template: src=nagios-ansible.cfg.j2 dest=/data/nagios/etc/objects/ansible.cfg owner=root group=root mode=0644
vars:
nagios_services:
# Agentless checks
- name: HTTP
command: check_http
hostgroup: nagios-checkhttp
- name: HTTPS
command: check_http!--ssl
hostgroup: nagios-checkhttp
- name: SSH
command: check_ssh
hostgroup: ansible
# Agented checks
- name: CPU Load
command: check_nrpe!check_load
hostgroup: nagios-nrpe
- name: Disk Usage
command: check_nrpe!check_disk_all
hostgroup: nagios-nrpe
- name: Reboot Required
command: check_nrpe!check_reboot_required
hostgroup: nagios-nrpe
- name: Unit backup.service
command: check_nrpe!check_systemd_backup_service
hostgroup: nagios-nrpe
- name: Unit backup.timer
command: check_nrpe!check_systemd_backup_timer
hostgroup: nagios-nrpe
- name: Unit docker.service
command: check_nrpe!check_systemd_docker_service
hostgroup: nagios-nrpe
- name: Users
command: check_nrpe!check_users
hostgroup: nagios-nrpe
# Tag-specific checks
# ansible-pull
- name: Unit ansible-pull.service
command: check_nrpe!check_systemd_ansiblepull_service
hostgroup: ansible-pull
- name: Unit ansible-pull.timer
command: check_nrpe!check_systemd_ansiblepull_timer
hostgroup: ansible-pull
# nagios-checkpgsql
- name: PostgreSQL
command: check_nrpe!check_pgsql
hostgroup: nagios-checkpgsql
# nagios-nrpeswap
- name: Swap Usage
command: check_nrpe!check_swap
hostgroup: nagios-nrpeswap
register: config
tags: [ nagios, template ]
- name: assure config file is loaded
lineinfile: path=/data/nagios/etc/nagios.cfg line='cfg_file=/opt/nagios/etc/objects/ansible.cfg'
tags: [ nagios, template ]
- name: docker deploy nagios
docker_container:
name: nagios
image: jasonrivers/nagios
env:
NAGIOSADMIN_USER: admin
NAGIOSADMIN_PASS: "{{ secret_nagios_admin_pass }}"
NAGIOS_TIMEZONE: "America/Chicago"
networks:
- name: web
aliases: [ "nagios" ]
volumes:
- /data/nagios/etc:/opt/nagios/etc
- /data/nagios/var:/opt/nagios/var
- /data/nagios/plugins:/opt/Custom-Nagios-Plugins
- /data/nagios/nagiosgraph/var:/opt/nagiosgraph/var
- /data/nagios/nagiosgraph/etc:/opt/nagiosgraph/etc
tags: [ docker, nagios ]
- name: restart nagios
docker_container: name=nagios state=started restart=yes
when: config and config is changed
tags: [ docker, nagios ]