diff --git a/roles/hedgedoc/handlers/main.yml b/roles/hedgedoc/handlers/main.yml index 2d580c8..e6dc1ed 100644 --- a/roles/hedgedoc/handlers/main.yml +++ b/roles/hedgedoc/handlers/main.yml @@ -6,6 +6,9 @@ - name: Restart hedgedoc service: name=hedgedoc state=restarted +- name: Restart hedgedoc-reload + service: name=hedgedoc-reload state=restarted + - name: Restart nginx service: name=nginx state=restarted diff --git a/roles/hedgedoc/tasks/main.yml b/roles/hedgedoc/tasks/main.yml index f9b5dda..e6e49be 100644 --- a/roles/hedgedoc/tasks/main.yml +++ b/roles/hedgedoc/tasks/main.yml @@ -42,9 +42,21 @@ - Reload systemd - Restart hedgedoc +- name: Systemd unit for hedgedoc-reload + template: src=hedgedoc-reload.{{ item }}.j2 dest=/etc/systemd/system/hedgedoc-reload.{{ item }} + with_items: + - "service" + - "timer" + notify: + - Reload systemd + - Restart hedgedoc-reload + - name: Start the hedgedoc service service: name=hedgedoc state=started enabled=yes +- name: Enable auto update timer + service: name=hedgedoc-reload.timer state=started enabled=yes + - name: Enable monitoring include_role: name=icinga-monitor tasks_from=http vars: diff --git a/roles/hedgedoc/templates/docker-compose.yml.j2 b/roles/hedgedoc/templates/docker-compose.yml.j2 index 17b8d37..30f808c 100644 --- a/roles/hedgedoc/templates/docker-compose.yml.j2 +++ b/roles/hedgedoc/templates/docker-compose.yml.j2 @@ -1,4 +1,5 @@ -version: "3" +--- +version: "3.4" services: database: image: postgres:13-alpine diff --git a/roles/hedgedoc/templates/hedgedoc-reload.service.j2 b/roles/hedgedoc/templates/hedgedoc-reload.service.j2 new file mode 100644 index 0000000..62566b3 --- /dev/null +++ b/roles/hedgedoc/templates/hedgedoc-reload.service.j2 @@ -0,0 +1,7 @@ +[Unit] +Description=Refresh hedgedoc images + +[Service] +Type=oneshot + +ExecStart=/bin/systemctl reload-or-restart hedgedoc.service diff --git a/roles/hedgedoc/templates/hedgedoc-reload.timer.j2 b/roles/hedgedoc/templates/hedgedoc-reload.timer.j2 new file mode 100644 index 0000000..6add452 --- /dev/null +++ b/roles/hedgedoc/templates/hedgedoc-reload.timer.j2 @@ -0,0 +1,10 @@ +[Unit] +Description=Refresh authentik images +Requires=authentik.service +After=authentik.service + +[Timer] +OnCalendar=*:0/15 + +[Install] +WantedBy=timers.target diff --git a/roles/hedgedoc/templates/hedgedoc.service.j2 b/roles/hedgedoc/templates/hedgedoc.service.j2 index fda3d9a..5cbdbda 100644 --- a/roles/hedgedoc/templates/hedgedoc.service.j2 +++ b/roles/hedgedoc/templates/hedgedoc.service.j2 @@ -17,6 +17,8 @@ WorkingDirectory=/opt/hedgedoc # Make sure no old containers are running ExecStartPre=/usr/bin/docker-compose down -v +# Update images +ExecStartPre=-/usr/bin/docker-compose pull --quiet # Compose up ExecStart=/usr/bin/docker-compose up @@ -24,5 +26,9 @@ ExecStart=/usr/bin/docker-compose up # Compose down, remove containers and volumes 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] WantedBy=multi-user.target