diff --git a/roles/nagios/tasks/main.yml b/roles/nagios/tasks/main.yml index 40a67b1..855250d 100644 --- a/roles/nagios/tasks/main.yml +++ b/roles/nagios/tasks/main.yml @@ -1,39 +1,40 @@ --- - yum: name="{{ item }}" state=present with_items: - nagios - nagios-plugins-nrpe - name: Create nagios directory (Bug 1291734) file: state=directory path=/var/log/nagios/rw/ owner=nagios group=nagios - name: Nagios cgi configuration remove auth lineinfile: dest: /etc/nagios/cgi.cfg line: "use_authentication=1" state: absent - name: Nagios cgi configuration remove auth lineinfile: dest: /etc/nagios/cgi.cfg line: "use_authentication=0" notify: reload nagios - name: Nagios configurations template: src: "{{ item }}.cfg" dest: "/etc/nagios/conf.d/{{ item }}.cfg" with_items: - commands - hosts - services + - contacts notify: reload nagios - name: Start nagios service: name=nagios state=started enabled=true - name: Nagios config for httpd template: src=nagios.conf dest=/etc/httpd/conf.d/nagios.conf notify: reload apache diff --git a/roles/nagios/templates/commands.cfg b/roles/nagios/templates/commands.cfg index b507309..77d59b9 100644 --- a/roles/nagios/templates/commands.cfg +++ b/roles/nagios/templates/commands.cfg @@ -1,5 +1,5 @@ define command{ - command_name check_nrpe - command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ - } + command_name check_nrpe + command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ +} diff --git a/roles/nagios/templates/contacts.cfg b/roles/nagios/templates/contacts.cfg new file mode 100644 index 0000000..7bc511c --- /dev/null +++ b/roles/nagios/templates/contacts.cfg @@ -0,0 +1,12 @@ +define contactgroup{ + contactgroup_name c4science_admins + alias Nagios Administrators + members aubort +} + +define contact { + contact_name aubort + use generic-contact + alias Nagios Admin + email jean-baptiste.aubort@epfl.ch +} diff --git a/roles/nagios/templates/hosts.cfg b/roles/nagios/templates/hosts.cfg index 8b3138a..229c1ab 100644 --- a/roles/nagios/templates/hosts.cfg +++ b/roles/nagios/templates/hosts.cfg @@ -1,30 +1,30 @@ define host{ name linux-box use generic-host check_period 24x7 check_interval 5 retry_interval 1 max_check_attempts 10 check_command check-host-alive notification_period 24x7 notification_interval 30 notification_options d,r - contact_groups admins + contact_groups c4science_admins register 0 } {% for host in groups['all'] %} {% if hostvars[host]['host_name'] is defined and hostvars[host]['host_name'] != 'c4science-jump00' and hostvars[host]['host_name'] != 'c4science-ci-slave00' %} define host{ use linux-box host_name {{ hostvars[host]['host_name'] }} address {{ host }} } {% endif %} {% endfor %} define host{ use linux-box host_name c4science-jump00 address {{ hostvars['127.0.0.1']['openstackjump'].results[0]['openstack']['private_v4'] }} }