Use more variables from group_data
This commit is contained in:
parent
14d127fa2c
commit
576d2c8fd5
4 changed files with 104 additions and 50 deletions
43
deploy.py
43
deploy.py
|
@ -17,17 +17,22 @@ apt.packages(
|
|||
|
||||
server.user(
|
||||
name='Create UNIX user',
|
||||
user='photoprism',
|
||||
shell='/bin/false',
|
||||
user=host.data.unix_user,
|
||||
group=host.data.unix_group,
|
||||
home=host.data.unix_home,
|
||||
shell=host.data.unix_shell,
|
||||
ensure_home=True,
|
||||
system=True,
|
||||
comment='photoprism system user',
|
||||
present=True,
|
||||
)
|
||||
|
||||
for items in ['storage', 'originals', 'import']:
|
||||
files.directory(
|
||||
name='Make required directories /home/photoprism/{}'.format(items),
|
||||
path='/home/photoprism/{}'.format(items),
|
||||
user='photoprism',
|
||||
group='photoprism',
|
||||
name='Make required directories {}'.format(items),
|
||||
path=host.data.unix_home+'/{}'.format(items),
|
||||
user=host.data.unix_user,
|
||||
group=host.data.unix_group,
|
||||
mode=755
|
||||
)
|
||||
|
||||
|
@ -53,16 +58,24 @@ files.download(
|
|||
sha256sum='b937e69e774c530c080c1f6685763ca7db4dc58520a5a2054d111e1504f47688',
|
||||
)
|
||||
|
||||
if not host.fact.file('/tmp/photoprism.tar'):
|
||||
files.directory(
|
||||
name='Create undocker cache',
|
||||
path=host.data.undocker_cache,
|
||||
user='root',
|
||||
group='root',
|
||||
mode=755
|
||||
)
|
||||
|
||||
if not host.fact.file(host.data.undocker_cache+'/photoprism.tar'):
|
||||
server.shell(
|
||||
name='Download photoprism Docker image',
|
||||
chdir='/tmp',
|
||||
chdir=host.data.undocker_cache,
|
||||
commands=['skopeo copy docker://docker.io/photoprism/photoprism:latest docker-archive:photoprism.tar'],
|
||||
)
|
||||
|
||||
files.directory(
|
||||
name='Ensure /opt/photoprism exists',
|
||||
path='/opt/photoprism',
|
||||
name='Create undocker destination',
|
||||
path=host.data.undocker_dst,
|
||||
user='root',
|
||||
group='root',
|
||||
mode=755
|
||||
|
@ -70,20 +83,20 @@ files.directory(
|
|||
|
||||
server.shell(
|
||||
name='Undocker the Docker image',
|
||||
chdir='/opt/photoprism',
|
||||
commands=['undocker /tmp/photoprism.tar - | tar -xv'],
|
||||
chdir=host.data.undocker_dst,
|
||||
commands=['undocker '+host.data.undocker_cache+'/photoprism.tar - | tar -xv'],
|
||||
)
|
||||
|
||||
files.template(
|
||||
name='Set env file',
|
||||
src='templates/env.j2',
|
||||
dest='/etc/photoprism.env',
|
||||
dest=host.data.systemd_env,
|
||||
mode='600',
|
||||
)
|
||||
|
||||
files.put(
|
||||
files.template(
|
||||
name='Set systemd service file',
|
||||
src='files/photoprism.service',
|
||||
src='templates/photoprism.service.j2',
|
||||
dest='/etc/systemd/system/photoprism.service',
|
||||
mode='644',
|
||||
)
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
[Unit]
|
||||
Description=photoprism
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=photoprism
|
||||
Group=photoprism
|
||||
StateDirectory=photoprism
|
||||
EnvironmentFile=/etc/photoprism.env
|
||||
WorkingDirectory=/photoprism
|
||||
RootDirectory=/opt/photoprism
|
||||
BindPaths=/home/photoprism/storage:/photoprism/storage /home/photoprism/originals:/photoprism/originals /home/photoprism/import:/photoprism/import
|
||||
ExecStart=/photoprism/bin/photoprism start
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,3 +1,4 @@
|
|||
# From Dockerfile
|
||||
PHOTOPRISM_ASSETS_PATH="/photoprism/assets"
|
||||
PHOTOPRISM_STORAGE_PATH="/photoprism/storage"
|
||||
PHOTOPRISM_BACKUP_PATH="/var/lib/photoprism"
|
||||
|
@ -5,29 +6,68 @@ PHOTOPRISM_ORIGINALS_PATH="/photoprism/originals"
|
|||
PHOTOPRISM_IMPORT_PATH="/photoprism/import"
|
||||
PHOTOPRISM_LOG_FILENAME="/photoprism/photoprism.log"
|
||||
PHOTOPRISM_PID_FILENAME="/photoprism/photoprism.pid"
|
||||
PHOTOPRISM_ADMIN_PASSWORD="{{ host.data.photoprism_admin_password }}"
|
||||
PHOTOPRISM_ORIGINALS_LIMIT={{ host.data.photoprism_originals_limit }}
|
||||
PHOTOPRISM_HTTP_COMPRESSION="{{ host.data.photoprism_http_compression }}"
|
||||
PHOTOPRISM_DEBUG="false"
|
||||
PHOTOPRISM_PUBLIC="false"
|
||||
PHOTOPRISM_READONLY="false"
|
||||
PHOTOPRISM_EXPERIMENTAL="false"
|
||||
PHOTOPRISM_DISABLE_WEBDAV="false"
|
||||
PHOTOPRISM_DISABLE_SETTINGS="false"
|
||||
PHOTOPRISM_DISABLE_TENSORFLOW="false"
|
||||
PHOTOPRISM_DISABLE_FACES="false"
|
||||
PHOTOPRISM_DISABLE_CLASSIFICATION="false"
|
||||
PHOTOPRISM_DARKTABLE_PRESETS="false"
|
||||
PHOTOPRISM_DETECT_NSFW="false"
|
||||
PHOTOPRISM_UPLOAD_NSFW="true"
|
||||
PHOTOPRISM_DATABASE_DRIVER="mysql"
|
||||
PHOTOPRISM_DATABASE_SERVER="{{ host.data.photoprism_database_server }}"
|
||||
PHOTOPRISM_DATABASE_NAME="{{ host.data.photoprism_database_name }}"
|
||||
PHOTOPRISM_DATABASE_USER="{{ host.data.photoprism_database_user }}"
|
||||
PHOTOPRISM_DATABASE_PASSWORD="{{ host.data.photoprism_database_password }}"
|
||||
PHOTOPRISM_DETECT_NSFW="false"
|
||||
PHOTOPRISM_EXPERIMENTAL="false"
|
||||
PHOTOPRISM_SITE_URL="http://localhost:2342/"
|
||||
PHOTOPRISM_SITE_TITLE="PhotoPrism"
|
||||
PHOTOPRISM_SITE_CAPTION="Browse Your Life"
|
||||
PHOTOPRISM_SITE_DESCRIPTION=""
|
||||
PHOTOPRISM_SITE_AUTHOR=""
|
||||
HOME="/photoprism"
|
||||
PHOTOPRISM_HTTP_HOST="0.0.0.0"
|
||||
PHOTOPRISM_HTTP_PORT=2342
|
||||
PHOTOPRISM_DATABASE_DRIVER="sqlite"
|
||||
PHOTOPRISM_DATABASE_SERVER=""
|
||||
PHOTOPRISM_DATABASE_NAME="photoprism"
|
||||
PHOTOPRISM_DATABASE_USER="photoprism"
|
||||
PHOTOPRISM_DATABASE_PASSWORD=""
|
||||
PHOTOPRISM_DISABLE_WEBDAV="false"
|
||||
PHOTOPRISM_DISABLE_SETTINGS="false"
|
||||
PHOTOPRISM_DISABLE_BACKUPS="false"
|
||||
PHOTOPRISM_DISABLE_EXIFTOOL="false"
|
||||
PHOTOPRISM_DISABLE_PLACES="false"
|
||||
PHOTOPRISM_DISABLE_TENSORFLOW="false"
|
||||
PHOTOPRISM_DISABLE_FACES="false"
|
||||
PHOTOPRISM_DISABLE_CLASSIFICATION="false"
|
||||
PHOTOPRISM_DARKTABLE_PRESETS="false"
|
||||
PHOTOPRISM_THUMB_FILTER="lanczos"
|
||||
PHOTOPRISM_THUMB_UNCACHED="false"
|
||||
PHOTOPRISM_THUMB_SIZE=2048
|
||||
PHOTOPRISM_THUMB_SIZE_UNCACHED=7680
|
||||
PHOTOPRISM_JPEG_SIZE=7680
|
||||
PHOTOPRISM_JPEG_QUALITY=92
|
||||
PHOTOPRISM_WORKERS=0
|
||||
PHOTOPRISM_WAKEUP_INTERVAL=900
|
||||
PHOTOPRISM_AUTO_INDEX=300
|
||||
PHOTOPRISM_AUTO_IMPORT=300
|
||||
|
||||
# From docker-compose, those that are really supposed to be configured by user
|
||||
PHOTOPRISM_ADMIN_PASSWORD="{{ host.data.photoprism_admin_password }}"
|
||||
PHOTOPRISM_ORIGINALS_LIMIT={{ host.data.photoprism_originals_limit }}
|
||||
PHOTOPRISM_HTTP_COMPRESSION="{{ host.data.photoprism_http_compression }}"
|
||||
PHOTOPRISM_DEBUG="{{ host.data.photoprism_debug }}"
|
||||
PHOTOPRISM_PUBLIC="{{ host.data.photoprism_public }}"
|
||||
PHOTOPRISM_READONLY="{{ host.data.photoprism_readonly }}"
|
||||
PHOTOPRISM_EXPERIMENTAL="{{ host.data.photoprism_experimental }}"
|
||||
PHOTOPRISM_DISABLE_WEBDAV="{{ host.data.photoprism_disable_webdav }}"
|
||||
PHOTOPRISM_DISABLE_SETTINGS="{{ host.data.photoprism_disable_settings }}"
|
||||
PHOTOPRISM_DISABLE_TENSORFLOW="{{ host.data.photoprism_disable_tensorflow }}"
|
||||
PHOTOPRISM_DISABLE_FACES="{{ host.data.photoprism_disable_faces }}"
|
||||
PHOTOPRISM_DISABLE_CLASSIFICATION="{{ host.data.photoprism_disable_classification }}"
|
||||
PHOTOPRISM_DARKTABLE_PRESETS="{{ host.data.photoprism_darktable_presets }}"
|
||||
PHOTOPRISM_DETECT_NSFW="{{ host.data.photoprism_detect_nsfw }}"
|
||||
PHOTOPRISM_UPLOAD_NSFW="{{ host.data.photoprism_upload_nsfw }}"
|
||||
PHOTOPRISM_DATABASE_DRIVER="{{ host.data.photoprism_database_driver }}"
|
||||
PHOTOPRISM_DATABASE_SERVER="{{ host.data.photoprism_database_server }}"
|
||||
PHOTOPRISM_DATABASE_NAME="{{ host.data.photoprism_database_name }}"
|
||||
PHOTOPRISM_DATABASE_USER="{{ host.data.photoprism_database_user }}"
|
||||
PHOTOPRISM_DATABASE_PASSWORD="{{ host.data.photoprism_database_password }}"
|
||||
PHOTOPRISM_SITE_URL="{{ host.data.photoprism_site_url }}"
|
||||
PHOTOPRISM_SITE_TITLE="{{ host.data.photoprism_site_title }}"
|
||||
PHOTOPRISM_SITE_CAPTION="{{ host.data.photoprism_site_caption }}"
|
||||
PHOTOPRISM_SITE_DESCRIPTION="{{ host.data.photoprism_site_description }}"
|
||||
PHOTOPRISM_SITE_AUTHOR="{{ host.data.photoprism_site_author }}"
|
||||
HOME="{{ host.data.photoprism_home }}"
|
||||
|
|
19
templates/photoprism.service.j2
Normal file
19
templates/photoprism.service.j2
Normal file
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=photoprism
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ host.data.unix_user }}
|
||||
Group={{ host.data.unix_group }}
|
||||
StateDirectory={{ host.data.unix_user }}
|
||||
EnvironmentFile={{ host.data.systemd_env }}
|
||||
WorkingDirectory=/photoprism
|
||||
RootDirectory={{ host.data.undocker_dst }}
|
||||
BindPaths={{ host.data.unix_home }}/storage:/photoprism/storage {{ host.data.unix_home }}/originals:/photoprism/originals {{ host.data.unix_home }}/import:/photoprism/import
|
||||
BindReadOnlyPaths=/etc/resolv.conf
|
||||
ExecStart=/photoprism/bin/photoprism start
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Reference in a new issue