repo: Move ansible setup to root dir

This commit is contained in:
Marty Oehme 2025-07-16 22:33:28 +02:00
parent ff718b46ef
commit 7a37d60494
Signed by: Marty
GPG key ID: 4E535BC19C61886E
48 changed files with 127 additions and 172 deletions

38
roles/paperless/README.md Normal file
View file

@ -0,0 +1,38 @@
Role 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).

View file

@ -0,0 +1,23 @@
---
stack_paperless_env_dir: /opt/stack_paperless
stack_paperless_puid: 1000
stack_paperless_pgid: 100
stack_paperless_serve_dir: /srv
stack_paperless_serve_dir_create: true
stack_paperless_tz: America/Chicago
stack_paperless_ocr_language: eng # default OCR languages
stack_paperless_ocr_languages: eng deu frk # ALL installed languages
stack_paperless_ocr_skip_archive_file: with_text
stack_paperless_enable_update_check: true
# using !unsafe macro to stop ansible from interpolating as variables
stack_paperless_filename_format: !unsafe "{{created_year}}/{{correspondent}}/{{created}}_{{title}}"
stack_paperless_dbname: ppldbname
stack_paperless_dbuser: ppldbuser
stack_paperless_dbpass: ppldbpass
stack_paperless_secret_key: super-secret-random-key
stack_paperless_admin_user: AnAdminUserName
stack_paperless_admin_password: AnAdminPassword

View file

@ -0,0 +1,2 @@
---
# handlers file for paperless

View file

@ -0,0 +1,34 @@
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: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
galaxy_tags: []
# 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.

View file

@ -0,0 +1,29 @@
---
- name: Create Paperless stack environment directory
ansible.builtin.file:
state: directory
path: "{{ stack_paperless_env_dir }}"
owner: root
group: root
mode: 0700
- name: Create user-facing data dir
ansible.builtin.file:
state: directory
path: "{{ stack_paperless_serve_dir }}/{{ item }}"
owner: "{{ stack_paperless_puid }}"
group: "{{ stack_paperless_pgid }}"
mode: 0770
when: stack_paperless_serve_dir_create
loop:
- ""
- documents
- consume
- name: Start compose stack
community.docker.docker_compose_v2:
project_name: paperless
definition: "{{ lookup('template', 'docker-compose.yaml.j2') | from_yaml }}"
remove_orphans: true
wait: true
wait_timeout: 60

View file

@ -0,0 +1,80 @@
services:
paperless:
container_name: paperless
image: ghcr.io/paperless-ngx/paperless-ngx:latest
restart: unless-stopped
networks:
- caddy
- backend
security_opt:
- no-new-privileges:true
depends_on:
- paperless-redis
- paperless-postgres
volumes:
- "{{ stack_paperless_env_dir }}/data/paperless:/usr/src/paperless/data" # container data
- "{{ stack_paperless_env_dir }}/data/paperless_export:/usr/src/paperless/export" # backup location
- "{{ stack_paperless_serve_dir }}/documents:/usr/src/paperless/media" # document location
- "{{ stack_paperless_serve_dir }}/consume:/usr/src/paperless/consume" # watch folder
environment:
- "PAPERLESS_TIME_ZONE={{ stack_paperless_tz }}"
- "USERMAP_UID={{ stack_paperless_puid }}"
- "USERMAP_GID={{ stack_paperless_pgid }}"
- "PAPERLESS_OCR_LANGUAGE={{ stack_paperless_ocr_language }}"
- "PAPERLESS_OCR_LANGUAGES={{ stack_paperless_ocr_languages }}"
- "PAPERLESS_OCR_SKIP_ARCHIVE_FILE={{ stack_paperless_ocr_skip_archive_file }}"
- "PAPERLESS_ENABLE_UPDATE_CHECK={{ stack_paperless_enable_update_check }}"
- "PAPERLESS_REDIS=redis://paperless-redis:6379"
- "PAPERLESS_DBHOST=paperless-postgres"
- "PAPERLESS_DBNAME={{ stack_paperless_dbname }}"
- "PAPERLESS_DBUSER={{ stack_paperless_dbuser }}"
- "PAPERLESS_DBPASS={{ stack_paperless_dbpass }}"
- "PAPERLESS_SECRET_KEY={{ stack_paperless_secret_key }}"
- "PAPERLESS_FILENAME_FORMAT={{ stack_paperless_filename_format }}"
- "PAPERLESS_ADMIN_USER={{ stack_paperless_admin_user }}"
- "PAPERLESS_ADMIN_PASSWORD={{ stack_paperless_admin_password }}"
labels:
caddy: "http://documents.pichi.berlin"
caddy.reverse_proxy: "{{ '{{' }}upstreams 8000{{ '}}'}}"
paperless-postgres:
container_name: paperless-postgres
image: postgres:16.0-alpine #fixedVersion
restart: unless-stopped
networks:
- backend
security_opt:
- no-new-privileges:true
volumes:
- "{{ stack_paperless_env_dir }}/data/postgres:/var/lib/postgresql/data"
environment:
POSTGRES_DB: "{{ stack_paperless_dbname }}"
POSTGRES_USER: "{{ stack_paperless_dbuser }}"
POSTGRES_PASSWORD: "{{ stack_paperless_dbpass }}"
paperless-redis:
container_name: paperless-redis
image: redis:7.2-alpine #fixedVersion
restart: unless-stopped
networks:
- backend
security_opt:
- no-new-privileges:true
volumes:
- "{{ stack_paperless_env_dir }}/data/redis:/data"
environment:
REDIS_ARGS: "--save 60 10"
networks:
caddy:
external: true
backend:
name: backend
driver: bridge
# secrets:
# paperless_db_paperless_passwd:
# file: ./secrets/paperless_db_paperless_passwd
# paperless_secret_key:
# file: ./secrets/paperless_secret_key
#

View file

@ -0,0 +1,2 @@
localhost

View file

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- paperless

View file

@ -0,0 +1,2 @@
---
# vars file for paperless