---

- include_tasks: ../functions/get_secret.yml
  with_items:
   - { path: /srv/shared/noreply_email_pass,  length: -1 }

- name: create folder struct for dokuwiki
  file:
    path: "{{item}}"
    state: "directory"
  with_items:
    - "{{ basedir }}"
    - "{{ basedir }}/data"
    - "{{ basedir }}/pdftemplate"

- name: Docker Compose Konfig-Datei erstellen
  template:
    src: "{{item}}"
    dest: "{{ basedir }}/{{item}}"
  with_items:
    - docker-compose.yml
    - Dockerfile
    - sendmail_plenum.py
  register: config

- name: Cronjob für Mailversand Plenumsmail
  cron: 
    name: "sendmail_plenum" 
    weekday: "0" 
    hour: "20" 
    minute: "0" 
    job: "/usr/bin/python3 {{ basedir }}/sendmail_plenum.py"
    disabled: false

- name: "stop {{ servicename}} docker"
  docker_compose:
    project_src: "{{ basedir }}"
    state: absent
  when: config.changed

- name: "start {{ servicename}} docker"
  docker_compose:
    project_src: "{{ basedir }}"
    state: present
