Files
ansible/roles/cron/tasks/main.yml
T
PhilandClaude Opus 5.5 a5cdfded37 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>
2026-11-03 07:24:43 -07:00

167 lines
4.8 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
# 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
get_url:
url: "https://raw.githubusercontent.com/mag37/dockcheck/{{ dockcheck_version }}/dockcheck.sh"
dest: /home/phil/.local/bin/dockcheck.sh
force: true
mode: '0755'
owner: 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
- name: Ensure .config directory exists for phil
file:
path: /home/phil/.config
state: directory
mode: '0755'
owner: phil
group: phil
# Create notify_templates directory alongside dockcheck.sh
- name: Ensure notify_templates directory exists in .local/bin
file:
path: /home/phil/.local/bin/notify_templates
state: directory
mode: '0755'
owner: phil
group: phil
# Download notify_v2.sh script for dockcheck notifications
- name: Download notify_v2.sh script
get_url:
url: "https://raw.githubusercontent.com/mag37/dockcheck/{{ dockcheck_version }}/notify_templates/notify_v2.sh"
dest: /home/phil/.local/bin/notify_templates/notify_v2.sh
force: true
mode: '0755'
owner: phil
group: phil
# Download notify_gotify.sh script for dockcheck notifications
- name: Download notify_gotify.sh script
get_url:
url: "https://raw.githubusercontent.com/mag37/dockcheck/{{ dockcheck_version }}/notify_templates/notify_gotify.sh"
dest: /home/phil/.local/bin/notify_templates/notify_gotify.sh
force: true
mode: '0755'
owner: phil
group: phil
# Template dockcheck configuration file
- name: Template dockcheck configuration
template:
src: dockcheck.config.j2
dest: /home/phil/.config/dockcheck.config
mode: '0600'
owner: phil
group: phil
# Create log directory for dockcheck
- name: Create dockcheck log directory
file:
path: /var/log/dockcheck
state: directory
mode: '0755'
owner: phil
group: phil
# Create dockcheck wrapper script to avoid cron escaping issues
- name: Create dockcheck wrapper script
copy:
dest: /home/phil/.local/bin/run_dockcheck.sh
mode: '0755'
owner: phil
group: phil
content: |
#!/bin/bash
cd /home/phil
/home/phil/.local/bin/dockcheck.sh >> /var/log/dockcheck/dockcheck.log 2>&1
# 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
- 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"