---
- name: Dependencies installed
  community.general.pkgng:
    name: dendrite,element-web
    state: latest

- name: Dendrite enabled
  shell: sysrc dendrite_enable="YES"
  notify: Dendrite restarted

- name: Matrix signing key installed
  template:
    src: matrix_key.pem.j2
    dest: /usr/local/etc/dendrite/matrix_key.pem
    owner: root
    mode: 0600
  notify: Dendrite restarted

- name: Dendrite config installed
  template:
    src: dendrite.yaml.j2
    dest: /usr/local/etc/dendrite/dendrite.yaml
    owner: root
    mode: 0600
  notify: Dendrite restarted

- name: Element nginx conf installed
  copy:
    src: nginx-location.conf
    dest: /usr/local/etc/nginx/locations/element.conf
  notify: Nginx retarted

- name: Element config installed
  copy:
    src: element-config.json
    dest: /usr/local/www/element/config.json

- name: Dendrite immortal file installed
  copy:
    src: immortal-dendrite.yml
    dest: /usr/local/etc/immortal/dendrite.yml
    mode: 0644
  notify: Immortal restarted
