From 0ab5593d7d73e6f1a5831106ef48490555853845 Mon Sep 17 00:00:00 2001
From: Andrea Dell'Amico <andrea.dellamico@isti.cnr.it>
Date: Fri, 7 Aug 2015 18:20:09 +0200
Subject: [PATCH] library/roles/nagios, xen: Various fixes to add debian 8
 compatibility.

---
 fail2ban/templates/jail.local.j2 |  2 +-
 nagios/tasks/dell-omsa.yml       | 33 ++++++++++++++++++--------------
 nagios/tasks/hardware-checks.yml |  1 +
 3 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/fail2ban/templates/jail.local.j2 b/fail2ban/templates/jail.local.j2
index 6cf14ac0..65c9e4f8 100644
--- a/fail2ban/templates/jail.local.j2
+++ b/fail2ban/templates/jail.local.j2
@@ -18,7 +18,7 @@
 # "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not
 # ban a host which matches an address in this list. Several addresses can be
 # defined using space separator.
-ignoreip = 127.0.0.1/8 {{ cm_ip }} {{ monitoring_ip }}
+ignoreip = 127.0.0.1/8 {% if cm_ip is defined %}{{ cm_ip }}{% endif %} {% if monitoring_ip is defined %}{{ monitoring_ip }}{% endif %}
 
 # "bantime" is the number of seconds that a host is banned.
 bantime  = {{ f2b_ban_time }}
diff --git a/nagios/tasks/dell-omsa.yml b/nagios/tasks/dell-omsa.yml
index 594d32e8..8dddf23f 100644
--- a/nagios/tasks/dell-omsa.yml
+++ b/nagios/tasks/dell-omsa.yml
@@ -7,14 +7,28 @@
   register: update_apt_cache
   tags: [ 'dell', 'nagios' ]
 
+- name: Install the NeMIS internal repository apt key
+  apt_key: url=http://ppa.research-infrastructures.eu/system/keys/system-archive.asc state=present
+  tags: [ 'dell', 'nagios' ]
+
 - name: research infrastructures system repository on debian
   copy: src={{ item }} dest=/etc/apt/sources.list.d/{{ item }}
   with_items:
     - research-infrastructures.eu.system.list
-  when: is_debian6
+  when: is_debian
   register: update_apt_cache
   tags: [ 'dell', 'nagios' ]
 
+- name: Update apt cache
+  apt: update_cache=yes
+  when: ( update_apt_cache | changed )
+  tags: [ 'dell', 'nagios' ]
+
+#- action: apt_key id=1285491434D8786F state=present
+- name: Install the Dell OMSA repository apt key
+  apt_key: keyserver=pool.sks-keyservers.net id=1285491434D8786F
+  tags: [ 'dell', 'nagios' ]
+
 - name: Install the Dell apt repository
   template: src={{ item }}.j2 dest=/etc/apt/sources.list.d/{{ item }}
   with_items:
@@ -23,18 +37,9 @@
   register: update_apt_cache
   tags: [ 'dell', 'nagios' ]
 
-- name: Install the NeMIS internal repository apt key
-  apt_key: url=http://ppa.research-infrastructures.eu/system/keys/system-archive.asc state=present
-  tags: [ 'dell', 'nagios' ]
-
-#- action: apt_key id=1285491434D8786F state=present
-- name: Install the Dell OMSA repository apt key
-  apt_key: keyserver=pool.sks-keyservers.net id=1285491434D8786F
-  tags: [ 'dell', 'nagios' ]
-
 - name: Update apt cache
   apt: update_cache=yes
-  when: update_apt_cache.changed
+  when: ( update_apt_cache | changed )
   tags: [ 'dell', 'nagios' ]
 
 - name: Install the Dell OMSA packages dependencies
@@ -42,7 +47,7 @@
   with_items: nagios_dell_omsa_deps
   tags: [ 'dell', 'nagios' ]
 
-- name: Install the Dell OMSA packages dependencies
+- name: Install other Dell OMSA packages dependencies
   apt: pkg={{ item }} state=installed
   with_items:
     - python-requests
@@ -75,8 +80,8 @@
   when: ( libssl_legacy | changed )
   tags: [ 'dell', 'nagios' ]
 
-- name: Install the Dell OMSA packages
-  apt: pkg={{ item }} state=installed force=yes
+- name: Install the main Dell OMSA package
+  apt: pkg={{ item }} state={{ nagios_dell_omsa_pkg_state }} force=yes
   with_items:
     - syscfg
   when: is_not_debian6
diff --git a/nagios/tasks/hardware-checks.yml b/nagios/tasks/hardware-checks.yml
index 26d921fc..29df2b57 100644
--- a/nagios/tasks/hardware-checks.yml
+++ b/nagios/tasks/hardware-checks.yml
@@ -25,6 +25,7 @@
 
 - name: Ensure that the smart server is enabled and running
   service: name=smartmontools state=started enabled=yes
+  when: not is_debian8
   tags:
     - nagios-hw
     - nagios