cron: refresh dockcheck setup
- Pin dockcheck (v0.8.3) and regctl (v0.11.7) and re-download on version bumps; get_url never replaced existing files, and dockcheck never updates regctl itself (server had regctl v0.8.3 from June 2025) - New options: DaysOld=3, BackupForDays=7 (rollback), MaxAsync=10, MonoMode for the log, PrintReleaseURL with upstream urls.list - Drop authentik-postgresql-1 from Exclude (container is gone) - Wrapper logged exit code 0 always ($? read after $(date)); fixed - Rotate /var/log/dockcheck/dockcheck.log weekly - Remove stale ~/.local/bin/notify_v2.sh Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b914460b72
commit
a5cdfded37
4 files changed
+93
-10
No files matched your search
+10
-3
@@ -11,15 +11,22 @@ jobs on the server, never on the machine running Ansible.
|
|||||||
| 09:10 daily | root | `/usr/local/bin/update_warhammer_feed.sh`: Warhammer RSS feed |
|
| 09:10 daily | root | `/usr/local/bin/update_warhammer_feed.sh`: Warhammer RSS feed |
|
||||||
|
|
||||||
### Dockcheck (container updates)
|
### Dockcheck (container updates)
|
||||||
- Downloads [dockcheck](https://github.com/mag37/dockcheck) and its Gotify
|
- Installs [dockcheck](https://github.com/mag37/dockcheck), its Gotify notify
|
||||||
notify templates into `/home/phil/.local/bin/`.
|
templates, `urls.list` and `regctl` into `/home/phil/.local/bin/`, pinned
|
||||||
|
to `dockcheck_version` and `regctl_version` in `defaults/main.yml`. Bump
|
||||||
|
those and run `bin/deploy --tags cron` to upgrade.
|
||||||
- Templates `/home/phil/.config/dockcheck.config` from `dockcheck.config.j2`
|
- Templates `/home/phil/.config/dockcheck.config` from `dockcheck.config.j2`
|
||||||
(Gotify token from `vault_dockcheck`).
|
(Gotify token from `vault_dockcheck`).
|
||||||
- Settings: `OnlyLabel=true` and `AutoMode=true`, so containers labelled
|
- Settings: `OnlyLabel=true` and `AutoMode=true`, so containers labelled
|
||||||
`mag37.dockcheck.update=true` are pulled and recreated automatically; any
|
`mag37.dockcheck.update=true` are pulled and recreated automatically; any
|
||||||
other container with an update gets a Gotify notice. `dawarich_db` and
|
other container with an update gets a Gotify notice. `dawarich_db` and
|
||||||
`dawarich_redis` are skipped.
|
`dawarich_redis` are skipped.
|
||||||
- `run_dockcheck.sh` logs to `/var/log/dockcheck/dockcheck.log`.
|
- `DaysOld=3`: images newer than 3 days wait for a later run.
|
||||||
|
- `BackupForDays=7`: the replaced image is kept for 7 days for rollback.
|
||||||
|
List backups with `dockcheck.sh -B` (or `docker images | grep _`);
|
||||||
|
to roll back, retag the backup and recreate the container.
|
||||||
|
- `run_dockcheck.sh` logs to `/var/log/dockcheck/dockcheck.log`, rotated
|
||||||
|
weekly (a year kept).
|
||||||
|
|
||||||
To see what needs updating by hand, run dockcheck on the server:
|
To see what needs updating by hand, run dockcheck on the server:
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# Pinned so a deploy installs a known version. Bump these to upgrade:
|
||||||
|
# https://github.com/mag37/dockcheck/releases
|
||||||
|
# https://github.com/regclient/regclient/releases (regctl, which dockcheck uses to query registries)
|
||||||
|
dockcheck_version: v0.8.3
|
||||||
|
regctl_version: v0.11.7
|
||||||
@@ -29,15 +29,44 @@
|
|||||||
owner: phil
|
owner: phil
|
||||||
group: phil
|
group: phil
|
||||||
|
|
||||||
# Install dockcheck script in phil's .local/bin
|
# Install dockcheck in phil's .local/bin, pinned to dockcheck_version.
|
||||||
|
# force: a version bump replaces the file (get_url otherwise never re-downloads).
|
||||||
- name: Download dockcheck.sh script
|
- name: Download dockcheck.sh script
|
||||||
get_url:
|
get_url:
|
||||||
url: https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh
|
url: "https://raw.githubusercontent.com/mag37/dockcheck/{{ dockcheck_version }}/dockcheck.sh"
|
||||||
dest: /home/phil/.local/bin/dockcheck.sh
|
dest: /home/phil/.local/bin/dockcheck.sh
|
||||||
|
force: true
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
owner: phil
|
owner: phil
|
||||||
group: phil
|
group: phil
|
||||||
|
|
||||||
|
# dockcheck only downloads regctl when it's missing, so it never updates by itself
|
||||||
|
- name: Download regctl
|
||||||
|
get_url:
|
||||||
|
url: "https://github.com/regclient/regclient/releases/download/{{ regctl_version }}/regctl-linux-amd64"
|
||||||
|
dest: /home/phil/.local/bin/regctl
|
||||||
|
force: true
|
||||||
|
mode: '0755'
|
||||||
|
owner: phil
|
||||||
|
group: phil
|
||||||
|
|
||||||
|
# Release-note links for known images, shown with each update (PrintReleaseURL).
|
||||||
|
# dockcheck reads it from beside dockcheck.sh.
|
||||||
|
- name: Download dockcheck release-note URL list
|
||||||
|
get_url:
|
||||||
|
url: "https://raw.githubusercontent.com/mag37/dockcheck/{{ dockcheck_version }}/notify_templates/urls.list"
|
||||||
|
dest: /home/phil/.local/bin/urls.list
|
||||||
|
force: true
|
||||||
|
mode: '0644'
|
||||||
|
owner: phil
|
||||||
|
group: phil
|
||||||
|
|
||||||
|
# Left over from an old install; dockcheck reads notify_templates/notify_v2.sh
|
||||||
|
- name: Remove stale notify_v2.sh beside dockcheck.sh
|
||||||
|
file:
|
||||||
|
path: /home/phil/.local/bin/notify_v2.sh
|
||||||
|
state: absent
|
||||||
|
|
||||||
# Create .config directory for phil user
|
# Create .config directory for phil user
|
||||||
- name: Ensure .config directory exists for phil
|
- name: Ensure .config directory exists for phil
|
||||||
file:
|
file:
|
||||||
@@ -59,8 +88,9 @@
|
|||||||
# Download notify_v2.sh script for dockcheck notifications
|
# Download notify_v2.sh script for dockcheck notifications
|
||||||
- name: Download notify_v2.sh script
|
- name: Download notify_v2.sh script
|
||||||
get_url:
|
get_url:
|
||||||
url: https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_v2.sh
|
url: "https://raw.githubusercontent.com/mag37/dockcheck/{{ dockcheck_version }}/notify_templates/notify_v2.sh"
|
||||||
dest: /home/phil/.local/bin/notify_templates/notify_v2.sh
|
dest: /home/phil/.local/bin/notify_templates/notify_v2.sh
|
||||||
|
force: true
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
owner: phil
|
owner: phil
|
||||||
group: phil
|
group: phil
|
||||||
@@ -68,8 +98,9 @@
|
|||||||
# Download notify_gotify.sh script for dockcheck notifications
|
# Download notify_gotify.sh script for dockcheck notifications
|
||||||
- name: Download notify_gotify.sh script
|
- name: Download notify_gotify.sh script
|
||||||
get_url:
|
get_url:
|
||||||
url: https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_gotify.sh
|
url: "https://raw.githubusercontent.com/mag37/dockcheck/{{ dockcheck_version }}/notify_templates/notify_gotify.sh"
|
||||||
dest: /home/phil/.local/bin/notify_templates/notify_gotify.sh
|
dest: /home/phil/.local/bin/notify_templates/notify_gotify.sh
|
||||||
|
force: true
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
owner: phil
|
owner: phil
|
||||||
group: phil
|
group: phil
|
||||||
@@ -103,7 +134,27 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd /home/phil
|
cd /home/phil
|
||||||
/home/phil/.local/bin/dockcheck.sh >> /var/log/dockcheck/dockcheck.log 2>&1
|
/home/phil/.local/bin/dockcheck.sh >> /var/log/dockcheck/dockcheck.log 2>&1
|
||||||
echo "$(date "+%Y-%m-%d %H:%M:%S") - Dockcheck completed with exit code $?" >> /var/log/dockcheck/dockcheck.log
|
# Save the code first: $(date) inside the echo would reset $?
|
||||||
|
code=$?
|
||||||
|
echo "$(date "+%Y-%m-%d %H:%M:%S") - Dockcheck completed with exit code $code" >> /var/log/dockcheck/dockcheck.log
|
||||||
|
|
||||||
|
# The log grows by about 3 MB a year; keep a year in weekly files
|
||||||
|
- name: Rotate the dockcheck log
|
||||||
|
copy:
|
||||||
|
dest: /etc/logrotate.d/dockcheck
|
||||||
|
mode: '0644'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
content: |
|
||||||
|
/var/log/dockcheck/dockcheck.log {
|
||||||
|
weekly
|
||||||
|
rotate 52
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
su phil phil
|
||||||
|
}
|
||||||
|
|
||||||
# Create cron job for dockcheck as phil user with logging
|
# Create cron job for dockcheck as phil user with logging
|
||||||
- name: Create cron job for dockcheck container updates
|
- name: Create cron job for dockcheck container updates
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Dockcheck Configuration
|
# Dockcheck Configuration (options: default.config in mag37/dockcheck)
|
||||||
# Auto-updates containers labelled mag37.dockcheck.update=true, and sends a
|
# Auto-updates containers labelled mag37.dockcheck.update=true, and sends a
|
||||||
# Gotify notice for anything else with an update. Uncomment DontUpdate to
|
# Gotify notice for anything else with an update. Uncomment DontUpdate to
|
||||||
# only check.
|
# only check.
|
||||||
@@ -6,6 +6,25 @@
|
|||||||
OnlyLabel=true
|
OnlyLabel=true
|
||||||
AutoMode=true
|
AutoMode=true
|
||||||
|
|
||||||
|
# Only take an image once it's at least this many days old, so a broken
|
||||||
|
# release has time to be fixed before it's applied unattended. Newer ones are
|
||||||
|
# listed with a "+" and their age, and picked up on a later run.
|
||||||
|
DaysOld="3"
|
||||||
|
|
||||||
|
# Keep the replaced image for 7 days (tagged <date>_<tag>) so a bad update
|
||||||
|
# can be rolled back, then delete it. With backups on, dockcheck doesn't
|
||||||
|
# prune dangling images (AutoPrune has no effect).
|
||||||
|
BackupForDays=7
|
||||||
|
|
||||||
|
# Check registries in parallel
|
||||||
|
MaxAsync=10
|
||||||
|
|
||||||
|
# Plain output for the cron log: no colour codes or progress bar
|
||||||
|
MonoMode=true
|
||||||
|
|
||||||
|
# Add release-note links (from urls.list) to each update listed
|
||||||
|
PrintReleaseURL=true
|
||||||
|
|
||||||
# Enable notifications
|
# Enable notifications
|
||||||
Notify=true
|
Notify=true
|
||||||
|
|
||||||
@@ -17,4 +36,4 @@ NOTIFY_CHANNELS="gotify"
|
|||||||
|
|
||||||
# Gotify notification configuration
|
# Gotify notification configuration
|
||||||
GOTIFY_DOMAIN="https://{{ subdomains.gotify }}"
|
GOTIFY_DOMAIN="https://{{ subdomains.gotify }}"
|
||||||
GOTIFY_TOKEN="{{ vault_dockcheck.gotify_token }}"
|
GOTIFY_TOKEN="{{ vault_dockcheck.gotify_token }}"
|
||||||
Reference in new issue
Block a user