Fix launchctl idempotency in kiwix and borgmatic roles

Check if LaunchAgent is already loaded before attempting to load it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-01-14 14:14:52 -08:00
commit 2f28b151f5
2 changed files with 16 additions and 6 deletions

View file

@ -178,8 +178,13 @@
mode: '0644'
notify: restart kiwix-serve
- name: Ensure kiwix-serve is loaded
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.kiwix-serve.plist
register: launchctl_load
changed_when: launchctl_load.rc == 0
- name: Check if kiwix-serve LaunchAgent is loaded
ansible.builtin.command: launchctl list mcquack.eblume.kiwix-serve
register: launchctl_check
changed_when: false
failed_when: false
- name: Load kiwix-serve LaunchAgent if not loaded
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.kiwix-serve.plist
when: launchctl_check.rc != 0
failed_when: false