---
- name: Dependencies installed
  community.general.pkgng:
    name: "git rust py38-cffi py38-cryptography py38-lxml py38-joblib py38-numpy py38-pip py38-pycparser py38-pyinotify py38-scikit-learn py38-scipy py38-setuptools py38-six py38-sqlite3 python38 py38-psycopg"
    state: latest

- name: Paperless-ng source cloned
  git:
    repo: "https://github.com/jonaswinkler/paperless-ng"
    dest: /usr/local/src/
    update: yes
    force: yes

- name: Requirements up to date
  pip:
    requirements: /usr/local/src/paperless-ng/requirements.txt
    executable: pip


- name: Paperless-web rc file installed
  ansible.builtin.copy:
    src: paperless.rc
    dest: /usr/local/etc/rc.d/paperless-web
    mode: a+x

- name: Paperless-tasks rc file installed
  ansible.builtin.copy:
    src: paperless-tasks.rc
    dest: /usr/local/etc/rc.d/paperless-tasks
    mode: a+x

- name: Paperless-consumer rc file installed
  ansible.builtin.copy:
    src: paperless-consumer.rc
    dest: /usr/local/etc/rc.d/paperless-consumer
    mode: a+x

- name: Paperless enabled
  shell: sysrc paperless_enable="YES"

- name: Paperless started
  service: name=paperless state=started
