From db8dbb6c7ac546677f4ddb0946f2d518b12812ec Mon Sep 17 00:00:00 2001 From: Jeltz Date: Thu, 11 Mar 2021 20:08:41 +0100 Subject: [PATCH] Add borgbackup_server role --- roles/borgbackup_server/defaults/main.yml | 5 +++ roles/borgbackup_server/tasks/main.yml | 47 +++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 roles/borgbackup_server/defaults/main.yml create mode 100644 roles/borgbackup_server/tasks/main.yml diff --git a/roles/borgbackup_server/defaults/main.yml b/roles/borgbackup_server/defaults/main.yml new file mode 100644 index 0000000..bedb950 --- /dev/null +++ b/roles/borgbackup_server/defaults/main.yml @@ -0,0 +1,5 @@ +--- +borg_server_user: borgbackup +borg_server_group: borgbackup +borg_home_dir: /var/lib/borgbackup +... diff --git a/roles/borgbackup_server/tasks/main.yml b/roles/borgbackup_server/tasks/main.yml new file mode 100644 index 0000000..eb92431 --- /dev/null +++ b/roles/borgbackup_server/tasks/main.yml @@ -0,0 +1,47 @@ +--- +- name: Install borg + apt: + name: borgbackup + state: latest + update_cache: true + register: apt_result + retries: 3 + until: apt_result is succeeded + +- name: Create a local group for borg + become: true + group: + name: "{{ borg_server_group }}" + system: true + +- name: Create a local user for borg + become: true + user: + home: "{{ borg_home_dir }}" + create_home: true + comment: Local user for borgbackup server + name: "{{ borg_server_user }}" + group: "{{ borg_server_group }}" + system: true + # Does not constitute a valid hash, preventing from login via password + password: "*" + update_password: always + +- name: Create backup directory + become: true + file: + path: "{{ borg_server_backups_dir }}" + state: directory + owner: "{{ borg_server_user }}" + group: "{{ borg_server_group }}" + mode: u=rw + +- include_role: + name: update_motd + vars: + motd_messages: + - key: 10-borg-server + message: >- + Les sauvegardes (borg) sont stockées dans + {{ borg_server_backups_dir }}. +...