WIP: backups with borg and borgmatic #39

Manually merged
jeltz merged 45 commits from backups into master 2024-07-01 01:55:28 +02:00
Showing only changes of commit 021a5ef1e8 - Show all commits

View file

@ -44,12 +44,34 @@
- name: Create SSH key
openssh_keypair:
path: "/etc/borgbackup/id_remote"
type: rsa
type: ed25519
regenerate: full_idempotence
owner: root
group: root
mode: u=r,g=r,o=
register: ssh_key
- name: Gather server facts
delegate_to: "{{ borg_server_host }}"
setup:
gather_subset:
- all
register: server_facts
- name: debug
debug:
var: "server_facts['ansible_facts'].ansible_ssh_host_key_ecdsa_public_keytype"
- name: Add server key to known hosts
known_hosts:
hash_host: true
host: "{{ borg_server_host }}"
key: "{{ borg_server_host }} {{ server_facts['ansible_facts']['ansible_ssh_host_key_' + item + '_public_keytype'] }} {{ server_facts['ansible_facts']['ansible_ssh_host_key_' + item + '_public'] }}"
loop:
- ecdsa
- ed25519
- rsa
- name: Add public key to remote
delegate_to: "{{ borg_server_host }}"
become: true
@ -65,12 +87,12 @@
no-user-rc,
no-X11-forwarding
vars:
borg_host_dir: "{{ borg_server_base_dir }}/{{ ansible_fqdn }}"
borg_host_dir: "/borg/{{ ansible_fqdn }}"
- name: Add borgmatic configuration file
become: true
template:
src: borgmatic.conf.j2
src: config.yaml.j2
dest: /etc/borgmatic/config.yaml
owner: root
group: root