2021-12-01 19:13:34 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Install packages
|
|
|
|
package: name={{ paperless_packages }}
|
|
|
|
tags: ged
|
|
|
|
|
|
|
|
- when: paperless_install_mode != 'none'
|
|
|
|
block:
|
|
|
|
- name: Download paperless
|
|
|
|
get_url:
|
|
|
|
url: "{{ paperless_archive_url }}"
|
|
|
|
dest: "{{ paperless_root_dir }}/tmp"
|
2022-03-19 01:00:10 +01:00
|
|
|
checksum: sha256:{{ paperless_archive_sha256 }}
|
2021-12-01 19:13:34 +01:00
|
|
|
|
|
|
|
- name: Extract archive
|
|
|
|
unarchive:
|
2022-05-12 16:00:11 +02:00
|
|
|
src: "{{ paperless_root_dir }}/tmp/paperless-ngx-v{{ paperless_version }}.tar.xz"
|
2021-12-01 19:13:34 +01:00
|
|
|
dest: "{{ paperless_root_dir }}/tmp"
|
|
|
|
remote_src: True
|
|
|
|
|
|
|
|
- name: Move paperless app
|
|
|
|
synchronize:
|
2022-03-19 01:00:10 +01:00
|
|
|
src: "{{ paperless_root_dir }}/tmp/paperless-ngx/"
|
2021-12-01 19:13:34 +01:00
|
|
|
dest: "{{ paperless_root_dir }}/app/"
|
|
|
|
delete: True
|
|
|
|
compress: False
|
|
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
|
|
|
|
|
|
- name: Fix permissions
|
|
|
|
file: path={{ paperless_root_dir }}/app/ owner=root group=root recurse=True
|
|
|
|
|
|
|
|
- name: Add exec perm on manage.py
|
|
|
|
file: path={{ paperless_root_dir }}/app/src/manage.py mode=755
|
|
|
|
|
|
|
|
tags: ged
|
|
|
|
|
2022-07-29 15:00:16 +02:00
|
|
|
|
2021-12-01 19:13:34 +01:00
|
|
|
- name: Create the virtualenv
|
2022-07-29 15:00:16 +02:00
|
|
|
pip:
|
|
|
|
name:
|
|
|
|
- pip
|
|
|
|
- setuptools
|
|
|
|
- wheel
|
|
|
|
state: "{{ (paperless_install_mode == 'upgrade') | ternary('latest', 'present') }}"
|
|
|
|
virtualenv: "{{ paperless_root_dir }}/venv"
|
|
|
|
virtualenv_command: /bin/python3.9 -m venv
|
|
|
|
tags: ged
|
|
|
|
|
|
|
|
- name: Install requirements in the virtualenv
|
2021-12-01 19:13:34 +01:00
|
|
|
pip:
|
|
|
|
requirements: "{{ paperless_root_dir }}/app/requirements.txt"
|
|
|
|
state: "{{ (paperless_install_mode == 'upgrade') | ternary('latest', 'present') }}"
|
|
|
|
virtualenv: "{{ paperless_root_dir }}/venv"
|
|
|
|
virtualenv_command: /bin/python3.9 -m venv
|
|
|
|
tags: ged
|
|
|
|
|
2022-12-01 12:00:13 +01:00
|
|
|
# Starting with ocrmypdf 14.0.0, ghostscript 9.50 is required
|
|
|
|
# But EL8 only has 9.27
|
|
|
|
- name: Install older ocrmypdf
|
|
|
|
pip:
|
|
|
|
name: ocrmypdf==13.7.0
|
|
|
|
virtualenv: "{{ paperless_root_dir }}/venv"
|
|
|
|
virtualenv_command: /bin/python3.9 -m venv
|
|
|
|
tags: ged
|
|
|
|
|
2021-12-01 19:13:34 +01:00
|
|
|
- block:
|
|
|
|
- name: Create the PostgreSQL role
|
|
|
|
postgresql_user:
|
|
|
|
db: postgres
|
|
|
|
name: "{{ paperless_db_user }}"
|
|
|
|
password: "{{ paperless_db_pass }}"
|
|
|
|
login_host: "{{ paperless_db_server }}"
|
|
|
|
login_user: sqladmin
|
|
|
|
login_password: "{{ pg_admin_pass }}"
|
|
|
|
|
|
|
|
- name: Create the PostgreSQL database
|
|
|
|
postgresql_db:
|
|
|
|
name: "{{ paperless_db_name }}"
|
|
|
|
encoding: UTF-8
|
|
|
|
template: template0
|
|
|
|
owner: "{{ paperless_db_user }}"
|
|
|
|
login_host: "{{ paperless_db_server }}"
|
|
|
|
login_user: sqladmin
|
|
|
|
login_password: "{{ pg_admin_pass }}"
|
|
|
|
tags: ged
|
|
|
|
|
|
|
|
- name: Install a wrapper for manage.py
|
|
|
|
copy:
|
|
|
|
content: |
|
|
|
|
#!/bin/bash
|
|
|
|
cd {{ paperless_root_dir }}/app/src
|
|
|
|
{{ paperless_root_dir }}/venv/bin/python ./manage.py $@
|
|
|
|
dest: /usr/local/bin/paperless_{{ paperless_id }}
|
|
|
|
mode: 0755
|
|
|
|
tags: ged
|
|
|
|
|
|
|
|
- name: Install systemd units
|
|
|
|
template: src={{ item }}.service.j2 dest=/etc/systemd/system/{{ item | regex_replace('^paperless','paperless_' ~ paperless_id) }}.service
|
|
|
|
loop:
|
|
|
|
- paperless-webserver
|
|
|
|
- paperless-scheduler
|
2022-11-28 12:00:11 +01:00
|
|
|
- paperless-task-queue
|
2021-12-01 19:13:34 +01:00
|
|
|
- paperless-consumer
|
|
|
|
notify: restart paperless
|
|
|
|
register: paperless_units
|
|
|
|
tags: ged
|
|
|
|
|
|
|
|
- name: Reload systemd
|
|
|
|
systemd: daemon_reload=True
|
|
|
|
when: paperless_units.results | selectattr('changed','equalto',True) | list | length > 0
|
|
|
|
tags: ged
|
|
|
|
|
|
|
|
- name: Install backup hooks
|
|
|
|
template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/paperless_{{ paperless_id }} mode=700
|
|
|
|
loop:
|
|
|
|
- pre
|
|
|
|
- post
|
|
|
|
tags: ged
|
|
|
|
|