From eff53f250319e4e31081e661e39fa1c0b77f9955 Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 11 Nov 2026 06:57:46 -0700 Subject: [PATCH] Mac: Hermes settings via hermes config, full pre-update backups Adds a small hermes_settings map that Ansible checks with `hermes config get` and fixes with `hermes config set`, leaving the rest of config.yaml to Hermes (its updates migrate that file). First setting: updates.pre_update_backup: full (was false), so every `hermes update` zips ~/.hermes first. Rollback isn't supported once a new version has written state.db, so the backup is the way back. Co-Authored-By: Claude Opus 5.5 --- group_vars/mac/main.yml | 5 +++++ roles/mac/README.md | 4 ++++ roles/mac/tasks/hermes-settings.yml | 15 +++++++++++++++ roles/mac/tasks/main.yml | 4 ++++ roles/mac/vars/main.yml | 1 + 5 files changed, 29 insertions(+) create mode 100644 roles/mac/tasks/hermes-settings.yml diff --git a/group_vars/mac/main.yml b/group_vars/mac/main.yml index ff0920d..3d8633e 100644 --- a/group_vars/mac/main.yml +++ b/group_vars/mac/main.yml @@ -24,3 +24,8 @@ mac_pmset: hermes_dashboard_port: 9119 hermes_dashboard_url: "https://{{ ansible_host }}" hermes_dashboard_username: admin + +# Individual Hermes settings, set with `hermes config set`. The rest of +# ~/.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 diff --git a/roles/mac/README.md b/roles/mac/README.md index c39cabe..cbe8697 100644 --- a/roles/mac/README.md +++ b/roles/mac/README.md @@ -22,6 +22,10 @@ Manages cogitator-02, an Apple Silicon Mac on the tailnet (`mac.yml`, `~/.hermes/.env` (a plaintext password line there is removed, since it would override the hash). After setting up Serve, the play checks the dashboard demands a login through it; if not, it turns Serve off and fails. +- **Hermes settings** (tag `hermes-settings`): the individual keys in + `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`. 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/tasks/hermes-settings.yml b/roles/mac/tasks/hermes-settings.yml new file mode 100644 index 0000000..367df8c --- /dev/null +++ b/roles/mac/tasks/hermes-settings.yml @@ -0,0 +1,15 @@ +- name: Read Hermes settings + ansible.builtin.command: + argv: ["{{ hermes_cli }}", config, get, "{{ item.key }}"] + loop: "{{ hermes_settings | dict2items }}" + register: hermes_settings_current + changed_when: false + check_mode: false + +- name: Set Hermes settings + ansible.builtin.command: + argv: ["{{ hermes_cli }}", config, set, "{{ item.item.key }}", "{{ item.item.value }}"] + loop: "{{ hermes_settings_current.results }}" + loop_control: + label: "{{ item.item.key }} = {{ item.item.value }}" + when: (item.stdout_lines | last | default('')) != (item.item.value | string) diff --git a/roles/mac/tasks/main.yml b/roles/mac/tasks/main.yml index 8018b5f..903717f 100644 --- a/roles/mac/tasks/main.yml +++ b/roles/mac/tasks/main.yml @@ -33,3 +33,7 @@ - name: Hermes dashboard ansible.builtin.import_tasks: hermes-dashboard.yml tags: hermes-dashboard + +- name: Hermes settings + ansible.builtin.import_tasks: hermes-settings.yml + tags: hermes-settings diff --git a/roles/mac/vars/main.yml b/roles/mac/vars/main.yml index ec5870d..b779b37 100644 --- a/roles/mac/vars/main.yml +++ b/roles/mac/vars/main.yml @@ -2,3 +2,4 @@ socketfilterfw: /usr/libexec/ApplicationFirewall/socketfilterfw hermes_env: "{{ ansible_user_dir }}/.hermes/.env" hermes_dashboard_label: local.hermes-dashboard tailscale_cli: /Applications/Tailscale.app/Contents/MacOS/Tailscale +hermes_cli: "{{ ansible_user_dir }}/.local/bin/hermes"