From 2d23b9c47098bc1adf5d2333c9c5e3adc9ec80ca Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 11 Nov 2026 06:59:37 -0700 Subject: [PATCH] Mac: weekly Hermes update notice on Telegram Hermes has no auto-update for itself, and /update from Telegram can leave a launchd gateway offline. Instead, a no-agent Hermes cron job runs `hermes update --check` on Mondays at 09:07 and messages Telegram only when a new stable release is out (a failing check sends an error alert). Adds hermes_cron_jobs (scripts in files/hermes-scripts/, copied to ~/.hermes/scripts/; jobs created when missing) so the deal checker can follow the same pattern. Co-Authored-By: Claude Opus 5.5 --- group_vars/mac/main.yml | 10 +++++++ roles/mac/README.md | 5 ++++ .../hermes-scripts/hermes-update-notice.sh | 14 ++++++++++ roles/mac/tasks/hermes-cron.yml | 27 +++++++++++++++++++ roles/mac/tasks/main.yml | 4 +++ 5 files changed, 60 insertions(+) create mode 100644 roles/mac/files/hermes-scripts/hermes-update-notice.sh create mode 100644 roles/mac/tasks/hermes-cron.yml diff --git a/group_vars/mac/main.yml b/group_vars/mac/main.yml index 3d8633e..0c6c78c 100644 --- a/group_vars/mac/main.yml +++ b/group_vars/mac/main.yml @@ -29,3 +29,13 @@ hermes_dashboard_username: admin # ~/.hermes/config.yaml stays Hermes's own (its updates migrate that file). hermes_settings: updates.pre_update_backup: full # zip of ~/.hermes before every update + +# Hermes cron jobs. `script` is a file in roles/mac/files/hermes-scripts/, +# copied to ~/.hermes/scripts/. Jobs are created when missing; to change one, +# edit or remove it in Hermes (`hermes cron edit|remove `) and redeploy. +hermes_cron_jobs: + - name: hermes-update-notice + schedule: "7 9 * * 1" # Mondays 09:07 + script: hermes-update-notice.sh + no_agent: true # just the script's output, no model + deliver: telegram diff --git a/roles/mac/README.md b/roles/mac/README.md index cbe8697..f402db5 100644 --- a/roles/mac/README.md +++ b/roles/mac/README.md @@ -26,6 +26,11 @@ Manages cogitator-02, an Apple Silicon Mac on the tailnet (`mac.yml`, `hermes_settings` (`group_vars/mac/main.yml`), checked with `hermes config get` and fixed with `hermes config set`. Today: a full backup of `~/.hermes` before every `hermes update`. +- **Hermes cron jobs** (tag `hermes-cron`): `hermes_cron_jobs` in + `group_vars/mac/main.yml`, with their scripts from `files/hermes-scripts/` + copied to `~/.hermes/scripts/`. Missing jobs are created; existing ones are + left as they are. Today: `hermes-update-notice`, which messages you on + Telegram on Mondays only when a new stable Hermes release is out. Ansible logs in as `phil`. sudo needs phil's password, which is in the vault as `vault_cogitator02.become_password`; only tasks with `become: true` use it. diff --git a/roles/mac/files/hermes-scripts/hermes-update-notice.sh b/roles/mac/files/hermes-scripts/hermes-update-notice.sh new file mode 100644 index 0000000..1df490e --- /dev/null +++ b/roles/mac/files/hermes-scripts/hermes-update-notice.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Hermes cron job (no agent): stdout goes to Telegram, empty stdout sends +# nothing, a non-zero exit sends an error alert. Silent while Hermes is on +# the latest stable release. +out=$("$HOME/.local/bin/hermes" update --check 2>&1) || { + echo "Hermes update check failed:" + echo "$out" | tail -5 + exit 1 +} +grep -q "Up to date" <<<"$out" && exit 0 +echo "Hermes on cogitator-02 has an update:" +grep -v "^→ Update channel" <<<"$out" +echo +echo "Ask Claude to run it (backup, update, checks). Avoid /update in Telegram." diff --git a/roles/mac/tasks/hermes-cron.yml b/roles/mac/tasks/hermes-cron.yml new file mode 100644 index 0000000..05150a3 --- /dev/null +++ b/roles/mac/tasks/hermes-cron.yml @@ -0,0 +1,27 @@ +- name: Hermes cron scripts + ansible.builtin.copy: + src: "hermes-scripts/{{ item.script }}" + dest: "{{ ansible_user_dir }}/.hermes/scripts/" + mode: "0700" + loop: "{{ hermes_cron_jobs | selectattr('script', 'defined') }}" + loop_control: + label: "{{ item.script }}" + +- name: List Hermes cron jobs + ansible.builtin.command: + argv: ["{{ hermes_cli }}", cron, list, --all] + register: hermes_cron_list + changed_when: false + check_mode: false + +- name: Create missing Hermes cron jobs + ansible.builtin.command: + argv: >- + {{ [hermes_cli, 'cron', 'create', item.schedule, '--name', item.name, '--deliver', item.deliver] + + (['--script', item.script] if item.script is defined else []) + + (['--no-agent'] if item.no_agent | default(false) else []) + + ([item.prompt] if item.prompt is defined else []) }} + loop: "{{ hermes_cron_jobs }}" + loop_control: + label: "{{ item.name }}" + when: item.name not in hermes_cron_list.stdout diff --git a/roles/mac/tasks/main.yml b/roles/mac/tasks/main.yml index 903717f..cd31323 100644 --- a/roles/mac/tasks/main.yml +++ b/roles/mac/tasks/main.yml @@ -37,3 +37,7 @@ - name: Hermes settings ansible.builtin.import_tasks: hermes-settings.yml tags: hermes-settings + +- name: Hermes cron jobs + ansible.builtin.import_tasks: hermes-cron.yml + tags: hermes-cron