2026-01-13 22:50:28 -08:00
|
|
|
---
|
2026-04-15 07:23:46 -07:00
|
|
|
# Borgmatic is installed via mise (pipx) and called directly by LaunchAgents.
|
|
|
|
|
# This role manages installation, config, and the scheduled LaunchAgents.
|
|
|
|
|
|
|
|
|
|
- name: Install borgmatic via mise
|
|
|
|
|
ansible.builtin.command: mise install pipx:borgmatic@{{ borgmatic_version }}
|
|
|
|
|
register: borgmatic_install
|
|
|
|
|
changed_when: "'installed' in borgmatic_install.stderr"
|
2026-01-16 12:30:20 -08:00
|
|
|
|
|
|
|
|
- name: Ensure borgmatic config directory exists
|
|
|
|
|
ansible.builtin.file:
|
|
|
|
|
path: "{{ borgmatic_config_dir }}"
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0700'
|
|
|
|
|
|
2026-01-20 09:04:47 -08:00
|
|
|
# .pgpass is used by pg_dump for database backups
|
|
|
|
|
# Password is fetched in playbook pre_tasks as borgmatic_db_password
|
|
|
|
|
- name: Write .pgpass file for borgmatic PostgreSQL backups
|
|
|
|
|
ansible.builtin.copy:
|
|
|
|
|
content: |
|
|
|
|
|
# Managed by ansible (borgmatic role) - k8s PostgreSQL backup credentials
|
2026-01-25 12:56:31 -08:00
|
|
|
pg.ops.eblu.me:5432:*:borgmatic:{{ borgmatic_db_password }}
|
2026-03-27 16:59:58 -07:00
|
|
|
pg.ops.eblu.me:5433:*:borgmatic:{{ borgmatic_db_password }}
|
2026-01-20 09:04:47 -08:00
|
|
|
dest: ~/.pgpass
|
|
|
|
|
mode: '0600'
|
|
|
|
|
no_log: true
|
|
|
|
|
|
2026-02-10 12:47:02 -08:00
|
|
|
# BorgBase offsite backup - SSH key and host verification
|
|
|
|
|
- name: Deploy BorgBase SSH private key
|
|
|
|
|
ansible.builtin.copy:
|
|
|
|
|
content: "{{ borgbase_ssh_private_key }}\n"
|
|
|
|
|
dest: "{{ borgmatic_borgbase_ssh_key_path }}"
|
|
|
|
|
mode: '0600'
|
|
|
|
|
no_log: true
|
|
|
|
|
|
2026-03-27 19:43:05 -07:00
|
|
|
- name: Add BorgBase host keys to known_hosts
|
2026-02-10 12:47:02 -08:00
|
|
|
ansible.builtin.known_hosts:
|
2026-03-27 19:43:05 -07:00
|
|
|
name: "{{ item }}"
|
|
|
|
|
key: "{{ item }} ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGU0mISTyHBw9tBs6SuhSq8tvNM8m9eifQxM+88TowPO"
|
2026-02-10 12:47:02 -08:00
|
|
|
state: present
|
2026-03-27 19:43:05 -07:00
|
|
|
loop:
|
|
|
|
|
- u3ugi1x1.repo.borgbase.com
|
|
|
|
|
- xcrtl5tg.repo.borgbase.com
|
2026-02-10 12:47:02 -08:00
|
|
|
|
2026-03-16 21:59:10 -07:00
|
|
|
- name: Ensure k8s dump directory exists
|
|
|
|
|
ansible.builtin.file:
|
|
|
|
|
path: "{{ borgmatic_k8s_dump_dir }}"
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0700'
|
|
|
|
|
when: borgmatic_k8s_sqlite_dumps | length > 0
|
|
|
|
|
|
2026-05-13 18:55:50 -07:00
|
|
|
- name: Ensure ~/bin exists
|
|
|
|
|
ansible.builtin.file:
|
|
|
|
|
path: "{{ ansible_env.HOME }}/bin"
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0755'
|
|
|
|
|
when: borgmatic_k8s_sqlite_dumps | length > 0
|
|
|
|
|
|
|
|
|
|
- name: Deploy k8s SQLite dump helper script
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: k8s-sqlite-dump.sh.j2
|
|
|
|
|
dest: "{{ ansible_env.HOME }}/bin/borgmatic-k8s-sqlite-dump"
|
|
|
|
|
mode: '0755'
|
|
|
|
|
when: borgmatic_k8s_sqlite_dumps | length > 0
|
|
|
|
|
|
2026-01-16 12:30:20 -08:00
|
|
|
- name: Deploy borgmatic configuration
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: config.yaml.j2
|
|
|
|
|
dest: "{{ borgmatic_config }}"
|
|
|
|
|
mode: '0600'
|
2026-01-13 22:50:28 -08:00
|
|
|
|
|
|
|
|
- name: Deploy borgmatic LaunchAgent plist
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: borgmatic.plist.j2
|
|
|
|
|
dest: ~/Library/LaunchAgents/mcquack.eblume.borgmatic.plist
|
|
|
|
|
mode: '0644'
|
2026-01-16 19:33:02 -08:00
|
|
|
notify: Reload borgmatic
|
2026-01-13 22:50:28 -08:00
|
|
|
|
2026-01-14 14:14:52 -08:00
|
|
|
- name: Check if borgmatic LaunchAgent is loaded
|
|
|
|
|
ansible.builtin.command: launchctl list mcquack.eblume.borgmatic
|
2026-01-16 19:33:02 -08:00
|
|
|
register: borgmatic_launchctl_check
|
2026-01-14 14:14:52 -08:00
|
|
|
changed_when: false
|
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
|
|
- name: Load borgmatic LaunchAgent if not loaded
|
2026-01-13 22:50:28 -08:00
|
|
|
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.borgmatic.plist
|
2026-01-16 19:33:02 -08:00
|
|
|
when: borgmatic_launchctl_check.rc != 0
|
|
|
|
|
changed_when: true
|
2026-01-13 22:50:28 -08:00
|
|
|
failed_when: false
|
2026-03-27 19:43:05 -07:00
|
|
|
|
|
|
|
|
# --- Immich photo library backup (BorgBase offsite only) ---
|
|
|
|
|
|
|
|
|
|
- name: Deploy borgmatic photos configuration
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: photos.yaml.j2
|
|
|
|
|
dest: "{{ borgmatic_photos_config }}"
|
|
|
|
|
mode: '0600'
|
|
|
|
|
|
|
|
|
|
- name: Deploy borgmatic-photos LaunchAgent plist
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: borgmatic-photos.plist.j2
|
|
|
|
|
dest: ~/Library/LaunchAgents/mcquack.eblume.borgmatic-photos.plist
|
|
|
|
|
mode: '0644'
|
|
|
|
|
notify: Reload borgmatic-photos
|
|
|
|
|
|
|
|
|
|
- name: Check if borgmatic-photos LaunchAgent is loaded
|
|
|
|
|
ansible.builtin.command: launchctl list mcquack.eblume.borgmatic-photos
|
|
|
|
|
register: borgmatic_photos_launchctl_check
|
|
|
|
|
changed_when: false
|
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
|
|
- name: Load borgmatic-photos LaunchAgent if not loaded
|
|
|
|
|
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.borgmatic-photos.plist
|
|
|
|
|
when: borgmatic_photos_launchctl_check.rc != 0
|
|
|
|
|
changed_when: true
|
|
|
|
|
failed_when: false
|