- Install dockcheck as a git clone in ~/.local/share/dockcheck with AutoSelfUpdate (git pull also updates notify templates and urls.list); no pinned versions. regctl is refreshed weekly by run_dockcheck.sh. - Since dockcheck ~v0.7, OnlyLabel skips unlabelled containers entirely, so they got no update notices. run_dockcheck.sh now runs twice: update labelled containers quietly, then check everything and notify once. - Running dockcheck.sh by hand now checks everything and changes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
186 lines
5.3 KiB
YAML
186 lines
5.3 KiB
YAML
---
|
|
# Enable cron logging in systemd-journald (already enabled by default)
|
|
# We'll rely on journalctl for cron execution logs
|
|
|
|
# Ensure the script is copied to the target machine
|
|
- name: Copy the warhammer feed update script
|
|
copy:
|
|
src: update_warhammer_feed.sh
|
|
dest: /usr/local/bin/update_warhammer_feed.sh
|
|
mode: '0755'
|
|
owner: root
|
|
group: root
|
|
|
|
# Create the cron job to run the script at 09:10 every day
|
|
- name: Create cron job for warhammer feed update
|
|
cron:
|
|
name: "Update Warhammer RSS Feed"
|
|
minute: "10"
|
|
hour: "9"
|
|
user: root
|
|
job: "/usr/local/bin/update_warhammer_feed.sh"
|
|
|
|
# Create .local/bin directory for phil user
|
|
- name: Ensure .local/bin directory exists for phil
|
|
file:
|
|
path: /home/phil/.local/bin
|
|
state: directory
|
|
mode: '0755'
|
|
owner: phil
|
|
group: phil
|
|
|
|
# --- Dockcheck (container updates) ---
|
|
# dockcheck lives in a git clone and updates itself on every run
|
|
# (AutoSelfUpdate does a `git pull`, which also brings new notify templates
|
|
# and urls.list). Ansible only makes the first clone and never resets it.
|
|
- name: Clone dockcheck
|
|
become_user: phil
|
|
git:
|
|
repo: https://github.com/mag37/dockcheck.git
|
|
dest: /home/phil/.local/share/dockcheck
|
|
version: main
|
|
update: false
|
|
|
|
# Keep the old path working for running it by hand
|
|
- name: Link dockcheck.sh into .local/bin
|
|
file:
|
|
src: /home/phil/.local/share/dockcheck/dockcheck.sh
|
|
dest: /home/phil/.local/bin/dockcheck.sh
|
|
state: link
|
|
force: true
|
|
owner: phil
|
|
group: phil
|
|
|
|
# dockcheck reads release-note links from beside dockcheck.sh; upstream keeps
|
|
# the list in notify_templates/, so link it (and keep git status clean)
|
|
- name: Link urls.list beside dockcheck.sh
|
|
file:
|
|
src: notify_templates/urls.list
|
|
dest: /home/phil/.local/share/dockcheck/urls.list
|
|
state: link
|
|
owner: phil
|
|
group: phil
|
|
|
|
- name: Keep local files out of the dockcheck clone's git status
|
|
copy:
|
|
dest: /home/phil/.local/share/dockcheck/.git/info/exclude
|
|
content: |
|
|
urls.list
|
|
snooze.list
|
|
*.bak
|
|
owner: phil
|
|
group: phil
|
|
mode: '0644'
|
|
|
|
# regctl (dockcheck's registry client) isn't updated by dockcheck;
|
|
# run_dockcheck.sh refreshes it weekly. This only seeds it.
|
|
- name: Install regctl
|
|
get_url:
|
|
url: https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64
|
|
dest: /home/phil/.local/bin/regctl
|
|
mode: '0755'
|
|
owner: phil
|
|
group: phil
|
|
|
|
# Left over from the old download-into-.local/bin install
|
|
- name: Remove the old dockcheck files from .local/bin
|
|
file:
|
|
path: "/home/phil/.local/bin/{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- notify_templates
|
|
- notify_v2.sh
|
|
- urls.list
|
|
- snooze.list
|
|
|
|
- name: Ensure .config directory exists for phil
|
|
file:
|
|
path: /home/phil/.config
|
|
state: directory
|
|
mode: '0755'
|
|
owner: phil
|
|
group: phil
|
|
|
|
- name: Template dockcheck configuration
|
|
template:
|
|
src: dockcheck.config.j2
|
|
dest: /home/phil/.config/dockcheck.config
|
|
mode: '0600'
|
|
owner: phil
|
|
group: phil
|
|
|
|
- name: Create dockcheck log directory
|
|
file:
|
|
path: /var/log/dockcheck
|
|
state: directory
|
|
mode: '0755'
|
|
owner: phil
|
|
group: phil
|
|
|
|
# Two runs: update labelled containers quietly, then check everything and
|
|
# send one Gotify notice for what's left (see dockcheck.config.j2)
|
|
- name: Create dockcheck wrapper script
|
|
copy:
|
|
dest: /home/phil/.local/bin/run_dockcheck.sh
|
|
mode: '0755'
|
|
owner: phil
|
|
group: phil
|
|
content: |
|
|
#!/bin/bash
|
|
# Daily container updates (cron, 08:00). Managed by ansible (roles/cron).
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
log=/var/log/dockcheck/dockcheck.log
|
|
cd "$HOME" || exit 1
|
|
|
|
stamp() { date "+%Y-%m-%d %H:%M:%S"; }
|
|
|
|
# Refresh regctl weekly from its latest release
|
|
regctl="$HOME/.local/bin/regctl"
|
|
if [[ ! -x $regctl || -n $(find "$regctl" -mtime +6) ]]; then
|
|
tmp=$(mktemp)
|
|
if curl -fsSL -o "$tmp" https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 \
|
|
&& chmod 755 "$tmp" && "$tmp" version >/dev/null; then
|
|
mv "$tmp" "$regctl"
|
|
echo "$(stamp) - regctl refreshed: $("$regctl" version --format '{{ "{{" }}.VCSTag{{ "}}" }}')" >> "$log"
|
|
else
|
|
rm -f "$tmp"
|
|
echo "$(stamp) - regctl refresh failed, keeping the current one" >> "$log"
|
|
fi
|
|
fi
|
|
|
|
echo "$(stamp) - Update run (labelled containers)" >> "$log"
|
|
DC_UPDATE=1 "$HOME/.local/bin/dockcheck.sh" >> "$log" 2>&1
|
|
code=$?
|
|
echo "$(stamp) - Update run completed with exit code $code" >> "$log"
|
|
|
|
echo "$(stamp) - Check run (all containers, notifies)" >> "$log"
|
|
DC_NOTIFY=1 "$HOME/.local/bin/dockcheck.sh" >> "$log" 2>&1
|
|
code=$?
|
|
echo "$(stamp) - Check run completed with exit code $code" >> "$log"
|
|
|
|
# The log grows by about 6 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
|
|
}
|
|
|
|
- name: Create cron job for dockcheck container updates
|
|
cron:
|
|
name: "Check Docker container updates"
|
|
minute: "0"
|
|
hour: "8"
|
|
user: phil
|
|
job: "/home/phil/.local/bin/run_dockcheck.sh"
|