# vim:ft=ansible: - name: assure data directory for nagios ansible.builtin.file: path="{{ nagios_data_dir }}" state=directory mode=0755 tags: [ nagios ] - name: docker deploy nagios docker_container: name: nagios #image: jasonrivers/nagios image: manios/nagios:latest pull: yes restart_policy: unless-stopped state: absent env: NAGIOSADMIN_USER: admin NAGIOSADMIN_PASS: "{{ nagios_admin_pass }}" NAGIOS_TIMEZONE: "{{ nagios_timezone }}" NAGIOS_FQDN: nagios.desu.ltd networks: - name: web aliases: [ "nagios" ] volumes: - "{{ nagios_data_dir }}/etc:/opt/nagios/etc" - "{{ nagios_data_dir }}/var:/opt/nagios/var" - "{{ nagios_data_dir }}/plugins:/opt/Custom-Nagios-Plugins" - "{{ nagios_data_dir }}/nagiosgraph/var:/opt/nagiosgraph/var" - "{{ nagios_data_dir }}/nagiosgraph/etc:/opt/nagiosgraph/etc" - /dev/null:/opt/nagios/bin/send_nsca tags: [ docker, nagios ] - name: template out scripts for nagios ansible.builtin.template: src="{{ item }}" dest="{{ nagios_data_dir }}/plugins/{{ item }}" owner=root group=root mode=0755 with_items: - notify-by-matrix tags: [ nagios, template, plugins ] - name: template out config for nagios ansible.builtin.template: src=nagios-ansible-inventory.cfg.j2 dest="{{ nagios_data_dir }}/etc/objects/ansible.cfg" owner=100 group=101 mode=0644 tags: [ nagios, template ] notify: restart nagios - name: assure config file is loaded ansible.builtin.lineinfile: path="{{ nagios_data_dir }}/etc/nagios.cfg" line='cfg_file=/opt/nagios/etc/objects/ansible.cfg' tags: [ nagios, template ] notify: restart nagios