Mac: compare Hermes settings against config.yaml; restart with --yes

`hermes config get` fills in and masks ${VAR} references, so the Karakeep
MCP entry (env KARAKEEP_API_KEY: ${KARAKEEP_API_KEY}) never matched and
every deploy re-set it and restarted the gateway. It also prints defaults
for unset keys and exits 1 for keys without one. Compare against
~/.hermes/config.yaml itself instead.

`hermes gateway restart` without a terminal refuses while anything is
running unless given --yes (docs, reference/cli-commands); the failed
handler left the gateway restarting under launchd but the play failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-11-11 08:33:41 -07:00
1 parent cccdca1469
commit 310e5523f1
3 files changed
+33 -23

No files matched your search

+2 -2
View File
@@ -23,8 +23,8 @@ Manages cogitator-02, an Apple Silicon Mac on the tailnet (`mac.yml`,
override the hash). After setting up Serve, the play checks the dashboard 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. demands a login through it; if not, it turns Serve off and fails.
- **Hermes settings** (tag `hermes-settings`): the individual keys in - **Hermes settings** (tag `hermes-settings`): the individual keys in
`hermes_settings` (`group_vars/mac/main.yml`), checked with `hermes_settings` (`group_vars/mac/main.yml`), compared against
`hermes config get` and fixed with `hermes config set`; any change restarts the gateway (`hermes gateway restart`) `~/.hermes/config.yaml` and fixed with `hermes config set`; any change restarts the gateway (`hermes gateway restart`)
and the dashboard. and the dashboard.
Covers update backups, timezone, not borrowing Claude Code's login, sandbox Covers update backups, timezone, not borrowing Claude Code's login, sandbox
memory, disabled toolsets, skill-write approval, deny rules, streaming, memory, disabled toolsets, skill-write approval, deny rules, streaming,
+4 -2
View File
@@ -5,8 +5,10 @@
# Nothing to restart in a dry run (on the first deploy the plist isn't there). # Nothing to restart in a dry run (on the first deploy the plist isn't there).
when: not ansible_check_mode when: not ansible_check_mode
# Lets running turns finish first (unlike launchctl kickstart -k). # Lets running turns finish first (unlike launchctl kickstart -k). Without a
# terminal it refuses while turns, cron jobs or subagents are running unless
# given --yes; the gateway then exits 75 and launchd starts a new one.
- name: Restart Hermes gateway - name: Restart Hermes gateway
ansible.builtin.command: ansible.builtin.command:
argv: ["{{ hermes_cli }}", gateway, restart] argv: ["{{ hermes_cli }}", gateway, restart, --yes]
when: not ansible_check_mode when: not ansible_check_mode
+27 -19
View File
@@ -11,30 +11,38 @@
diff: false diff: false
notify: [Restart Hermes gateway, Restart Hermes dashboard] notify: [Restart Hermes gateway, Restart Hermes dashboard]
# `hermes config get` prints the value as YAML, so it's compared # Compared against ~/.hermes/config.yaml itself: `hermes config get` prints
# structurally; `hermes config set` takes JSON for lists and booleans. # defaults for unset keys, exits 1 for keys without a default, and fills in
# Settings are always set explicitly: for a key that isn't in config.yaml, # and masks ${VAR} references, so it can't tell what's actually set.
# `config get` (non-interactive) prints just the default when there is one, - name: Read Hermes's config.yaml
# so "unset" can't be detected. ansible.builtin.slurp:
- name: Read Hermes settings src: "{{ ansible_user_dir }}/.hermes/config.yaml"
ansible.builtin.command: register: hermes_config_file
argv: ["{{ hermes_cli }}", config, get, "{{ item.key }}"]
loop: "{{ hermes_settings | dict2items }}"
register: hermes_settings_current
changed_when: false
# Exit 1 = "Config key not set" (only for keys without a built-in default).
failed_when: hermes_settings_current.rc > 1
check_mode: false
- name: Note the current value of each setting
ansible.builtin.set_fact:
hermes_settings_current: >-
{%- set config = hermes_config_file.content | b64decode | from_yaml -%}
{%- set current = {} -%}
{%- for key in hermes_settings -%}
{%- set node = namespace(value=config) -%}
{%- for part in key.split('.') -%}
{%- set node.value = node.value[part] if (node.value is mapping and part in node.value) else none -%}
{%- endfor -%}
{%- set _ = current.update({key: node.value}) -%}
{%- endfor -%}
{{ current }}
# `hermes config set` takes JSON for lists, mappings and booleans.
- name: Set Hermes settings - name: Set Hermes settings
ansible.builtin.command: ansible.builtin.command:
argv: >- argv: >-
{{ [hermes_cli, 'config', 'set'] {{ [hermes_cli, 'config', 'set']
+ (['--force'] if item.item.key in hermes_settings_force | default([]) else []) + (['--force'] if item.key in hermes_settings_force | default([]) else [])
+ [item.item.key, item.item.value if item.item.value is string else item.item.value | to_json] }} + [item.key, item.value if item.value is string else item.value | to_json] }}
loop: "{{ hermes_settings_current.results }}" loop: "{{ hermes_settings | dict2items }}"
loop_control: loop_control:
label: "{{ item.item.key }} = {{ item.item.value | to_json }}" label: "{{ item.key }} = {{ item.value | to_json }}"
when: (none if item.rc == 1 else item.stdout | from_yaml) != item.item.value when: hermes_settings_current[item.key] != item.value
# The dashboard is a separate process with its own copy of the settings. # The dashboard is a separate process with its own copy of the settings.
notify: [Restart Hermes gateway, Restart Hermes dashboard] notify: [Restart Hermes gateway, Restart Hermes dashboard]