- name: apt update
  tags: update
  apt:
    update-cache: yes
    cache_valid_time: 3600

- name: installation des utilitaires
  tags: utils
  apt:
    name:
      - mysql-server
      - mysql-client
      - apache2
      - php7.4
      - php-7.4-mysql
      - libapache2-mod-php7.4
      - php7.4-json
      - php7.4-cli
      - php7.4-xml
      - php-cas
      - php7.4-mbstring
      - php7.4-curl
      - php7.4-gd
      - php7.4-imap
      - php7.4-ldap
      - php7.4-xmlrpc
      - php-apcu
    state: present

- name: Création de la BDD GLPI
  tags: glpi
  mysql_db:
    login_unix_socket: /var/run/mysqld/mysqld.sock
    name: glpi

- name: Création de l'utilisateur glpi sur mysql
  tags: user
  mysql_user:
    name: glpi
    password: glpi
    priv: '*.*:ALL,GRANT'
    state: present
    login_unix_socket: /var/run/mysqld/mysqld.sock

- name: Enable the Apache2 module wsgi
  community.general.apache2_module:
    state: present
    name: rewrite

- name: Message d'information
  tags: msg
  debug: msg="Adminer sera accessible depuis l'adresse http://onfarbo44/adminer/"

- name: On démarre MariaDB
  tags: mariadb
  service:
    name: mysql
    state: started

- name: Création de la BDD bdarbre
  tags: bdarbre
  mysql_db:
    login_unix_socket: /var/run/mysqld/mysqld.sock
    name: bdarbre

- name: Création de l'utilisateur slam
  tags: user
  mysql_user:
    name: slam
    password: Azerty1+
    priv: '*.*:ALL,GRANT'
    state: present
    login_unix_socket: /var/run/mysqld/mysqld.sock
  notify: restart apache
