paperless-formula/paperless/init.sls
2024-10-27 16:35:17 +01:00

120 lines
3.8 KiB
Text

broker-data-directory-exists:
file.directory:
- name: /opt/paperless/broker
- makedirs: True
paperless-data-directory-exists:
file.directory:
- name: /opt/paperless/webserver
- makedirs: True
python3-pip:
pkg.installed
# https://github.com/saltstack/salt/issues/61004
python-pip-uptodate:
pip.installed:
- require:
- pkg: python3-pip
- pkgs:
- pip
- upgrade: True
# https://bugs.launchpad.net/ubuntu/+source/python-docker/+bug/2066926
# https://packages.debian.org/source/sid/python-docker
# does not work
# python-docker-package:
# pkg.installed:
# - name: python3-docker
# https://stackoverflow.com/a/78224409
# https://github.com/docker/docker-py/issues/3113
# https://github.com/saltstack/salt/issues/62689
docker-requirements:
pip.installed:
- require:
- pkg: python3-pip
- pkgs:
- pyyaml==5.3.1
# - docker==6.1.3
# - docker==7.0.0
- docker==7.1.0
# - docker==5.0.3
# - docker-py==1.10.5
# - requests<2.29.0
# - urllib3<2.0
- docker-compose>=1.5.0
# other errors that were encountered
# keyerror http+docker
# https://github.com/geerlingguy/ansible-role-docker/issues/462
# https://github.com/docker/docker-py/issues/3279
# unexpected keyword argument 'chunked'
# https://github.com/saltstack/salt/issues/65526
# 'docker.version' is not available
# https://github.com/saltstack/salt/issues/53836
# https://github.com/saltstack/salt/issues/54449
# https://github.com/saltstack/salt/issues/62602
# network is always recreated
# https://github.com/saltstack/salt/issues/66408
# otherwise it complains about scope attribute, similar to
# https://github.com/saltstack/salt/issues/50194
# https://github.com/saltstack/salt/issues/51009
# but it should be possible according to docs
# https://docs.saltproject.io/en/latest/ref/states/all/salt.states.docker_network.html#salt.states.docker_network.present
docker-network-paperless-exists:
docker_network.present:
- name: paperless-network
# - scope: local
broker-docker-container-running:
docker_container.running:
- name: broker
- image: {{ salt['pillar.get']('paperless:broker:image:path', 'docker.io/library/redis') }}:{{ salt['pillar.get']('paperless:broker:image:version', '7') }}
- container_name: broker
- restart: unless-stopped
- binds: /opt/paperless/broker:/data
- networks:
- paperless-network
gotenberg-docker-container-running:
docker_container.running:
- name: gotenberg
- image: {{ salt['pillar.get']('paperless:gotenberg:image:path', 'docker.io/gotenberg/gotenberg') }}:{{ salt['pillar.get']('paperless:gotenberg:image:version', '8.9.1') }}
- container_name: gotenberg
- restart: unless-stopped
# The gotenberg chromium route is used to convert .eml files. We do not
# want to allow external content like tracking pixels or even javascript.
- command:
- "gotenberg"
- "--chromium-disable-javascript=true"
- "--chromium-allow-list=file:///tmp/.*"
- networks:
- paperless-network
tika-docker-container-running:
docker_container.running:
- name: tika
- image: {{ salt['pillar.get']('paperless:tika:image:path', 'docker.io/apache/tika') }}:{{ salt['pillar.get']('paperless:tika:image:version', '2.9.2.1') }}
- container_name: tika
- restart: unless-stopped
- networks:
- paperless-network
paperless-docker-compose-env-file-present:
file.managed:
- name: /opt/docker-compose.env
- template: jinja
- source: salt://paperless/docker-compose.env.jinja
paperless-docker-compose-file-present:
file.managed:
- name: /opt/docker-compose.yml
- template: jinja
- source: salt://docker-compose.yml.jinja
paperless-docker-compose-up:
module.run:
- dockercompose.up:
- path: /opt/docker-compose.yml