- name: 1. Récupération du tar.gz du DokuWiki
  get_url:
    url: http://depl/store/dokuwiki-stable.tgz
    dest: /tmp

- name: 2. Extraction de l'archive
  unarchive:
    src: /tmp/dokuwiki-stable.tgz
    dest: /var/www/html
    remote_src: yes

- name: 3. Status des dossiers du Wiki
  stat:
    path: /var/www/html/dokuwiki-2024-02-06b
  register: rept_stat

- name: 4. On renomme les dossiers
  command: mv /var/www/html/dokuwiki-2024-02-06b /var/www/html/doku
  when: rept_stat.stat.exists

- name: 5. Changement des droits sur la racine
  file:
    path: /var/www/html/doku
    owner: root
    group: root

- name: 6. Changement des droits sur le dossier data
  file:
    path: /var/www/html/doku/data
    owner: www-data
    group: www-data
    recurse: true

- name: 7. Changement des droits sur le dossier conf
  file:
    path: /var/www/html/doku/conf
    owner: www-data
    group: www-data
    recurse: true

- name: 8. Changement des droits sur le dossier lib
  file:
    path: /var/www/html/doku/lib
    owner: www-data
    group: www-data
    recurse: true

- name: 9. Redémarre Apache2
  service:
    name: apache2
    state: restarted
