mirror of
https://github.com/nikdoof/ansible-borgmatic.git
synced 2025-12-11 09:52:18 +00:00
Support Debian
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
---
|
||||
borgmatic_ssh_keys: []
|
||||
|
||||
borgmatic_config:
|
||||
# Where to look for files to backup, and where to store those backups.
|
||||
# See https://borgbackup.readthedocs.io/en/stable/quickstart.html and
|
||||
|
||||
@@ -3,7 +3,7 @@ allow_duplicates: false
|
||||
|
||||
galaxy_info:
|
||||
role_name: borgmatic
|
||||
author: Andrew Williams
|
||||
author: nikdoof
|
||||
description: Installs and configures a Borgmatic
|
||||
license: MIT
|
||||
|
||||
@@ -13,3 +13,6 @@ galaxy_info:
|
||||
- name: EL
|
||||
versions:
|
||||
- 8
|
||||
- name: Debian
|
||||
versions:
|
||||
- bookworm
|
||||
|
||||
@@ -6,13 +6,15 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
|
||||
- name: Write borgmatic config
|
||||
copy:
|
||||
dest: /etc/borgmatic/config.yaml
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
content: "{{ borgmatic_config | to_nice_yaml( width=50, explicit_start=True, explicit_end=True) }}"
|
||||
content: "{{ borgmatic_config | to_nice_yaml(width=50, explicit_start=True, explicit_end=True) }}"
|
||||
|
||||
- name: Create /root/.borgmatic folder
|
||||
ansible.builtin.file:
|
||||
path: /root/.borgmatic
|
||||
@@ -20,6 +22,7 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
|
||||
- name: "Copy SSH key {{ item }} to borgmatic config folder"
|
||||
ansible.builtin.copy:
|
||||
src: "ssh_keys/{{ item }}"
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
---
|
||||
- name: Get borg target host SSH host key
|
||||
ansible.builtin.command: "ssh-keyscan -H {{ item.split('@')[1].split(':')[0] }}"
|
||||
loop: "{{ borgmatic_config['location']['repositories'] }}"
|
||||
when:
|
||||
- "'location' in borgmatic_config"
|
||||
- "'repositories' in borgmatic_config['location']"
|
||||
register: _borgmatic_ssh_host_keys
|
||||
|
||||
- name: Add SSH key to known hosts
|
||||
ansible.builtin.known_hosts:
|
||||
path: /etc/ssh/ssh_known_hosts
|
||||
name: "{{ item.item.split('@')[1].split(':')[0] }}"
|
||||
key: "{{ item.stdout }}"
|
||||
loop: "{{ _borgmatic_ssh_host_keys.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item }}"
|
||||
|
||||
- name: Initialize borg check_repositories
|
||||
ansible.builtin.command: "/usr/local/bin/borgmatic init --encryption repokey" # noqa 301
|
||||
no_log: true
|
||||
async: 300
|
||||
poll: 0
|
||||
ansible.builtin.shell: "borgmatic init --encryption repokey"
|
||||
environment:
|
||||
PATH: "{{ ansible_env.PATH}}:/usr/local/bin"
|
||||
|
||||
- name: Enable borgmatic.timer
|
||||
ansible.builtin.systemd:
|
||||
name: borgmatic.timer
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
---
|
||||
- name: Install BorgBackup
|
||||
ansible.builtin.package:
|
||||
name: "{{ packages }}"
|
||||
state: installed
|
||||
vars:
|
||||
packages:
|
||||
- borgbackup
|
||||
- name: Install Borgmatic
|
||||
name: borgbackup
|
||||
state: present
|
||||
|
||||
- name: Install Borgmatic (Pip)
|
||||
ansible.builtin.pip:
|
||||
name: "{{ packages }}"
|
||||
vars:
|
||||
packages:
|
||||
- borgmatic
|
||||
name: borgmatic
|
||||
when:
|
||||
- borgmatic_install_from_pip | default(false)
|
||||
|
||||
- name: Install Borgmatic (Package)
|
||||
ansible.builtin.package:
|
||||
name: borgmatic
|
||||
when:
|
||||
- borgmatic_install_from_package | default(false)
|
||||
|
||||
- name: Add borgmatic systemd units
|
||||
ansible.builtin.copy:
|
||||
src: "systemd/{{ item }}"
|
||||
@@ -23,3 +27,5 @@
|
||||
loop:
|
||||
- borgmatic.service
|
||||
- borgmatic.timer
|
||||
when:
|
||||
- borgmatic_install_from_pip | default(false)
|
||||
@@ -1,4 +1,9 @@
|
||||
---
|
||||
- include: install.yaml
|
||||
- include: config.yaml
|
||||
- include: init.yaml
|
||||
- name: Borgmatic - Get OS specific vars
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "os/{{ ansible_os_family }}/{{ ansible_distribution_major_version }}.yaml"
|
||||
- "os/{{ ansible_os_family }}.yaml"
|
||||
- include_tasks: install.yaml
|
||||
- include_tasks: config.yaml
|
||||
- include_tasks: init.yaml
|
||||
|
||||
2
vars/os/Debian.yaml
Normal file
2
vars/os/Debian.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
borgmatic_install_from_package: true
|
||||
2
vars/os/RedHat.yaml
Normal file
2
vars/os/RedHat.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
borgmatic_install_from_pip: true
|
||||
Reference in New Issue
Block a user