vaultwarden: enable automatic updates of docker images

This commit is contained in:
Markus 2024-11-06 19:11:29 +01:00
parent 338c12c687
commit 44f9505bef
5 changed files with 38 additions and 0 deletions

View File

@ -6,6 +6,9 @@
- name: Restart vaultwarden - name: Restart vaultwarden
service: name=vaultwarden state=restarted service: name=vaultwarden state=restarted
- name: Restart vaultwarden-reload
service: name=vaultwarden-reload state=restarted
- name: Restart nginx - name: Restart nginx
service: name=nginx state=restarted service: name=nginx state=restarted

View File

@ -42,9 +42,21 @@
- Reload systemd - Reload systemd
- Restart vaultwarden - Restart vaultwarden
- name: Systemd unit for vaultwarden-reload
template: src=vaultwarden-reload.{{ item }}.j2 dest=/etc/systemd/system/vaultwarden-reload.{{ item }}
with_items:
- "service"
- "timer"
notify:
- Reload systemd
- Restart vaultwarden-reload
- name: Start the vaultwarden service - name: Start the vaultwarden service
service: name=vaultwarden state=started enabled=yes service: name=vaultwarden state=started enabled=yes
- name: Enable auto update timer
service: name=vaultwarden-reload.timer state=started enabled=yes
- name: Enable monitoring - name: Enable monitoring
include_role: name=icinga-monitor tasks_from=http include_role: name=icinga-monitor tasks_from=http
vars: vars:

View File

@ -0,0 +1,7 @@
[Unit]
Description=Refresh vaultwarden images
[Service]
Type=oneshot
ExecStart=/bin/systemctl reload-or-restart vaultwarden.service

View File

@ -0,0 +1,10 @@
[Unit]
Description=Refresh vaultwarden images
Requires=vaultwarden.service
After=vaultwarden.service
[Timer]
OnCalendar=*:0/15
[Install]
WantedBy=timers.target

View File

@ -17,6 +17,8 @@ WorkingDirectory=/opt/vaultwarden
# Make sure no old containers are running # Make sure no old containers are running
ExecStartPre=/usr/bin/docker-compose down -v ExecStartPre=/usr/bin/docker-compose down -v
# Update images
ExecStartPre=-/usr/bin/docker-compose pull --quiet
# Compose up # Compose up
ExecStart=/usr/bin/docker-compose up ExecStart=/usr/bin/docker-compose up
@ -24,5 +26,9 @@ ExecStart=/usr/bin/docker-compose up
# Compose down, remove containers and volumes # Compose down, remove containers and volumes
ExecStop=/usr/bin/docker-compose down -v ExecStop=/usr/bin/docker-compose down -v
# Refresh on reload
ExecReload=-/usr/bin/docker-compose pull --quiet
ExecReload=/usr/bin/docker-compose up -d
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target