---

# Voir : https://github.com/hedgedoc/hedgedoc/blob/master/docs/configuration.md
# et : https://github.com/hedgedoc/hedgedoc/blob/880af8d4f80b9e1dcaa30014d4ed5c41e351b564/docs/setup/reverse-proxy.md

- name: Mise en éxécutable du script de dépendances
  ansible.builtin.file:
    path: /home/hedgedocs/hedgedoc/bin/setup
    owner: hedgedocs
    group: www-data
    mode: '0777'

- name: Configuration des dépendances
  ansible.builtin.shell: /home/hedgedocs/hedgedoc/bin/setup >> /home/hedgedocs/setup_log_hedgedocs.txt
    chdir: /home/hedgedocs/hedgedoc

- name: Mise en non-éxécutable du script de dépendances
  ansible.builtin.file:
    path: /home/hedgedocs/hedgedoc/bin/setup
    owner: hedgedocs
    group: www-data
    mode: '0644'


- name: Configuration du service HedgeDocs
  template:
    src: files/config.json.j2
    dest: /home/hedgedocs/hedgedoc/config.json
    owner: hedgedocs
    group: www-data
    mode: 0644

- name: Configuration du fichier SystemD
  template:
    src: files/hedgedocs.service
    dest: /etc/systemd/system/hedgedocs.service
    owner: root
    group: root
    mode: 0644

- name: Activation de la configuration systemd
  systemd:
    state: started
    name: hedgedocs
    enabled: yes

- name: Force systemd à relire les configs
  ansible.builtin.systemd:
    daemon_reload: yes

- name: Reload nginx
  systemd:
    state: reloaded
    name: nginx
    enabled: yes

# And we're done !
