From 4074a4598359cec849462f72cc3d63257bf55c0f Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Sun, 1 Oct 2023 19:08:06 +0200 Subject: [PATCH] Tidy up systemd files --- .../templates/systemd/pod-database.service | 7 +++- .../systemd/container-music-archive.service | 36 +++++++++---------- .../container-music-collection.service | 36 +++++++++---------- .../music/templates/systemd/pod-music.service | 7 +++- .../systemd/container-www-nginx.service | 25 +++++++------ .../www/templates/systemd/pod-www.service | 9 +++-- 6 files changed, 67 insertions(+), 53 deletions(-) diff --git a/playbooks/roles/services/deploy/database/templates/systemd/pod-database.service b/playbooks/roles/services/deploy/database/templates/systemd/pod-database.service index beffe76..b767c7d 100644 --- a/playbooks/roles/services/deploy/database/templates/systemd/pod-database.service +++ b/playbooks/roles/services/deploy/database/templates/systemd/pod-database.service @@ -12,7 +12,12 @@ Environment=PODMAN_SYSTEMD_UNIT=%n Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/pod-database.pid %t/pod-database.pod-id -ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/pod-database.pid --pod-id-file %t/pod-database.pod-id --name=database --network=none --replace +ExecStartPre=/usr/bin/podman pod create \ + --infra-conmon-pidfile %t/pod-database.pid \ + --pod-id-file %t/pod-database.pod-id \ + --name=database \ + --network=none \ + --replace ExecStart=/usr/bin/podman pod start --pod-id-file %t/pod-database.pod-id ExecStartPost=/usr/bin/sh -c 'podman inspect --format "{% raw %}{{ .State.Pid }}{% endraw %}" $(podman inspect --format "{% raw %}{{ .InfraContainerID }}{% endraw %}" database) > {{ services_containers_directory }}/pod-database/pidfile' ExecStartPost=/usr/bin/sudo /usr/sbin/ifdown --ignore-errors veth-database diff --git a/playbooks/roles/services/deploy/music/templates/systemd/container-music-archive.service b/playbooks/roles/services/deploy/music/templates/systemd/container-music-archive.service index b24da9a..1c5d091 100644 --- a/playbooks/roles/services/deploy/music/templates/systemd/container-music-archive.service +++ b/playbooks/roles/services/deploy/music/templates/systemd/container-music-archive.service @@ -13,24 +13,24 @@ Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/container-music-archive.pid %t/container-music-archive.ctr-id ExecStart=/usr/bin/podman run \ - --conmon-pidfile %t/container-music-archive.pid \ - --cidfile %t/container-music-archive.ctr-id \ - --cgroups=no-conmon \ - --pod-id-file %t/pod-music.pod-id \ - --replace \ - --label "io.containers.autoupdate=image" \ - --log-driver=journald \ - -dt \ - -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ - -v {{ services_data_directory }}/pod-music/archive/_data:/data \ - -v {{ services_host_services[services_service_name].archive_path }}:/music:ro \ - -e ND_PORT="8080" \ - -e ND_IGNOREDARTICLES="The El La Los Las Le Les Os O A" \ - -e ND_ENABLESTARRATING="false" \ - -e ND_LASTFM_ENABLED="false" \ - -e ND_PASSWORDENCRYPTIONKEY={{ services[services_service_name].password_encryption_key }} \ - --name=pod-music-archive \ - docker.io/deluan/navidrome:{{ services_service_deploy_versions.navidrome }} + --conmon-pidfile %t/container-music-archive.pid \ + --cidfile %t/container-music-archive.ctr-id \ + --cgroups=no-conmon \ + --pod-id-file %t/pod-music.pod-id \ + --replace \ + --label "io.containers.autoupdate=image" \ + --log-driver=journald \ + -dt \ + -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ + -v {{ services_data_directory }}/pod-music/archive/_data:/data \ + -v {{ services_host_services[services_service_name].archive_path }}:/music:ro \ + -e ND_PORT="8080" \ + -e ND_IGNOREDARTICLES="The El La Los Las Le Les Os O A" \ + -e ND_ENABLESTARRATING="false" \ + -e ND_LASTFM_ENABLED="false" \ + -e ND_PASSWORDENCRYPTIONKEY={{ services[services_service_name].password_encryption_key }} \ + --name=pod-music-archive \ + docker.io/deluan/navidrome:{{ services_service_deploy_versions.navidrome }} ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-music-archive.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-music-archive.ctr-id PIDFile=%t/container-music-archive.pid diff --git a/playbooks/roles/services/deploy/music/templates/systemd/container-music-collection.service b/playbooks/roles/services/deploy/music/templates/systemd/container-music-collection.service index 734caba..43fa84c 100644 --- a/playbooks/roles/services/deploy/music/templates/systemd/container-music-collection.service +++ b/playbooks/roles/services/deploy/music/templates/systemd/container-music-collection.service @@ -13,24 +13,24 @@ Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/container-music-collection.pid %t/container-music-collection.ctr-id ExecStart=/usr/bin/podman run \ - --conmon-pidfile %t/container-music-collection.pid \ - --cidfile %t/container-music-collection.ctr-id \ - --cgroups=no-conmon \ - --pod-id-file %t/pod-music.pod-id \ - --replace \ - --label "io.containers.autoupdate=image" \ - --log-driver=journald \ - -dt \ - -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ - -v {{ services_data_directory }}/pod-music/collection/_data:/data \ - -v {{ services_host_services[services_service_name].collection_path }}:/music:ro \ - -e ND_PORT="80" \ - -e ND_IGNOREDARTICLES="The El La Los Las Le Les Os O A" \ - -e ND_ENABLESTARRATING="false" \ - -e ND_LASTFM_ENABLED="false" \ - -e ND_PASSWORDENCRYPTIONKEY={{ services[services_service_name].password_encryption_key }} \ - --name=pod-music-collection \ - docker.io/deluan/navidrome:{{ services_service_deploy_versions.navidrome }} + --conmon-pidfile %t/container-music-collection.pid \ + --cidfile %t/container-music-collection.ctr-id \ + --cgroups=no-conmon \ + --pod-id-file %t/pod-music.pod-id \ + --replace \ + --label "io.containers.autoupdate=image" \ + --log-driver=journald \ + -dt \ + -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ + -v {{ services_data_directory }}/pod-music/collection/_data:/data \ + -v {{ services_host_services[services_service_name].collection_path }}:/music:ro \ + -e ND_PORT="80" \ + -e ND_IGNOREDARTICLES="The El La Los Las Le Les Os O A" \ + -e ND_ENABLESTARRATING="false" \ + -e ND_LASTFM_ENABLED="false" \ + -e ND_PASSWORDENCRYPTIONKEY={{ services[services_service_name].password_encryption_key }} \ + --name=pod-music-collection \ + docker.io/deluan/navidrome:{{ services_service_deploy_versions.navidrome }} ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-music-collection.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-music-collection.ctr-id PIDFile=%t/container-music-collection.pid diff --git a/playbooks/roles/services/deploy/music/templates/systemd/pod-music.service b/playbooks/roles/services/deploy/music/templates/systemd/pod-music.service index 85313aa..f7d47e4 100644 --- a/playbooks/roles/services/deploy/music/templates/systemd/pod-music.service +++ b/playbooks/roles/services/deploy/music/templates/systemd/pod-music.service @@ -12,7 +12,12 @@ Environment=PODMAN_SYSTEMD_UNIT=%n Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/pod-music.pid %t/pod-music.pod-id -ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/pod-music.pid --pod-id-file %t/pod-music.pod-id --name=music --network=none --replace +ExecStartPre=/usr/bin/podman pod create \ + --infra-conmon-pidfile %t/pod-music.pid \ + --pod-id-file %t/pod-music.pod-id \ + --name=music \ + --network=none \ + --replace ExecStart=/usr/bin/podman pod start --pod-id-file %t/pod-music.pod-id ExecStartPost=/usr/bin/sh -c 'podman inspect --format "{% raw %}{{ .State.Pid }}{% endraw %}" $(podman inspect --format "{% raw %}{{ .InfraContainerID }}{% endraw %}" music) > {{ services_containers_directory }}/pod-music/pidfile' ExecStartPost=/usr/bin/sudo /usr/sbin/ifdown --ignore-errors veth-music diff --git a/playbooks/roles/services/deploy/www/templates/systemd/container-www-nginx.service b/playbooks/roles/services/deploy/www/templates/systemd/container-www-nginx.service index 9111ada..bcca96c 100644 --- a/playbooks/roles/services/deploy/www/templates/systemd/container-www-nginx.service +++ b/playbooks/roles/services/deploy/www/templates/systemd/container-www-nginx.service @@ -13,19 +13,18 @@ Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/container-www-nginx.pid %t/container-www-nginx.ctr-id ExecStart=/usr/bin/podman run \ - --conmon-pidfile %t/container-www-nginx.pid \ - --cidfile %t/container-www-nginx.ctr-id \ - --cgroups=no-conmon \ - --pod-id-file \ - %t/pod-www.pod-id \ - --replace \ - --label "io.containers.autoupdate=image" \ - --log-driver=journald \ - -dt \ - -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ - -v ./.config/service/wojciechkozlowski.eu/public:/usr/share/nginx/html:ro \ - --name=pod-www-nginx \ - docker.io/library/nginx:{{ services_service_deploy_versions.nginx }} + --conmon-pidfile %t/container-www-nginx.pid \ + --cidfile %t/container-www-nginx.ctr-id \ + --cgroups=no-conmon \ + --pod-id-file %t/pod-www.pod-id \ + --replace \ + --label "io.containers.autoupdate=image" \ + --log-driver=journald \ + -dt \ + -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ + -v ./.config/service/wojciechkozlowski.eu/public:/usr/share/nginx/html:ro \ + --name=pod-www-nginx \ + docker.io/library/nginx:{{ services_service_deploy_versions.nginx }} ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-www-nginx.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-www-nginx.ctr-id PIDFile=%t/container-www-nginx.pid diff --git a/playbooks/roles/services/deploy/www/templates/systemd/pod-www.service b/playbooks/roles/services/deploy/www/templates/systemd/pod-www.service index 7fbc953..d39b71c 100644 --- a/playbooks/roles/services/deploy/www/templates/systemd/pod-www.service +++ b/playbooks/roles/services/deploy/www/templates/systemd/pod-www.service @@ -12,9 +12,14 @@ Environment=PODMAN_SYSTEMD_UNIT=%n Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/pod-www.pid %t/pod-www.pod-id -ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/pod-www.pid --pod-id-file %t/pod-www.pod-id --name=rproxy --network=none --replace +ExecStartPre=/usr/bin/podman pod create \ + --infra-conmon-pidfile %t/pod-www.pid \ + --pod-id-file %t/pod-www.pod-id \ + --name=www \ + --network=none \ + --replace ExecStart=/usr/bin/podman pod start --pod-id-file %t/pod-www.pod-id -ExecStartPost=/usr/bin/sh -c 'podman inspect --format "{% raw %}{{ .State.Pid }}{% endraw %}" $(podman inspect --format "{% raw %}{{ .InfraContainerID }}{% endraw %}" rproxy) > {{ services_containers_directory }}/pod-www/pidfile' +ExecStartPost=/usr/bin/sh -c 'podman inspect --format "{% raw %}{{ .State.Pid }}{% endraw %}" $(podman inspect --format "{% raw %}{{ .InfraContainerID }}{% endraw %}" www) > {{ services_containers_directory }}/pod-www/pidfile' ExecStartPost=/usr/bin/sudo /usr/sbin/ifdown --ignore-errors veth-www ExecStartPost=/usr/bin/sudo /usr/sbin/ifup veth-www ExecStop=/usr/bin/sudo /usr/sbin/ifdown --ignore-errors veth-www