Mac: start the Podman VM from launchd; settings restart the dashboard too
The VM resize in a92d4c1 worked but left the VM stopped: a VM started from
an Ansible task is stopped when the task ends. Nothing started the VM at
login either, so after a reboot Hermes's sandbox stayed down.
- launchd job local.podman-machine runs `podman machine start` at login;
the resize now starts the VM through it and waits until it's running.
- Hermes setting changes also restart the dashboard, which keeps its own
copy of the settings (it kept logging the old /workspace cwd).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a92d4c199c
commit
4592ee2132
5 files changed
+73
-7
No files matched your search
@@ -21,4 +21,5 @@
|
||||
when: >-
|
||||
(none if item.stdout is search('^Config key not set') else item.stdout | from_yaml)
|
||||
!= item.item.value
|
||||
notify: Restart Hermes gateway
|
||||
# The dashboard is a separate process with its own copy of the settings.
|
||||
notify: [Restart Hermes gateway, Restart Hermes dashboard]
|
||||
@@ -1,5 +1,26 @@
|
||||
# Memory for the Podman VM that runs Hermes's sandbox. Changing it means a
|
||||
# stop/start, which ends any sandbox containers that are running.
|
||||
# The Podman VM runs Hermes's sandbox containers. A launchd job starts it at
|
||||
# login, and starts it again after a resize: a VM started from an Ansible task
|
||||
# gets stopped when the task ends.
|
||||
- name: Podman VM launchd job
|
||||
ansible.builtin.template:
|
||||
src: podman-machine.plist.j2
|
||||
dest: "{{ ansible_user_dir }}/Library/LaunchAgents/{{ podman_machine_label }}.plist"
|
||||
mode: "0644"
|
||||
|
||||
- name: Check the Podman VM job is loaded
|
||||
ansible.builtin.command:
|
||||
argv: [launchctl, print, "gui/{{ ansible_user_uid }}/{{ podman_machine_label }}"]
|
||||
register: podman_job
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Load the Podman VM job
|
||||
ansible.builtin.command:
|
||||
argv: [launchctl, bootstrap, "gui/{{ ansible_user_uid }}",
|
||||
"{{ ansible_user_dir }}/Library/LaunchAgents/{{ podman_machine_label }}.plist"]
|
||||
when: podman_job.rc != 0
|
||||
|
||||
- name: Read Podman VM memory
|
||||
ansible.builtin.command:
|
||||
argv: [/opt/podman/bin/podman, machine, inspect, --format, !unsafe "{{.Resources.Memory}}"]
|
||||
@@ -7,10 +28,21 @@
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
# Stopping ends any sandbox containers that are running.
|
||||
- name: Resize the Podman VM
|
||||
ansible.builtin.shell: |
|
||||
set -e
|
||||
/opt/podman/bin/podman machine stop
|
||||
/opt/podman/bin/podman machine set --memory {{ podman_machine_memory }}
|
||||
/opt/podman/bin/podman machine start
|
||||
launchctl kickstart gui/{{ ansible_user_uid }}/{{ podman_machine_label }}
|
||||
when: podman_memory.stdout | int != podman_machine_memory
|
||||
|
||||
- name: Podman VM is running
|
||||
ansible.builtin.command:
|
||||
argv: [/opt/podman/bin/podman, machine, inspect, --format, !unsafe "{{.State}}"]
|
||||
register: podman_state
|
||||
until: podman_state.stdout == "running"
|
||||
retries: 12
|
||||
delay: 5
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
Reference in new issue
Block a user