From 7e1bf86baab91e10da489cf7e7233bcb6df499bc Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 6 Sep 2021 18:00:07 +0200 Subject: [PATCH] Update to 2021-09-06 18:00 --- roles/paperless_ng/defaults/main.yml | 12 +++++++----- roles/paperless_ng/handlers/main.yml | 6 +++--- roles/paperless_ng/meta/main.yml | 1 + roles/paperless_ng/tasks/conf.yml | 4 +++- roles/paperless_ng/tasks/install.yml | 6 +++--- roles/paperless_ng/tasks/services.yml | 6 +++--- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/roles/paperless_ng/defaults/main.yml b/roles/paperless_ng/defaults/main.yml index c91edf2..154cd40 100644 --- a/roles/paperless_ng/defaults/main.yml +++ b/roles/paperless_ng/defaults/main.yml @@ -2,6 +2,8 @@ # The version to deploy paperless_version: 1.5.0 +# Instance ID, as you can deploy several instances on the same server +paperless_id: 1 # URL of the paperless archive paperless_archive_url: https://github.com/jonaswinkler/paperless-ng/releases/download/ng-{{ paperless_version }}/paperless-ng-{{ paperless_version }}.tar.xz # Expected checksum @@ -9,12 +11,12 @@ paperless_archive_sha1: edbbbfde6718ee7586acf1212d32ca379058cb15 # Should ansible handle install and upgrades, or only initial install paperless_manage_upgrade: True # Root directory where paperless will be installed -paperless_root_dir: /opt/paperless +paperless_root_dir: /opt/paperless_{{ paperless_id }} # Paperless will monitor this dir and import files from here paperless_consume_dir: "{{ paperless_root_dir }}/consume" # The user under which paperless will run -paperless_user: paperless +paperless_user: paperless_{{ paperless_id }} # Port used by paperless web interface # You should put it behind a reverse proxy @@ -25,13 +27,13 @@ paperless_src_ip: [] # PostgreSQL database settings paperless_db_server: "{{ pg_server | default('localhost') }}" paperless_db_port: 5432 -paperless_db_name: paperless -paperless_db_user: paperless +paperless_db_name: paperless_{{ paperless_id }} +paperless_db_user: paperless_{{ paperless_id }} # If the password is not defined, a random one will be generated and stored in {{ papermerge_root_dir }}/meta/ansible_dbpass # paperless_db_pass: S3cr3t. # Redis URL -paperless_redis_url: redis://localhost:6379 +paperless_redis_url: redis://localhost:6379/0 # Secret key to create session token. If not defined, a random one will be generated and stored in {{ papermerge_root_dir }}/meta/ansible_secret_key # paperless_secret_key: SecretKey diff --git a/roles/paperless_ng/handlers/main.yml b/roles/paperless_ng/handlers/main.yml index 35882eb..e84b3b1 100644 --- a/roles/paperless_ng/handlers/main.yml +++ b/roles/paperless_ng/handlers/main.yml @@ -3,7 +3,7 @@ - name: restart paperless service: name={{ item }} state=restarted loop: - - paperless-webserver - - paperless-scheduler - - paperless-consumer + - paperless_{{ paperless_id }}-webserver + - paperless_{{ paperless_id }}-scheduler + - paperless_{{ paperless_id }}-consumer diff --git a/roles/paperless_ng/meta/main.yml b/roles/paperless_ng/meta/main.yml index 23e7545..c7ca5c7 100644 --- a/roles/paperless_ng/meta/main.yml +++ b/roles/paperless_ng/meta/main.yml @@ -1,5 +1,6 @@ --- +allow_duplicates: True dependencies: - role: mkdir - role: postgresql_server diff --git a/roles/paperless_ng/tasks/conf.yml b/roles/paperless_ng/tasks/conf.yml index 399d038..cad1870 100644 --- a/roles/paperless_ng/tasks/conf.yml +++ b/roles/paperless_ng/tasks/conf.yml @@ -16,6 +16,7 @@ app_path: "{{ paperless_root_dir }}/app/src" virtualenv: "{{ paperless_root_dir }}/venv" notify: restart paperless + become_user: "{{ paperless_user }}" - name: Collect static files django_manage: @@ -37,6 +38,7 @@ virtualenv: "{{ paperless_root_dir }}/venv" environment: DJANGO_SUPERUSER_PASSWORD: '{{ paperless_admin_pass }}' - + failed_when: False + become_user: "{{ paperless_user }}" tags: ged diff --git a/roles/paperless_ng/tasks/install.yml b/roles/paperless_ng/tasks/install.yml index fbc95ef..1d1f46c 100644 --- a/roles/paperless_ng/tasks/install.yml +++ b/roles/paperless_ng/tasks/install.yml @@ -69,12 +69,12 @@ #!/bin/bash cd {{ paperless_root_dir }}/app/src {{ paperless_root_dir }}/venv/bin/python ./manage.py $@ - dest: /usr/local/bin/paperless + 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 }}.service + template: src={{ item }}.service.j2 dest=/etc/systemd/system/{{ item | regex_replace('^paperless','paperless_' ~ paperless_id) }}.service loop: - paperless-webserver - paperless-scheduler @@ -89,7 +89,7 @@ tags: ged - name: Install backup hooks - template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/paperless mode=700 + template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/paperless_{{ paperless_id }} mode=700 loop: - pre - post diff --git a/roles/paperless_ng/tasks/services.yml b/roles/paperless_ng/tasks/services.yml index 8465849..f417d37 100644 --- a/roles/paperless_ng/tasks/services.yml +++ b/roles/paperless_ng/tasks/services.yml @@ -3,7 +3,7 @@ - name: Start and enable services service: name={{ item }} state=started enabled=True loop: - - paperless-webserver - - paperless-scheduler - - paperless-consumer + - paperless_{{ paperless_id }}-webserver + - paperless_{{ paperless_id }}-scheduler + - paperless_{{ paperless_id }}-consumer tags: ged