- pmset: never sleep, no disk sleep, restart after a power cut, wake on network. The Mac had sleep 1 and only stayed up because BlueBubbles runs caffeinate. - Application firewall on, keeping signed software allowed automatically, stealth and block-all off. Hermes's ad hoc signed Python (dashboard on 9119) is allowed explicitly, since an unattended Mac blocks unsigned programs silently. - Local id_ed25519.pub in phil's authorized_keys (already there). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.2 KiB
YAML
55 lines
2.2 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
|
|
|
|
# Hermes's own Python (ad hoc signed) serves its web dashboard on port 9119.
|
|
# Its path has a version in it, so every Python Hermes has installed is allowed.
|
|
- name: Find Hermes's Python
|
|
ansible.builtin.find:
|
|
paths: "{{ ansible_user_dir }}/.hermes/tools"
|
|
patterns: '^python3\.\d+$'
|
|
use_regex: true
|
|
recurse: true
|
|
depth: 3
|
|
file_type: file
|
|
register: hermes_python
|
|
|
|
- name: Allow Hermes's Python
|
|
ansible.builtin.shell: >-
|
|
{{ socketfilterfw }} --add {{ item.path | quote }} &&
|
|
{{ socketfilterfw }} --unblockapp {{ item.path | quote }}
|
|
loop: "{{ hermes_python.files }}"
|
|
loop_control:
|
|
label: "{{ item.path }}"
|
|
when: firewall_current is not search((item.path | regex_escape) ~ '\s*\n\s*\(Allow incoming')
|
|
become: true
|
|
|
|
- name: Turn the firewall on
|
|
ansible.builtin.command: "{{ socketfilterfw }} --setglobalstate on"
|
|
when: "'Firewall is enabled' not in firewall_current"
|
|
become: true
|