Files
ansible/roles/mac/tasks/firewall.yml
T
PhilandClaude Opus 5.5 d617a2aa64 Mac: Hermes dashboard as a launchd service behind Tailscale Serve
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>
2026-11-11 06:46:47 -07:00

33 lines
1.4 KiB
YAML

# macOS's application firewall. It filters incoming connections per program:
# Apple's and other properly signed apps are allowed automatically (SSH,
# BlueBubbles, AirPlay, Tailscale), unsigned ones are blocked. Nothing is
# asked on screen because nobody sits at this Mac, so an unsigned program
# that listens has to be allowed here.
- name: Read firewall settings
ansible.builtin.command: "{{ socketfilterfw }} --{{ item }}"
loop: [getglobalstate, getallowsigned, getstealthmode, getblockall, listapps]
register: firewall_read
changed_when: false
check_mode: false
- name: Note the current firewall settings
ansible.builtin.set_fact:
firewall_current: "{{ firewall_read.results | map(attribute='stdout') | join('\n') }}"
- name: Allow signed software, no stealth mode, don't block everything
ansible.builtin.command: "{{ socketfilterfw }} {{ item.set }}"
loop:
- { set: --setallowsigned on, current: built-in signed software ENABLED }
- { set: --setallowsignedapp on, current: downloaded signed software ENABLED }
- { set: --setstealthmode off, current: stealth mode is off }
- { set: --setblockall off, current: block all state set to disabled }
loop_control:
label: "{{ item.set }}"
when: item.current not in firewall_current
become: true
- name: Turn the firewall on
ansible.builtin.command: "{{ socketfilterfw }} --setglobalstate on"
when: "'Firewall is enabled' not in firewall_current"
become: true