---
 - name: Install apache2
   apt: name=apache2 state=present update_cache=yes
   notify: 
     - restart apache2

 - name: Install php5
   apt: name=php5 state=present update_cache=yes

 - name: Install php5-mysql
   apt: name=php5-mysql state=present update_cache=yes

 - name: Install php5-gd
   apt: name=php5-gd state=present update_cache=yes

 - name: Install php5-curl
   apt: name=php5-curl state=present update_cache=yes

 - name: Install php5-imap
   apt: name=php5-imap state=present update_cache=yes

 - name: Install php5-ldap
   apt: name=php5-ldap state=present update_cache=yes

 - name: Download GLPI from Internet
   copy: src=glpi-9.1.3.tgz dest=/var/www/

 - name: Instructions
   debug: msg="En cas de problemes, relancez le playbook une seconde fois."

 - name: unpack tarball
   unarchive: src=/var/www/glpi-9.1.3.tgz dest=/var/www/

 - name: Fix permissions
   shell: chown -R www-data:www-data /var/www/glpi/
   
 - name: copy .my.cnf file with root password credentials
   copy: src=.my.cnf dest=/root/tools/ansible/.my.cnf owner=root mode=0600


 - name: Print web instructions
   debug: msg="/!\ Se rendre sur http://adresse_ip_de_votre_serveur/glpi et suivre l'installation"

 - name: Download Fusioninventory from Internet
   copy: src=fusioninventory-for-glpi_0.85+1.3.tar.gz dest=/var/www/glpi/plugins

 - name: unpack tarball
   unarchive: src=/var/www/glpi/plugins/fusioninventory-for-glpi_0.85+1.3.tar.gz dest=/var/www/glpi/plugins
   
 - name: Print web instructions
   debug: msg="(i) Fusioninventory plugin installed in /var/www/glpi/plugins"

 - name: copy glpi.conf 
   copy: src=glpi.conf dest=/etc/apache2/sites-available/ 

 - name: activation du site glpi
   shell: a2ensite glpi.conf
   notify:
     - restart apache2

 - name: copie script
   copy: src=script dest=/root/

 - name: chmod
   shell: chmod +x /root/script