- name: create dirs
  file:
    path: "{{ item }}"
    state: directory
  with_items:
    - /srv/dockerdata/copyparty
    - /srv/dockerdata/copyparty/config
    - /srv/dockerdata/copyparty/data
    - /srv/dockerdata/copyparty/data/public
    - /srv/dockerdata/copyparty/data/upload
    - /srv/dockerdata/copyparty/hists
  tags: ["docker", "copyparty"]

- name: create volume directories
  file:
    path: "{{ item.path }}"
    state: directory
  with_items: "{{ copyparty.volumes | default([]) }}"
  when:
    - item.path is defined
    - item.path.startswith('/srv/dockerdata/copyparty/')
  tags: ["docker", "copyparty"]

- name: template config file
  template:
    src: copyparty.conf
    dest: /srv/dockerdata/copyparty/config/copyparty.conf
    owner: root
    group: root
    mode: "0644"
  notify: run copyparty container
  tags: ["docker", "copyparty"]

- name: template compose file
  template:
    src: docker-compose.yml
    dest: /srv/dockerdata/copyparty/
    owner: root
    group: root
    mode: "0644"
  notify: run copyparty container
  tags: ["docker", "copyparty"]
