Add borgmatic role to ansible playbook
Manages scheduled LaunchAgent for daily backups at 2:00 AM. Borgmatic itself is installed via mise (pipx), not managed by ansible. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
6977197c98
commit
d761e61809
5 changed files with 60 additions and 0 deletions
|
|
@ -5,3 +5,4 @@
|
|||
- prometheus
|
||||
- grafana
|
||||
- kiwix
|
||||
- borgmatic
|
||||
|
|
|
|||
7
ansible/roles/borgmatic/defaults/main.yml
Normal file
7
ansible/roles/borgmatic/defaults/main.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
borgmatic_config: /Users/erichblume/.config/borgmatic/config.yaml
|
||||
borgmatic_log_dir: /Users/erichblume/Library/Logs
|
||||
|
||||
# Schedule: runs daily at 2:00 AM
|
||||
borgmatic_schedule_hour: 2
|
||||
borgmatic_schedule_minute: 0
|
||||
5
ansible/roles/borgmatic/handlers/main.yml
Normal file
5
ansible/roles/borgmatic/handlers/main.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: reload borgmatic
|
||||
ansible.builtin.shell: |
|
||||
launchctl unload ~/Library/LaunchAgents/mcquack.eblume.borgmatic.plist 2>/dev/null || true
|
||||
launchctl load ~/Library/LaunchAgents/mcquack.eblume.borgmatic.plist
|
||||
16
ansible/roles/borgmatic/tasks/main.yml
Normal file
16
ansible/roles/borgmatic/tasks/main.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
# Note: borgmatic is installed via mise (pipx), not managed here.
|
||||
# This role manages only the scheduled LaunchAgent.
|
||||
|
||||
- name: Deploy borgmatic LaunchAgent plist
|
||||
ansible.builtin.template:
|
||||
src: borgmatic.plist.j2
|
||||
dest: ~/Library/LaunchAgents/mcquack.eblume.borgmatic.plist
|
||||
mode: '0644'
|
||||
notify: reload borgmatic
|
||||
|
||||
- name: Ensure borgmatic LaunchAgent is loaded
|
||||
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.borgmatic.plist
|
||||
register: launchctl_load
|
||||
changed_when: launchctl_load.rc == 0
|
||||
failed_when: false
|
||||
31
ansible/roles/borgmatic/templates/borgmatic.plist.j2
Normal file
31
ansible/roles/borgmatic/templates/borgmatic.plist.j2
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- {{ ansible_managed }} -->
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>KeepAlive</key>
|
||||
<false/>
|
||||
<key>Label</key>
|
||||
<string>mcquack.eblume.borgmatic</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>borgmatic</string>
|
||||
<string>--config</string>
|
||||
<string>{{ borgmatic_config }}</string>
|
||||
<string>create</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>{{ borgmatic_log_dir }}/mcquack.borgmatic.err.log</string>
|
||||
<key>StandardOutPath</key>
|
||||
<string>{{ borgmatic_log_dir }}/mcquack.borgmatic.out.log</string>
|
||||
<key>StartCalendarInterval</key>
|
||||
<dict>
|
||||
<key>Hour</key>
|
||||
<integer>{{ borgmatic_schedule_hour }}</integer>
|
||||
<key>Minute</key>
|
||||
<integer>{{ borgmatic_schedule_minute }}</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
Loading…
Add table
Add a link
Reference in a new issue