diff --git a/playbooks/roles/services/deploy/cloud/tasks/main.yml b/playbooks/roles/services/deploy/cloud/tasks/main.yml index af43f06..74e258d 100644 --- a/playbooks/roles/services/deploy/cloud/tasks/main.yml +++ b/playbooks/roles/services/deploy/cloud/tasks/main.yml @@ -32,6 +32,7 @@ loop: - "pod-cloud.service" - "container-cloud-nginx.service" + - "container-cloud-redis.service" - "container-cloud-chown.service" - "container-cloud-nextcloud.service" - "container-cloud-cron.service" diff --git a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-chown.service b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-chown.service index e8b67f0..6c7dbd9 100644 --- a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-chown.service +++ b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-chown.service @@ -10,19 +10,19 @@ 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/nextcloud/_data:/var/www/html \ - -v {{ services_data_directory }}/pod-cloud/data/_data:/var/www/html/data \ - -v {{ services_data_directory }}/pod-cloud/external/_data:/media/external \ - --user=0 \ - --entrypoint="/bin/bash" \ - --name=pod-cloud-chown \ - docker.io/library/nextcloud:{{ services_service_deploy_versions.nextcloud }} \ - -c "chown -R www-data:www-data /var/www/html /media/external" + --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/nextcloud/_data:/var/www/html \ + -v {{ services_data_directory }}/pod-cloud/data/_data:/var/www/html/data \ + -v {{ services_data_directory }}/pod-cloud/external/_data:/media/external \ + --user=0 \ + --entrypoint="/bin/bash" \ + --name=pod-cloud-chown \ + docker.io/library/nextcloud:{{ services_service_deploy_versions.nextcloud }} \ + -c "chown -R www-data:www-data /var/www/html /media/external" ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-cloud-chown.ctr-id Type=oneshot diff --git a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-cron.service b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-cron.service index 17142c8..bf43c58 100644 --- a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-cron.service +++ b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-cron.service @@ -14,23 +14,23 @@ Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/container-cloud-cron.pid %t/container-cloud-cron.ctr-id ExecStart=/usr/bin/podman run \ - --conmon-pidfile %t/container-cloud-cron.pid \ - --cidfile %t/container-cloud-cron.ctr-id \ - --cgroups=no-conmon \ - --pod-id-file %t/pod-cloud.pod-id \ - --replace \ - --label "io.containers.autoupdate=image" \ - --log-driver=journald \ - -dt \ - --add-host=pod-database:{{ services_all_services['database'].inet_address }} \ - --add-host=pod-database:{{ services_all_services['database'].inet6_address }} \ - -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ - -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/external/_data:/media/external \ - --name=pod-cloud-cron \ - docker.io/library/nextcloud:{{ services_service_deploy_versions.nextcloud }} \ - /cron.sh + --conmon-pidfile %t/container-cloud-cron.pid \ + --cidfile %t/container-cloud-cron.ctr-id \ + --cgroups=no-conmon \ + --pod-id-file %t/pod-cloud.pod-id \ + --replace \ + --label "io.containers.autoupdate=image" \ + --log-driver=journald \ + -dt \ + --add-host=pod-database:{{ services_all_services['database'].inet_address }} \ + --add-host=pod-database:{{ services_all_services['database'].inet6_address }} \ + -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ + -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/external/_data:/media/external \ + --name=pod-cloud-cron \ + docker.io/library/nextcloud:{{ services_service_deploy_versions.nextcloud }} \ + /cron.sh ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-cloud-cron.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-cloud-cron.ctr-id PIDFile=%t/container-cloud-cron.pid diff --git a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-nextcloud.service b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-nextcloud.service index 27da2ca..199f5be 100644 --- a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-nextcloud.service +++ b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-nextcloud.service @@ -4,8 +4,8 @@ Documentation=man:podman-generate-systemd(1) Wants=network.target After=network-online.target BindsTo=pod-cloud.service -Requires=container-cloud-chown.service -After=pod-cloud.service container-cloud-chown.service +Requires=container-cloud-chown.service container-cloud-redis.service +After=pod-cloud.service container-cloud-chown.service container-cloud-redis.service OnFailure=status-mail@%n.service [Service] @@ -14,39 +14,40 @@ Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/container-cloud-nextcloud.pid %t/container-cloud-nextcloud.ctr-id ExecStart=/usr/bin/podman run \ - --conmon-pidfile %t/container-cloud-nextcloud.pid \ - --cidfile %t/container-cloud-nextcloud.ctr-id \ - --cgroups=no-conmon \ - --pod-id-file %t/pod-cloud.pod-id \ - --replace \ - --label "io.containers.autoupdate=image" \ - --log-driver=journald \ - -dt \ - --add-host=pod-database:{{ services_all_services['database'].inet_address }} \ - --add-host=pod-database:{{ services_all_services['database'].inet6_address }} \ - -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ - -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/external/_data:/media/external \ - -v ./.config/service/database.name:/run/secrets/database.name:ro \ - -v ./.config/service/database.user:/run/secrets/database.user:ro \ - -v ./.config/service/database.password:/run/secrets/database.password:ro \ - -e POSTGRES_HOST=pod-database:5432 \ - -e POSTGRES_DB_FILE=/run/secrets/database.name \ - -e POSTGRES_USER_FILE=/run/secrets/database.user \ - -e POSTGRES_PASSWORD_FILE=/run/secrets/database.password \ - -e NEXTCLOUD_TRUSTED_DOMAINS="{{ services[services_service_name].domain }}" \ - -e OVERWRITEPROTOCOL="https" \ - -e SMTP_HOST="{{ services[services_service_name].smtp.host }}" \ - -e SMTP_SECURE="ssl" \ - -e SMTP_PORT=465 \ - -e SMTP_AUTHTYPE="PLAIN" \ - -e SMTP_NAME="{{ services[services_service_name].smtp.user }}" \ - -e SMTP_PASSWORD="{{ services[services_service_name].smtp.password }}" \ - -e MAIL_FROM_ADDRESS="cloud" \ - -e MAIL_DOMAIN="{{ services[services_service_name].domain }}" \ - --name=pod-cloud-nextcloud \ - docker.io/library/nextcloud:{{ services_service_deploy_versions.nextcloud }} + --conmon-pidfile %t/container-cloud-nextcloud.pid \ + --cidfile %t/container-cloud-nextcloud.ctr-id \ + --cgroups=no-conmon \ + --pod-id-file %t/pod-cloud.pod-id \ + --replace \ + --label "io.containers.autoupdate=image" \ + --log-driver=journald \ + -dt \ + --add-host=pod-database:{{ services_all_services['database'].inet_address }} \ + --add-host=pod-database:{{ services_all_services['database'].inet6_address }} \ + -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ + -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/external/_data:/media/external \ + -v ./.config/service/database.name:/run/secrets/database.name:ro \ + -v ./.config/service/database.user:/run/secrets/database.user:ro \ + -v ./.config/service/database.password:/run/secrets/database.password:ro \ + -e POSTGRES_HOST=pod-database:5432 \ + -e POSTGRES_DB_FILE=/run/secrets/database.name \ + -e POSTGRES_USER_FILE=/run/secrets/database.user \ + -e POSTGRES_PASSWORD_FILE=/run/secrets/database.password \ + -e REDIS_HOST=localhost \ + -e NEXTCLOUD_TRUSTED_DOMAINS="{{ services[services_service_name].domain }}" \ + -e OVERWRITEPROTOCOL="https" \ + -e SMTP_HOST="{{ services[services_service_name].smtp.host }}" \ + -e SMTP_SECURE="ssl" \ + -e SMTP_PORT=465 \ + -e SMTP_AUTHTYPE="PLAIN" \ + -e SMTP_NAME="{{ services[services_service_name].smtp.user }}" \ + -e SMTP_PASSWORD="{{ services[services_service_name].smtp.password }}" \ + -e MAIL_FROM_ADDRESS="cloud" \ + -e MAIL_DOMAIN="{{ services[services_service_name].domain }}" \ + --name=pod-cloud-nextcloud \ + docker.io/library/nextcloud:{{ services_service_deploy_versions.nextcloud }} ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-cloud-nextcloud.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-cloud-nextcloud.ctr-id PIDFile=%t/container-cloud-nextcloud.pid diff --git a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-nginx.service b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-nginx.service index d2871d9..29e4af3 100644 --- a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-nginx.service +++ b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-nginx.service @@ -4,7 +4,7 @@ Documentation=man:podman-generate-systemd(1) Wants=network.target After=network-online.target BindsTo=pod-cloud.service -After=pod-cloud.service +After=pod-cloud.service pod-cloud-nextcloud.service OnFailure=status-mail@%n.service [Service] @@ -13,20 +13,20 @@ Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/container-cloud-nginx.pid %t/container-cloud-nginx.ctr-id ExecStart=/usr/bin/podman run \ - --conmon-pidfile %t/container-cloud-nginx.pid \ - --cidfile %t/container-cloud-nginx.ctr-id \ - --cgroups=no-conmon \ - --pod-id-file %t/pod-cloud.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/nginx.conf:/etc/nginx/nginx.conf:ro \ - -v {{ services_data_directory }}/pod-cloud/nextcloud/_data:/var/www/html \ - -v {{ services_data_directory }}/pod-cloud/data/_data:/var/www/html/data \ - --name=pod-cloud-nginx \ - docker.io/library/nginx:{{ services_service_deploy_versions.nginx }} + --conmon-pidfile %t/container-cloud-nginx.pid \ + --cidfile %t/container-cloud-nginx.ctr-id \ + --cgroups=no-conmon \ + --pod-id-file %t/pod-cloud.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/nginx.conf:/etc/nginx/nginx.conf:ro \ + -v {{ services_data_directory }}/pod-cloud/nextcloud/_data:/var/www/html \ + -v {{ services_data_directory }}/pod-cloud/data/_data:/var/www/html/data \ + --name=pod-cloud-nginx \ + docker.io/library/nginx:{{ services_service_deploy_versions.nginx }} ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-cloud-nginx.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-cloud-nginx.ctr-id PIDFile=%t/container-cloud-nginx.pid diff --git a/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-redis.service b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-redis.service new file mode 100644 index 0000000..4552a8a --- /dev/null +++ b/playbooks/roles/services/deploy/cloud/templates/systemd/container-cloud-redis.service @@ -0,0 +1,34 @@ +[Unit] +Description=Podman container-cloud-redis.service +Documentation=man:podman-generate-systemd(1) +Wants=network.target +After=network-online.target +BindsTo=pod-cloud.service +After=pod-cloud.service +Before=pod-cloud-nextcloud.service +OnFailure=status-mail@%n.service + +[Service] +Environment=PODMAN_SYSTEMD_UNIT=%n +Restart=on-failure +TimeoutStopSec=70 +ExecStartPre=/bin/rm -f %t/container-cloud-redis.pid %t/container-cloud-redis.ctr-id +ExecStart=/usr/bin/podman run \ + --conmon-pidfile %t/container-cloud-redis.pid \ + --cidfile %t/container-cloud-redis.ctr-id \ + --cgroups=no-conmon \ + --pod-id-file %t/pod-cloud.pod-id \ + --replace \ + --label "io.containers.autoupdate=image" \ + --log-driver=journald \ + -dt \ + -v {{ system_etc_root_directory }}/resolv.conf:/etc/resolv.conf:ro \ + --name=pod-cloud-redis \ + docker.io/library/redis:{{ services_service_deploy_versions.redis }} +ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-cloud-redis.ctr-id -t 10 +ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-cloud-redis.ctr-id +PIDFile=%t/container-cloud-redis.pid +Type=forking + +[Install] +WantedBy=multi-user.target default.target diff --git a/playbooks/roles/services/deploy/cloud/templates/systemd/pod-cloud.service b/playbooks/roles/services/deploy/cloud/templates/systemd/pod-cloud.service index 53005ba..975f612 100644 --- a/playbooks/roles/services/deploy/cloud/templates/systemd/pod-cloud.service +++ b/playbooks/roles/services/deploy/cloud/templates/systemd/pod-cloud.service @@ -3,8 +3,8 @@ Description=Podman pod-cloud.service Documentation=man:podman-generate-systemd(1) Wants=network.target After=network-online.target -Requires=container-cloud-nginx.service container-cloud-nextcloud.service container-cloud-cron.service -Before=container-cloud-nginx.service container-cloud-nextcloud.service container-cloud-cron.service +Requires=container-cloud-nginx.service container-cloud-redis.service container-cloud-nextcloud.service container-cloud-cron.service +Before=container-cloud-nginx.service container-cloud-redis.service container-cloud-nextcloud.service container-cloud-cron.service OnFailure=status-mail@%n.service [Service] diff --git a/playbooks/vars/services/deploy/versions.yml b/playbooks/vars/services/deploy/versions.yml index 3fb29bc..23c1708 100644 --- a/playbooks/vars/services/deploy/versions.yml +++ b/playbooks/vars/services/deploy/versions.yml @@ -12,6 +12,7 @@ services_deploy_versions: cloud: nginx: "stable" nextcloud: "27-fpm" + redis: "7" git: gitea: "1" notes: