2021-08-08 00:28:18 -05:00
|
|
|
# vim:ft=ansible:
|
|
|
|
- name: assure data directory for nagios
|
|
|
|
file: path=/data/nagios state=directory mode=0755
|
|
|
|
tags: [ nagios ]
|
2021-08-08 01:20:48 -05:00
|
|
|
- name: template out config for nagios
|
|
|
|
template: src=nagios-hosts.cfg.j2 dest=/data/nagios/etc/objects/ansible.cfg owner=root group=root mode=0644
|
2021-08-08 12:15:10 -05:00
|
|
|
register: config
|
2021-08-08 01:20:48 -05:00
|
|
|
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'
|
2021-08-08 00:28:18 -05:00
|
|
|
tags: [ nagios, template ]
|
|
|
|
- name: docker deploy nagios
|
|
|
|
docker_container:
|
|
|
|
name: nagios
|
2021-08-08 14:46:58 -05:00
|
|
|
image: jasonrivers/nagios
|
2021-08-08 00:28:18 -05:00
|
|
|
env:
|
|
|
|
NAGIOSADMIN_USER: admin
|
|
|
|
NAGIOSADMIN_PASS: "{{ secret_nagios_admin_pass }}"
|
2021-08-08 14:46:58 -05:00
|
|
|
NAGIOS_TIMEZONE: "America/Chicago"
|
2021-08-08 00:28:18 -05:00
|
|
|
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
|
2021-08-08 14:46:58 -05:00
|
|
|
- /data/nagios/nagiosgraph/var:/opt/nagiosgraph/var
|
|
|
|
- /data/nagios/nagiosgraph/etc:/opt/nagiosgraph/etc
|
2021-08-08 00:28:18 -05:00
|
|
|
tags: [ docker, nagios ]
|
2021-08-08 12:15:10 -05:00
|
|
|
- name: restart nagios
|
|
|
|
docker_container: name=nagios state=started restart=yes
|
|
|
|
when: config and config is changed
|
|
|
|
tags: [ docker, nagios ]
|