From cb94e15ba7cd9333b8f0b75eb91ad53fab350a74 Mon Sep 17 00:00:00 2001 From: Fabian Koller Date: Thu, 14 Jan 2021 21:18:45 +0100 Subject: [PATCH 1/2] Update ansible README.md --- ansible/README.md | 108 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 92 insertions(+), 16 deletions(-) diff --git a/ansible/README.md b/ansible/README.md index 225dd44b9..6cd9e9f9b 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -1,38 +1,114 @@ -Role Name -========= +Ansible Role: paperless-ng +========================== -A brief description of the role goes here. +Installs and configures paperless-ng EDMS on Debian/Ubuntu systems. Requirements ------------ -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. +No special system requirements. Ansible 2.7 or newer is required. + +Note that this role requires root access, so either run it in a playbook with a global `become: yes`, or invoke the role in your playbook like: + + - hosts: all + roles: + - role: ansible + become: yes Role Variables -------------- -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. +Most configuration variables from paperless-ng itself are available and accept their respective arguments. +Every `PAPERLESS_*` configuration varaible is lowercased and instead prefixed with `paperlessng_*` in `defaults/main.yml`. + +For a full listing including explainations and allowed values, see the current [documentation](https://paperless-ng.readthedocs.io/en/ng-0.9.14/configuration.html). + +Additional variables available in this role are listed below, along with default values: + + paperlessng_version: 0.9.14 + +The [release](https://github.com/jonaswinkler/paperless-ng/releases) archive version of paperless-ng to install. + + paperlessng_redis_host: localhost + paperlessng_redis_port: 6379 + +Seperate configuration values that combine into `PAPERLESS_REDIS`. + + paperlessng_db_type: sqlite + +Database to use. Default is file-based SQLite. + + paperlessng_db_host: localhost + paperlessng_db_port: 5432 + paperlessng_db_name: paperlessng + paperlessng_db_user: paperlessng + paperlessng_db_pass: paperlessng + paperlessng_db_sslmode: prefer + +Database configuration (only applicable if `paperlessng_db_type == 'postgresql'`). + + paperlessng_directory: /opt/paperless-ng + +Root directory paperless-ng is installed into. + + paperlessng_virtualenv: "{{ paperlessng_directory }}/.venv" + +Directory used for the virtual environment for paperless-ng. + + paperlessng_ocr_languages: + - eng + +List of OCR languages to install and configure (`apt search tesseract-ocr-*`). + + paperlessng_use_jbig2enc: True + +Whether to install and use [jbig2enc](https://github.com/agl/jbig2enc) for OCRmyPDF. + + paperlessng_big2enc_lossy: False + +Whether to use jbig2enc's lossy compression mode. + + paperlessng_superuser_name: paperlessng + paperlessng_superuser_email: paperlessng@example.com + paperlessng_superuser_password: paperlessng + +Credentials of the initial superuser in paperless-ng. + + paperlessng_system_user: paperlessng + paperlessng_system_group: paperlessng + +System user and group to run the paperless-ng services as (will be created if required). + + paperlessng_listen_address: 127.0.0.1 + paperlessng_listen_port: 8000 + +Address and port for the paperless-ng service to listen on. Dependencies ------------ -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. +No ansible dependencies. Example Playbook ---------------- +`playbook.yml`: -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers + - hosts: all + become: yes + vars_files: + - vars/main.yml roles: - - { role: username.rolename, x: 42 } + - ansible + +`vars/main.yml`: -License -------- + paperlessng_media_root: /mnt/media/smbshare -BSD + paperlessng_db_type: postgresql + paperlessng_db_pass: PLEASEPROVIDEASTRONGPASSWORDHERE -Author Information ------------------- + paperless_secret_key: AGAINPLEASECHANGETHISNOW -An optional section for the role authors to include contact information, or a website (HTML is not allowed). + paperlessng_ocr_languages: + - eng + - deu From 8d433ac0deb4a882e07296bf8844a3fd0019acdd Mon Sep 17 00:00:00 2001 From: Fabian Koller Date: Fri, 15 Jan 2021 10:10:36 +0100 Subject: [PATCH 2/2] Update setup docs with ansible instructions --- docs/setup.rst | 123 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) diff --git a/docs/setup.rst b/docs/setup.rst index 6eb597014..a3a0bd1e8 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -83,7 +83,8 @@ You can go multiple routes with setting up and running Paperless: * :ref:`Pull the image from Docker Hub ` * :ref:`Build the Docker image yourself ` -* :ref:`Install Paperless directly on your system (bare metal) ` +* :ref:`Install Paperless directly on your system manually (bare metal) ` +* :ref:`Use ansible to install Paperless on your system automatically (bare metal) ` The Docker routes are quick & easy. These are the recommended routes. This configures all the stuff from above automatically so that it just works and uses sensible defaults for all configuration options. @@ -92,6 +93,11 @@ The bare metal route is more complicated to setup but makes it easier should you want to contribute some code back. You need to configure and run the above mentioned components yourself. +The ansible route cobines benefits from both options: +the setup process is fully automated, reproducible and idempotent, +it includes the same sensible defaults, +and it simultaneously provides the flexibility of a bare metal installation. + .. _setup-docker_hub: Install Paperless from Docker Hub @@ -392,6 +398,121 @@ writing. Windows is not and will never be supported. to compile this by yourself, because this software has been patented until around 2017 and binary packages are not available for most distributions. +.. _setup-ansible: + +Install Paperless using ansible +=============================== + .. note:: + + This role currently only supports Debian 10 Buster and Ubuntu 20.04 Focal or later as target hosts. + +1. Install ansible 2.7+ on the management node. + This may be the target host paperless-ng is being installed on or any remote host which can access the target host. + For further details, check the ansible `inventory `_ documentation. + + On Debian and Ubuntu, the official repositories should provide a suitable version: + + .. code:: bash + + apt install ansible + ansible --version + + Alternatively, you can install the most recent ansible release using PyPI: + + .. code:: bash + + python3 -m pip install ansible + ansible --version + + Make sure your taget hosts are accessible: + + .. code:: sh + + ansible -m ping YourAnsibleTargetHostGoesHere + +2. Clone the repository of paperless-ng: + + .. code:: sh + + git clone https://github.com/jonaswinkler/paperless-ng + + Checkout the latest release tag: + + .. code:: sh + + cd paperless-ng + git checkout ng-0.9.14 + +3. Create an ansible ``playbook.yml`` in the paperless-ng root directory: + + .. code:: yaml + + - hosts: YourAnsibleTargetHostGoesHere + become: yes + vars_files: + - ansible/vars.yml + roles: + - ansible + + Optional: If you also want to use PostgreSQL on the target system, install and add (for example) the `geerlingguy.postgresql `_ role: + + .. code:: sh + + ansible-galaxy install geerlingguy.postgresql + + .. code:: yaml + + - hosts: YourAnsibleTargetHostGoesHere + become: yes + vars_files: + - ansible/vars.yml + roles: + - geerlingguy.postgresql + - ansible + + Optional: If you also want to use a reverse proxy on the target system, install and add (for example) the `geerlingguy.nginx `_ role: + + .. code:: sh + + ansible-galaxy install geerlingguy.nginx + + .. code:: yaml + + - hosts: YourAnsibleTargetHostGoesHere + become: yes + vars_files: + - ansible/vars.yml + roles: + - geerlingguy.postgresql + - ansible + - geerlingguy.nginx + +4. Create ``ansible/vars.yml`` to configure your ansible deployment: + + .. code:: yaml + + paperless_secret_key: PleaseGenerateAStrongKeyForThis + + paperlessng_superuser_name: YourUserName + paperlessng_superuser_email: name@domain.tld + paperlessng_superuser_password: YourDesiredPasswordUsedForFirstLogin + + paperlessng_ocr_languages: + - eng + - deu + + For all of the available options, please check ``ansible/README.md`` and :ref:`configuration`. + + Optional configurations for the above-mentioned PostgreSQL and nginx roles would also go here. + +5. Run the ansible playbook from the management node: + + .. code:: sh + + ansible-playbook playbook.yml + + When this step completes successfully, paperless-ng will be available on the target host at ``http://127.0.0.1:8000`` (or the address you configured). + Migration to paperless-ng #########################