2016-05-22 04:43:14 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: install borg
|
|
|
|
pacman: name=borg state=present
|
|
|
|
|
2016-05-28 19:06:00 +02:00
|
|
|
- name: create borg user
|
2019-10-30 07:18:30 +01:00
|
|
|
user:
|
|
|
|
name: borg
|
|
|
|
home: "{{ backup_dir }}"
|
2016-05-28 19:06:00 +02:00
|
|
|
|
|
|
|
- name: create borg user home
|
2019-10-30 07:18:30 +01:00
|
|
|
file:
|
|
|
|
path: "{{ backup_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: borg
|
|
|
|
group: borg
|
|
|
|
mode: 0700
|
2016-05-28 19:06:00 +02:00
|
|
|
|
2016-05-22 04:43:14 +02:00
|
|
|
- name: create the root backup directory at {{ backup_dir }}
|
2019-10-30 07:18:30 +01:00
|
|
|
file:
|
|
|
|
path: "{{ backup_dir }}/{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: borg
|
|
|
|
group: borg
|
|
|
|
mode: 0700
|
2016-05-22 04:43:14 +02:00
|
|
|
with_items: "{{ backup_clients }}"
|
|
|
|
|
2020-03-08 17:25:03 +01:00
|
|
|
- name: fetch ssh keys from each borg client machine
|
2016-05-22 04:43:14 +02:00
|
|
|
command: cat /root/.ssh/id_rsa.pub
|
|
|
|
register: ssh_keys
|
2017-09-06 20:43:44 +02:00
|
|
|
delegate_to: "{{ item }}"
|
2016-05-22 04:43:14 +02:00
|
|
|
with_items: "{{ backup_clients }}"
|
2020-06-12 22:10:24 +02:00
|
|
|
changed_when: ssh_keys.stdout | length > 0
|
2016-05-22 04:43:14 +02:00
|
|
|
|
|
|
|
- name: allow certain clients to connect
|
|
|
|
authorized_key:
|
2019-10-30 07:18:30 +01:00
|
|
|
user: borg
|
|
|
|
key: "{{ item.stdout }}"
|
2021-02-14 14:05:32 +01:00
|
|
|
manage_dir: true
|
2019-10-30 07:18:30 +01:00
|
|
|
key_options: "command=\"/usr/bin/borg serve --restrict-to-path {{ backup_dir }}/{{ item['item'] }}\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc"
|
2016-05-22 04:43:14 +02:00
|
|
|
with_items: "{{ ssh_keys.results }}"
|