---
- name: Installation apache2 
  apt: name=apache2 state=present
 
- name: Installation snmp
  apt: name=snmp state=present

- name: Installation de icinga 
  apt: name=icinga state=present 

- name: Installation de nagios-plugins 
  apt: name=nagios-plugins state=present 

- name: Installation de nagios-snmp-plugins 
  apt: name=nagios-snmp-plugins state=present

- name: Installation des dépendances dns
  apt: name=libnet-dns-perl state=present

#- name: Copie de fichier apache.conf  
#  copy: remote_src=true src=/etc/icinga/apache2.conf dest=/etc/apache2/sites-available/icinga.conf

#- name: activation du site de icinga
#  shell: a2ensite icinga 
#  notify: 
#    - restart icinga

- name: changement de mot de passe de icingaadmin  
  shell: htpasswd -dbc /etc/icinga/htpasswd.users icingaadmin root

- name: Copie du fichier commands.cfg
  copy: src=commands.cfg  dest=/etc/icinga/commands.cfg

- name: Copie du fichier icinga.cfg
  copy: src=icinga.cfg  dest=/etc/icinga

- name: Copie du fichier contacts_icinga.cfg
  copy: src=cfg/contacts_icinga.cfg dest=/etc/icinga/objects

- name: Copie du fichier hostgroups_icinga.cfg
  copy: src=cfg/hostgroups_icinga.cfg dest=/etc/icinga/objects

- name: Copie du fichier r-ext.cfg
  copy: src=cfg/r-ext.cfg dest=/etc/icinga/objects

- name: Copie du fichier r-int.cfg
  copy: src=cfg/r-int.cfg dest=/etc/icinga/objects

- name: Copie du fichier s-adm.cfg
  copy: src=cfg/s-adm.cfg dest=/etc/icinga/objects

- name: Copie du fichier services_icinga.cfg
  copy: src=cfg/services_icinga.cfg dest=/etc/icinga/objects

- name: Copie du fichier s-infra.cfg
  copy: src=cfg/s-infra.cfg dest=/etc/icinga/objects

- name: Copie du fichier s-infra-adm.cfg
  copy: src=cfg/s-infra-adm.cfg dest=/etc/icinga/objects

#- name: Copie du fichier s-lb.cfg
#  copy: src=cfg/s-lb.cfg dest=/etc/icinga/objects

#- name: Copie du fichier s-lb-adm.cfg
# copy: src=cfg/s-lb-adm.cfg dest=/etc/icinga/objects

- name: Copie du fichier s-win
  copy: src=cfg/s-win.cfg dest=/etc/icinga/objects

- name: Changement droit notif
  shell: chmod 644 /var/log/icinga/icinga.log

- name: copie nt.cfg
  copy: src=nt.cfg dest=/etc/nagios-plugins/config

#- name: copie dns.cfg
#  copy: remote_src=true src=dns.cfg dest=/etc/nagios-plugins/config

- name: stop icinga
  service:
    name: icinga
    state: stopped

- name: modif des droits /var/lib/icinga/rw/
  shell: dpkg-statoverride --update --add nagios www-data 2710 /var/lib/icinga/rw/

- name: modif des droits /var/lib/icinga/
  shell: dpkg-statoverride --update --add nagios nagios 751 /var/lib/icinga/

- name: start icinga
  service:
    name: icinga
    state: started

- name: copie check traffic
  copy: src=check_iftraffic3.pl dest=/usr/lib/nagios/plugins

- name: modif des droits plugin traffic
  shell: chmod 755 /usr/lib/nagios/plugins/check_iftraffic3.pl

- name: message d'information
  debug: msg="Pour superviser le Windows, il faut installer NSClient++"
