WIP: backups with borg and borgmatic #39
1 changed files with 25 additions and 3 deletions
|
@ -44,11 +44,33 @@
|
||||||
- name: Create SSH key
|
- name: Create SSH key
|
||||||
openssh_keypair:
|
openssh_keypair:
|
||||||
path: "/etc/borgbackup/id_remote"
|
path: "/etc/borgbackup/id_remote"
|
||||||
type: rsa
|
type: ed25519
|
||||||
|
regenerate: full_idempotence
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: u=r,g=r,o=
|
mode: u=r,g=r,o=
|
||||||
register: ssh_key
|
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
|
- name: Add public key to remote
|
||||||
delegate_to: "{{ borg_server_host }}"
|
delegate_to: "{{ borg_server_host }}"
|
||||||
|
@ -65,12 +87,12 @@
|
||||||
no-user-rc,
|
no-user-rc,
|
||||||
no-X11-forwarding
|
no-X11-forwarding
|
||||||
vars:
|
vars:
|
||||||
borg_host_dir: "{{ borg_server_base_dir }}/{{ ansible_fqdn }}"
|
borg_host_dir: "/borg/{{ ansible_fqdn }}"
|
||||||
|
|
||||||
- name: Add borgmatic configuration file
|
- name: Add borgmatic configuration file
|
||||||
become: true
|
become: true
|
||||||
template:
|
template:
|
||||||
src: borgmatic.conf.j2
|
src: config.yaml.j2
|
||||||
dest: /etc/borgmatic/config.yaml
|
dest: /etc/borgmatic/config.yaml
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
|
|
Loading…
Reference in a new issue