bundlewrap/bundles/paperless-ng/items.py

147 lines
4.4 KiB
Python
Raw Normal View History

2021-05-23 15:41:19 +00:00
users = {
'paperless': {
'home': '/opt/paperless',
},
}
directories = {
'/opt/paperless/src': {},
'/opt/paperless/static': {
'owner': 'paperless',
},
}
git_deploy = {
'/opt/paperless/src': {
'repo': 'https://github.com/paperless-ngx/paperless-ngx.git',
2021-05-23 15:41:19 +00:00
'rev': node.metadata.get('paperless/version'),
'triggers': {
'action:paperless_collectstatic',
2021-05-23 15:41:19 +00:00
'action:paperless_compile_frontend',
'action:paperless_install_deps',
'action:paperless_migrate_database',
'svc_systemd:paperless-consumer:restart',
'svc_systemd:paperless-scheduler:restart',
'svc_systemd:paperless-webserver:restart',
},
},
}
files = {
'/etc/systemd/system/paperless-consumer.service': {
'triggers': {
'action:systemd-reload',
'svc_systemd:paperless-consumer:restart',
},
},
'/etc/systemd/system/paperless-scheduler.service': {
'triggers': {
'action:systemd-reload',
'svc_systemd:paperless-scheduler:restart',
},
},
'/etc/systemd/system/paperless-webserver.service': {
'triggers': {
'action:systemd-reload',
'svc_systemd:paperless-webserver:restart',
},
},
'/opt/paperless/src/paperless.conf': {
'content_type': 'mako',
'needs': {
'git_deploy:/opt/paperless/src',
},
'triggers': {
'svc_systemd:paperless-consumer:restart',
'svc_systemd:paperless-scheduler:restart',
'svc_systemd:paperless-webserver:restart',
},
},
}
actions = {
'paperless_create_virtualenv': {
'command': '/usr/bin/python3 -m virtualenv -p python3 /opt/paperless/venv/',
'unless': 'test -d /opt/paperless/venv/',
'needs': {
# actually /opt/paperless, but we don't create that
'directory:/opt/paperless/src',
'pkg_apt:python3',
'pkg_apt:python3-pip',
'pkg_apt:python3-virtualenv',
2021-05-23 15:41:19 +00:00
},
},
'paperless_install_deps': {
'command':
'cd /opt/paperless/src && '
'/opt/paperless/venv/bin/pip install --upgrade pip && '
'/opt/paperless/venv/bin/pip install --upgrade -r requirements.txt',
'triggered': True,
'needs': {
'action:paperless_create_virtualenv',
},
},
'paperless_migrate_database': {
'command':
'cd /opt/paperless/src/src && '
'sudo -Hu paperless /opt/paperless/venv/bin/python manage.py migrate',
'triggered': True,
'needs': {
# /mnt/paperless is NOT created by this bundle.
'action:paperless_install_deps',
'directory:/mnt/paperless',
'directory:/opt/paperless/static',
'file:/opt/paperless/src/paperless.conf',
'user:paperless',
'postgres_db:paperless',
},
},
'paperless_compile_frontend': {
'command':
'cd /opt/paperless/src/src-ui && '
'npm install && '
'node_modules/.bin/ng build',
2021-05-23 15:41:19 +00:00
'triggered': True,
'needs': {
'file:/opt/paperless/src/paperless.conf',
'pkg_apt:nodejs',
},
},
'paperless_collectstatic': {
'command':
'cd /opt/paperless/src/src && '
'sudo -Hu paperless /opt/paperless/venv/bin/python manage.py collectstatic',
'triggered': True,
'needs': {
'directory:/opt/paperless/static',
'file:/opt/paperless/src/paperless.conf',
'action:paperless_install_deps',
},
},
2021-05-23 15:41:19 +00:00
}
svc_systemd = {
'paperless-consumer': {
'needs': {
'action:paperless_migrate_database',
'file:/etc/systemd/system/paperless-consumer.service',
'git_deploy:/opt/paperless/src',
},
},
'paperless-scheduler': {
'needs': {
'action:paperless_migrate_database',
'file:/etc/systemd/system/paperless-scheduler.service',
'git_deploy:/opt/paperless/src',
},
},
'paperless-webserver': {
'needs': {
'action:paperless_compile_frontend',
'action:paperless_migrate_database',
'file:/etc/systemd/system/paperless-webserver.service',
'git_deploy:/opt/paperless/src',
},
},
}