Feat(Songe): Start songe borgbackup server

This commit is contained in:
2018-11-11 09:01:21 +01:00
parent ada234ed9e
commit 24d07cd8d1
3 changed files with 81 additions and 0 deletions

View File

@@ -3,3 +3,65 @@
apt:
name: borgbackup
state: present
- name: Add borgbackup group
group:
name: "{{ borg_group }}"
state: present
- name: Add borgbackup user
user:
name: "{{ borg_user }}"
shell: /bin/bash
home: "{{ borg_home }}"
createhome: yes
group: "{{ borg_group }}"
state: present
- name: Fix permission on borgbackup home
file:
path: "{{ borg_home }}"
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
mode: 0700
state: directory
- name: Fix .ssh permision
file:
path: "{{ borg_home }}/.ssh"
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
mode: 0700
state: directory
- name: Fix pool permission
file:
path: "{{ borg_pool }}"
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
mode: 0700
state: directory
- name: Add autorized backup user through $HOME/.ssh/authorized_keys
authorized_key:
user: "{{ borg_user }}"
key: "{{ item.key }}"
key_options: 'command="cd {{ borg_pool }}/{{ item.host }};borg serve --restrict-to-path {{ borg_pool }}/{{ item.host }}",restrict'
with_items: "{{ borg_auth_users }}"
- name: Fix permission on authorized_keys
file:
path: "{{ borg_home }}/.ssh/authorized_keys"
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
mode: 0600
state: file
- name: Fix permission on each repo
file:
path: "{{ borg_pool }}/{{ item.host }}"
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
mode: 0700
state: directory
with_items: "{{ borg_auth_users }}"