Add external volume to pod-cloud

This commit is contained in:
Wojciech Kozlowski 2023-04-08 09:24:47 +02:00
parent ee61a4a3cb
commit ce0cbe27af
6 changed files with 42 additions and 4 deletions

View File

@ -258,7 +258,8 @@ class DatasetRepoManager(RepoManager):
def __get_volume_datasets(self, root_dataset): def __get_volume_datasets(self, root_dataset):
zfs_list = subprocess.getoutput( zfs_list = subprocess.getoutput(
f"zfs list -H -r {root_dataset} -o name,mountpoint" f"zfs list -H -r {root_dataset} "
"-o name,mountpoint,eu.wojciechkozlowski:offsite-snapshot"
) )
zfs_list_lines = zfs_list.split('\n') zfs_list_lines = zfs_list.split('\n')
zfs_list_lines_items = map(lambda l: l.split(), zfs_list_lines) zfs_list_lines_items = map(lambda l: l.split(), zfs_list_lines)
@ -269,7 +270,8 @@ class DatasetRepoManager(RepoManager):
dataset, dataset,
mountpoint, mountpoint,
) )
for dataset, mountpoint in zfs_list_lines_items if os.path.ismount(mountpoint) for dataset, mountpoint, offsite_snapshot in zfs_list_lines_items
if os.path.ismount(mountpoint) and (offsite_snapshot.lower() != "false")
] ]
def restore(self): def restore(self):

View File

@ -39,6 +39,7 @@
loop: loop:
- "pod-cloud.service" - "pod-cloud.service"
- "container-cloud-nginx.service" - "container-cloud-nginx.service"
- "container-cloud-chown.service"
- "container-cloud-nextcloud.service" - "container-cloud-nextcloud.service"
- "container-cloud-cron.service" - "container-cloud-cron.service"
register: services_deploy_cloud_systemd_files register: services_deploy_cloud_systemd_files

View File

@ -0,0 +1,28 @@
[Unit]
Description=Podman container-cloud-chown.service
Documentation=man:podman-generate-systemd(1)
After=pod-cloud.service
Before=container-cloud-nextcloud.service container-cloud-cron.service
OnFailure=status-mail@%n.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/container-cloud-chown.pid %t/container-cloud-chown.ctr-id
ExecStart=/usr/bin/podman run \
--conmon-pidfile %t/container-cloud-chown.pid \
--cidfile %t/container-cloud-chown.ctr-id \
--cgroups=no-conmon \
--pod-id-file %t/pod-cloud.pod-id \
--replace \
-v {{ services_data_directory }}/pod-cloud/external/_data:/media/external \
--user=0 \
--entrypoint="/bin/bash" \
--name=pod-cloud-chown \
docker.io/library/nextcloud:{{ services_deploy_versions.cloud.nextcloud }} \
-c "chown -R www-data:www-data /media/external"
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-cloud-chown.ctr-id
Type=oneshot
[Install]
WantedBy=container-cloud-nextcloud.service container-cloud-cron.service

View File

@ -4,7 +4,8 @@ Documentation=man:podman-generate-systemd(1)
Wants=network.target Wants=network.target
After=network-online.target After=network-online.target
BindsTo=pod-cloud.service BindsTo=pod-cloud.service
After=pod-cloud.service Requires=container-cloud-chown.service
After=pod-cloud.service container-cloud-chown.service
OnFailure=status-mail@%n.service OnFailure=status-mail@%n.service
[Service] [Service]
@ -24,6 +25,7 @@ ExecStart=/usr/bin/podman run \
-v {{ services_root_directory }}/{{ services_resolv_host }}-resolv.conf:/etc/resolv.conf:ro \ -v {{ services_root_directory }}/{{ services_resolv_host }}-resolv.conf:/etc/resolv.conf:ro \
-v {{ services_data_directory }}/pod-cloud/nextcloud/_data:/var/www/html \ -v {{ services_data_directory }}/pod-cloud/nextcloud/_data:/var/www/html \
-v {{ services_data_directory }}/pod-cloud/data/_data:/var/www/html/data \ -v {{ services_data_directory }}/pod-cloud/data/_data:/var/www/html/data \
-v {{ services_data_directory }}/pod-cloud/external/_data:/media/external \
--name=pod-cloud-cron \ --name=pod-cloud-cron \
docker.io/library/nextcloud:{{ services_deploy_versions.cloud.nextcloud }} \ docker.io/library/nextcloud:{{ services_deploy_versions.cloud.nextcloud }} \
/cron.sh /cron.sh

View File

@ -4,7 +4,8 @@ Documentation=man:podman-generate-systemd(1)
Wants=network.target Wants=network.target
After=network-online.target After=network-online.target
BindsTo=pod-cloud.service BindsTo=pod-cloud.service
After=pod-cloud.service Requires=container-cloud-chown.service
After=pod-cloud.service container-cloud-chown.service
OnFailure=status-mail@%n.service OnFailure=status-mail@%n.service
[Service] [Service]
@ -24,6 +25,7 @@ ExecStart=/usr/bin/podman run \
-v {{ services_root_directory }}/{{ services_resolv_host }}-resolv.conf:/etc/resolv.conf:ro \ -v {{ services_root_directory }}/{{ services_resolv_host }}-resolv.conf:/etc/resolv.conf:ro \
-v {{ services_data_directory }}/pod-cloud/nextcloud/_data:/var/www/html \ -v {{ services_data_directory }}/pod-cloud/nextcloud/_data:/var/www/html \
-v {{ services_data_directory }}/pod-cloud/data/_data:/var/www/html/data \ -v {{ services_data_directory }}/pod-cloud/data/_data:/var/www/html/data \
-v {{ services_data_directory }}/pod-cloud/external/_data:/media/external \
-v ./.config/pod-cloud/database.name:/run/secrets/database.name:ro \ -v ./.config/pod-cloud/database.name:/run/secrets/database.name:ro \
-v ./.config/pod-cloud/database.user:/run/secrets/database.user:ro \ -v ./.config/pod-cloud/database.user:/run/secrets/database.user:ro \
-v ./.config/pod-cloud/database.password:/run/secrets/database.password:ro \ -v ./.config/pod-cloud/database.password:/run/secrets/database.password:ro \

View File

@ -16,6 +16,9 @@ services_volumes:
cloud: cloud:
nextcloud: nextcloud:
data: data:
external:
extra_zfs_properties:
"eu.wojciechkozlowski:offsite-snapshot=false"
git: git:
data: data:
notes: notes: