The dashboard used to be started by hand as `serve --host 0.0.0.0`, so it was reachable from the LAN and didn't survive a reboot or a Hermes update. Now, following Hermes's docs: - launchd agent local.hermes-dashboard runs `hermes dashboard` on 127.0.0.1:9119 (KeepAlive, --skip-build since `hermes update` builds it). - Tailscale Serve publishes it on https://cogitator-02.porgy-porgy.ts.net, tailnet only. No module exists for Serve; the task reads `serve status --json` and only sets it when it differs. - Login: scrypt password hash and a real signing secret from the vault (the old secret was the literal text "$(openssl rand -base64 32)"); the plaintext password line is removed from .env since it overrides the hash. - After Serve is set, the play checks /api/status demands the basic login; if not, it turns Serve off and fails. - Hermes's Python no longer needs a firewall exception, so that's gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
106 lines
4.1 KiB
YAML
106 lines
4.1 KiB
YAML
# Hermes never installs a service for its dashboard; this is the launchd
|
|
# version of the systemd unit in its docs (user-guide/features/web-dashboard).
|
|
# Login: username + scrypt password hash + a fixed signing secret, so sessions
|
|
# survive restarts. public_url makes it accept the Tailscale Serve origin.
|
|
- name: Dashboard login and public URL in Hermes's .env
|
|
ansible.builtin.lineinfile:
|
|
path: "{{ hermes_env }}"
|
|
regexp: "^{{ item.key }}="
|
|
# Single quotes: Hermes reads .env without interpolation, and the hash has $ in it.
|
|
line: "{{ item.key }}='{{ item.value }}'"
|
|
mode: "0600"
|
|
loop:
|
|
- { key: HERMES_DASHBOARD_BASIC_AUTH_USERNAME, value: "{{ hermes_dashboard_username }}" }
|
|
- { key: HERMES_DASHBOARD_BASIC_AUTH_PASSWORD_HASH, value: "{{ vault_cogitator02.dashboard_password_hash }}" }
|
|
- { key: HERMES_DASHBOARD_BASIC_AUTH_SECRET, value: "{{ vault_cogitator02.dashboard_secret }}" }
|
|
- { key: HERMES_DASHBOARD_PUBLIC_URL, value: "{{ hermes_dashboard_url }}" }
|
|
no_log: true
|
|
diff: false
|
|
notify: Restart Hermes dashboard
|
|
|
|
# A plaintext password overrides the hash, so it must not be there.
|
|
- name: No plaintext dashboard password in .env
|
|
ansible.builtin.lineinfile:
|
|
path: "{{ hermes_env }}"
|
|
regexp: "^HERMES_DASHBOARD_BASIC_AUTH_PASSWORD="
|
|
state: absent
|
|
no_log: true
|
|
diff: false
|
|
notify: Restart Hermes dashboard
|
|
|
|
- name: Dashboard launchd service
|
|
ansible.builtin.template:
|
|
src: hermes-dashboard.plist.j2
|
|
dest: "{{ ansible_user_dir }}/Library/LaunchAgents/{{ hermes_dashboard_label }}.plist"
|
|
mode: "0644"
|
|
register: dashboard_plist
|
|
notify: Restart Hermes dashboard
|
|
|
|
- name: Dashboard running
|
|
community.general.launchd:
|
|
name: "{{ hermes_dashboard_label }}"
|
|
state: started
|
|
# In a dry run of the first deploy the plist doesn't exist yet.
|
|
when: not (ansible_check_mode and dashboard_plist is changed)
|
|
|
|
# Restart now on changes, so the login check below tests the new settings.
|
|
- name: Apply dashboard changes
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
# Tailscale Serve: tailnet-only HTTPS on https://<this Mac>.ts.net, proxied to
|
|
# the loopback dashboard. No Ansible module manages it, so read the current
|
|
# config and set it only when it differs. --bg keeps it across reboots.
|
|
# TAILSCALE_BE_CLI makes the app binary act as the CLI without a terminal.
|
|
- name: Read Tailscale Serve config
|
|
ansible.builtin.command:
|
|
argv: ["{{ tailscale_cli }}", serve, status, --json]
|
|
environment:
|
|
TAILSCALE_BE_CLI: "1"
|
|
register: tailscale_serve
|
|
changed_when: false
|
|
check_mode: false
|
|
|
|
- name: Serve the dashboard on the tailnet over HTTPS
|
|
ansible.builtin.command:
|
|
argv: ["{{ tailscale_cli }}", serve, --bg, --https=443, "http://127.0.0.1:{{ hermes_dashboard_port }}"]
|
|
environment:
|
|
TAILSCALE_BE_CLI: "1"
|
|
when: >-
|
|
(tailscale_serve.stdout | from_json).get('Web', {}).get(ansible_host ~ ':443', {})
|
|
.get('Handlers', {}).get('/', {}).get('Proxy', '')
|
|
!= 'http://127.0.0.1:' ~ hermes_dashboard_port
|
|
|
|
# The dashboard must ask for a login through Serve. If it doesn't, take it
|
|
# off the tailnet and stop.
|
|
- name: Check the dashboard login is on
|
|
when: not ansible_check_mode
|
|
block:
|
|
- name: Wait for the dashboard to answer through Tailscale Serve
|
|
ansible.builtin.uri:
|
|
url: "{{ hermes_dashboard_url }}/api/status"
|
|
return_content: true
|
|
register: dashboard_status
|
|
until: dashboard_status.status == 200
|
|
retries: 12
|
|
delay: 5
|
|
|
|
- name: Dashboard requires the username/password login
|
|
ansible.builtin.assert:
|
|
that:
|
|
- dashboard_status.json.auth_required | bool
|
|
- "'basic' in dashboard_status.json.auth_providers"
|
|
quiet: true
|
|
rescue:
|
|
- name: Take the dashboard off the tailnet
|
|
ansible.builtin.command:
|
|
argv: ["{{ tailscale_cli }}", serve, --https=443, "off"]
|
|
environment:
|
|
TAILSCALE_BE_CLI: "1"
|
|
|
|
- name: Stop here
|
|
ansible.builtin.fail:
|
|
msg: >-
|
|
The dashboard didn't answer or doesn't require a login through
|
|
{{ hermes_dashboard_url }}, so Tailscale Serve was turned off.
|
|
Check ~/.hermes/logs/dashboard.error.log on the Mac.
|