commit 19bd75c78c5ad5e877f1651181f93001411319a4 Author: Lennard Brinkhaus Date: Wed Sep 20 21:47:16 2023 +0200 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ab9fdb4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# EditorConfig: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Defaults for all editor files +[*] +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +# Files with a smaller indent +[*.yml] +indent_size = 2 + +# Jinja2 template files +[*.j2] +end_of_line = lf \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b396ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +local-configure.yml +.vagrant/ +docs/_build/ +roles/plone.plone_server +roles/jnv.unattended-upgrades +roles/tersmitten.fail2ban +roles/ANXS.hostname +roles/ANXS.apt +._* +bin/ +lib/ +include/ +local/ +tests.out +*.retry +*.log +vbox_host.cfg +.DS_Store +*.py[co] +.idea/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..4c2fe2a --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# EditorConfig: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Defaults for all editor files +[*] +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +# Files with a smaller indent +[*.yml] +indent_size = 2 + +# Jinja2 template files +[*.j2] +end_of_line = lfRole Name +========= + +A brief description of the role goes here. + +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. + +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. + +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. + +Example Playbook +---------------- + +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 + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..17c134e --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +roles_path: ./../ diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..ff9bf3a --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,9 @@ +--- +paperless_ngx_version: "1.17" +paperless_ngx_redis_version: "7" +paperless_ngx_postgres_version: "16" +paperless_ngx_gotenberg_version: "7.8" + +paperless_ngx_url: "" + +paperless_barcode_enable: true \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..3fde42c --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,4 @@ +- name: "Restart Paperless" + ansible.builtin.service: + name: paperless-ngx + state: restarted diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..dbf0452 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,54 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: None + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [ + - paperless-ngx + ] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/meta/requirements.yml b/meta/requirements.yml new file mode 100644 index 0000000..37553ac --- /dev/null +++ b/meta/requirements.yml @@ -0,0 +1,2 @@ +- name: role-traefik + src: https://git.dragse.it/ansible/role-traefik diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..73f31f1 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,70 @@ +--- +- name: Create podman folder + file: + path: /etc/containers/systemd + state: directory + mode: 0775 + recurse: yes + +- name: Create paperless data folder + file: + path: "/var/paperless-ngx/data" + state: directory + mode: 0775 + recurse: yes + +- name: Create paperless media folder + file: + path: "/var/paperless-ngx/media" + state: directory + mode: 0775 + recurse: yes + +- name: Create paperless export folder + file: + path: "/var/paperless-ngx/export" + state: directory + mode: 0775 + recurse: yes + +- name: Create paperless consume folder + file: + path: "/var/paperless-ngx/consume" + state: directory + mode: 0775 + recurse: yes + +- name: Create paperless redis folder + file: + path: "/var/paperless-ngx/redis" + state: directory + mode: 0775 + recurse: yes + +- name: Create paperless postgres folder + file: + path: "/var/paperless-ngx/postgres" + state: directory + mode: 0775 + recurse: yes + +- name: Setup Podman quadlet + block: + - name: Copy vaultwarden.container + ansible.builtin.template: + src: vaultwarden.quadlet.j2 + dest: "/etc/containers/systemd/vaultwarden-{{ vaultwarden_identifier }}.container" + + - name: "Reload systemd" + ansible.builtin.systemd: + daemon_reload: true + when: ansible_service_mgr == "systemd" + + - name: Start Vaultwardne + systemd_service: + enabled: true + name: vaultwarden-{{ vaultwarden_identifier }} + state: started + notify: + - Restart Vaultwarden + diff --git a/templates/paperless-ngx-gotenberg.quadlet.j2 b/templates/paperless-ngx-gotenberg.quadlet.j2 new file mode 100644 index 0000000..632895a --- /dev/null +++ b/templates/paperless-ngx-gotenberg.quadlet.j2 @@ -0,0 +1,30 @@ +[Unit] +Description=Paperless-ngx Gotenberg + +[Container] +ContainerName=paperless-ngx-gotenberg +Image=docker.io/gotenberg/gotenberg:{{ paperless_ngx_gotenberg_version }} + +Network=paperless.network + +NoNewPrivileges=true +DropCapability=All + +#UserNS=keep-id +# Required to access the Podman Socket +#SecurityLabelDisable=true +PodmanArgs=--userns=keep-id --security-opt label=disable + +Exec=gotenberg --chromium-disable-javascript=true --chromium-allow-list=file:///tmp/.* + +[Service] +Restart=on-failure +# Restart Delay +RestartSec=30 +# Allowed time for the service to start. +TimeoutStartSec=90 +# Allowed time for the service to stop. +TimeoutStopSec=90 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/templates/paperless-ngx-postgres.quadlet.j2 b/templates/paperless-ngx-postgres.quadlet.j2 new file mode 100644 index 0000000..3af6a9c --- /dev/null +++ b/templates/paperless-ngx-postgres.quadlet.j2 @@ -0,0 +1,36 @@ +[Unit] +Description=Paperless-ngx Postgres + +[Container] +ContainerName=paperless-ngx-postgres +Image=docker.io/library/postgres:{{ paperless_ngx_postgres_version }} + +Environment=TZ=Europe/Berlin +Environment=POSTGRES_USER=paperless +Environment=POSTGRES_PASSWORD=paperless +Environment=POSTGRES_DB=paperless + +Network=paperless.network + +Volume=/var/paperless-ngx/postgres:/var/lib/postgresql/data:rw + +NoNewPrivileges=true +DropCapability=All +AddCapability=net_bind_service + +#UserNS=keep-id +# Required to access the Podman Socket +#SecurityLabelDisable=true +PodmanArgs=--userns=keep-id --security-opt label=disable + +[Service] +Restart=on-failure +# Restart Delay +RestartSec=30 +# Allowed time for the service to start. +TimeoutStartSec=90 +# Allowed time for the service to stop. +TimeoutStopSec=90 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/templates/paperless-ngx-redis.quadlet.j2 b/templates/paperless-ngx-redis.quadlet.j2 new file mode 100644 index 0000000..a2c118c --- /dev/null +++ b/templates/paperless-ngx-redis.quadlet.j2 @@ -0,0 +1,31 @@ +[Unit] +Description=Paperless-ngx Redis + +[Container] +ContainerName=paperless-ngx-redis +Image=docker.io/library/redis:{{ paperless_ngx_redis_version }} + +Network=paperless.network + +Volume=/var/paperless-ngx/redis:/data:rw + +NoNewPrivileges=true +DropCapability=All +AddCapability=net_bind_service + +#UserNS=keep-id +# Required to access the Podman Socket +#SecurityLabelDisable=true +PodmanArgs=--userns=keep-id --security-opt label=disable + +[Service] +Restart=on-failure +# Restart Delay +RestartSec=30 +# Allowed time for the service to start. +TimeoutStartSec=90 +# Allowed time for the service to stop. +TimeoutStopSec=90 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/templates/paperless-ngx-tika.quadlet.j2 b/templates/paperless-ngx-tika.quadlet.j2 new file mode 100644 index 0000000..783550b --- /dev/null +++ b/templates/paperless-ngx-tika.quadlet.j2 @@ -0,0 +1,28 @@ +[Unit] +Description=Paperless-ngx Tika + +[Container] +ContainerName=paperless-ngx-tika +Image=ghcr.io/paperless-ngx/tika:latest + +Network=paperless.network + +NoNewPrivileges=true +DropCapability=All + +#UserNS=keep-id +# Required to access the Podman Socket +#SecurityLabelDisable=true +PodmanArgs=--userns=keep-id --security-opt label=disable + +[Service] +Restart=on-failure +# Restart Delay +RestartSec=30 +# Allowed time for the service to start. +TimeoutStartSec=90 +# Allowed time for the service to stop. +TimeoutStopSec=90 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/templates/paperless-ngx.quadlet.j2 b/templates/paperless-ngx.quadlet.j2 new file mode 100644 index 0000000..0c3d482 --- /dev/null +++ b/templates/paperless-ngx.quadlet.j2 @@ -0,0 +1,75 @@ +[Unit] +Description=Paperless-ngx +Requires=paperless-ngx-postgres.service +Requires=paperless-ngx-redis.service +Requires=paperless-ngx-tika.service +Requires=paperless-ngx-gotenberg.service +After=paperless-ngx-postgres.service +After=paperless-ngx-redis.service +After=paperless-ngx-tika.service +After=paperless-ngx-gotenberg.service + +[Container] +ContainerName=paperless-ngx +Image=ghcr.io/paperless-ngx/paperless-ngx:{{ paperless_ngx_version }} + +Environment=PAPERLESS_SECRET_KEY={{ paperless_secret_key }} +Environment=TZ=Europe/Berlin +Environment=PAPERLESS_TIME_ZONE=Europe/Berlin +Environment=PAPERLESS_OCR_LANGUAGE=deu+eng +Environment=PAPERLESS_URL=https://{{ paperless_ngx_url }} + +Environment=PAPERLESS_TIKA_ENABLED=1 +Environment=PAPERLESS_TIKA_ENDPOINT=http://paperless-ngx-tika:9998 +Environment=PAPERLESS_TIKA_GOTENBERG_ENDPOINT=http://paperless-ngx-gotenberg:3000 + +Environment=PAPERLESS_DBENGINE=postgresql +Environment=PAPERLESS_DBHOST=paperless-ngx-postgres +Environment=PAPERLESS_DBPORT=5432 +Environment=PAPERLESS_DBNAME=paperless +Environment=PAPERLESS_DBUSER=paperless +Environment=PAPERLESS_DBPASS=paperless + +Environment=PAPERLESS_REDIS=redis://paperless-ngx-redis:6379 + +PAPERLESS_CONSUMER_ENABLE_BARCODES={{ paperless_barcode_enable }} + +Network=traefik.network +Network=paperless.network + +Volume=/var/paperless-ngx/data:/usr/src/paperless/data:rw +Volume=/var/paperless-ngx/media:/usr/src/paperless/media:rw +Volume=/var/paperless-ngx/export:/usr/src/paperless/export:rw +Volume=/var/paperless-ngx/consume:/usr/src/paperless/consume:rw + +NoNewPrivileges=true +DropCapability=All +AddCapability=net_bind_service + +#UserNS=keep-id +# Required to access the Podman Socket +#SecurityLabelDisable=true +PodmanArgs=--userns=keep-id --security-opt label=disable + +Label="traefik.http.routers.paperless-ngx.tls.certresolver=resolver" +Label="traefik.http.routers.paperless-ngx.tls=true" +Label="traefik.http.routers.paperless-ngx.rule=Host(`{{ paperless_ngx_url }}`)" +Label="traefik.http.routers.paperless-ngx.service=paperless-ngx" +Label="traefik.http.services.paperless-ngx.loadbalancer.server.port=8000" + +HealthCmd="curl -fs -S --max-time 2 http://localhost:8000" +HealthInterval=30s +HealthTimeout=20s +HealthRetries=5 + +[Service] +Restart=on-failure +# Restart Delay +RestartSec=30 +# Allowed time for the service to start. +TimeoutStartSec=90 +# Allowed time for the service to stop. +TimeoutStopSec=90 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/templates/paperless.network b/templates/paperless.network new file mode 100644 index 0000000..678e69f --- /dev/null +++ b/templates/paperless.network @@ -0,0 +1,2 @@ +[Network] +Label=app=paperless-ngx diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..42e3b81 --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +192.168.1.142 + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..c4672ef --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + remote_user: root + roles: + - role-paperless-ngx diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..c000ab1 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for role-paperless-ng