Add borg backup role

This commit is contained in:
Daniel A. Maierhofer
2018-07-28 19:05:46 +02:00
parent ba40616ab2
commit 99ee7f23aa
33 changed files with 1042 additions and 137 deletions

View File

@@ -0,0 +1,21 @@
---
- name: borgbackup - download borg binary
get_url:
url: "{{ borgbackup_binary_uri }}"
dest: "{{ borgbackup_binary }}-{{ borgbackup_binary_version }}"
mode: "755"
when: not borgbackup_install_from_repo
- name: borgbackup - link install
file:
src: "{{ borgbackup_binary }}-{{ borgbackup_binary_version }}"
dest: "{{ borgbackup_binary }}"
state: link
force: yes
when: not borgbackup_install_from_repo
- name: borgbackup - install borgbackup
package:
name: borg
state: latest
when: borgbackup_install_from_repo

View File

@@ -0,0 +1,40 @@
---
- name: borg_server - create group
group:
name: "{{ borgbackup_server_group }}"
state: present
- name: borg_server - create user
user:
name: "{{ borgbackup_server_user }}"
group: "{{ borgbackup_server_group }}"
groups:
home: "{{ borgbackup_server_home }}"
createhome: yes
shell: /bin/bash
state: present
- name: borg_server - manage permissions
file:
path: "{{ item }}"
owner: "{{ borgbackup_server_user }}"
group: "{{ borgbackup_server_group }}"
mode: 0700
state: directory
with_items:
- "{{ borgbackup_server_home }}"
- "{{ borgbackup_server_home }}/.ssh"
- "{{ borgbackup_server_pool }}"
- name : borg_server - create authorized_keys
stat:
path: "{{ borgbackup_server_home }}/.ssh/authorized_keys"
register: authorized_keys
- name: borg_server - manage permissions for authorized_keys
file:
path: "{{ borgbackup_server_home }}/.ssh/authorized_keys"
owner: "{{ borgbackup_server_user }}"
group: "{{ borgbackup_server_group }}"
mode: 0600
state: '{{ "file" if authorized_keys.stat.exists else "touch" }}'

View File

@@ -0,0 +1,6 @@
---
- import_tasks: borgbackup_install.yml
tags: [ borg ]
- import_tasks: borgbackup_server.yml
tags: [ borg ]