From c99b611b8f32a8f177b35848234aef650269d387 Mon Sep 17 00:00:00 2001 From: Jeltz Date: Sun, 14 Mar 2021 14:17:36 +0100 Subject: [PATCH] Various fixes --- backups.yml | 2 +- group_vars/all/vars.yml | 2 ++ roles/borgbackup_client/tasks/main.yml | 28 ++++++++++++------- roles/borgbackup_client/templates/apt/list.j2 | 3 ++ .../templates/apt/preferences.j2 | 9 ++++++ 5 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 roles/borgbackup_client/templates/apt/list.j2 create mode 100644 roles/borgbackup_client/templates/apt/preferences.j2 diff --git a/backups.yml b/backups.yml index b87c1f9..b2820fa 100644 --- a/backups.yml +++ b/backups.yml @@ -3,7 +3,7 @@ roles: - borgbackup_server -- host: all, !unifi +- hosts: all,!unifi roles: - borgbackup_client ... diff --git a/group_vars/all/vars.yml b/group_vars/all/vars.yml index a351878..885dc41 100644 --- a/group_vars/all/vars.yml +++ b/group_vars/all/vars.yml @@ -103,3 +103,5 @@ borg_backup_directories: - "/etc/" - "/var/" borg_encryption_passphrase: "{{ vault_borg_encryption_passphrase }}" + +borg_server_host: 10.128.0.4 diff --git a/roles/borgbackup_client/tasks/main.yml b/roles/borgbackup_client/tasks/main.yml index 2038a2e..871234f 100644 --- a/roles/borgbackup_client/tasks/main.yml +++ b/roles/borgbackup_client/tasks/main.yml @@ -1,18 +1,19 @@ --- - name: Pin borgmatic template: - src: "apt/{{ item }}.j2" - dest: "/etc/apt/{{ item }}" + src: "{{ item.src }}" + dest: "{{ item.dest }}" owner: root group: root mode: u=rw,g=r,o= loop: - - sources.list.d/bullseye.list - - preferences.d/borgmatic-bullseye + - src: apt/list.j2 + dest: /etc/apt/sources.list.d/bullseye.list + - src: apt/preferences.j2 + dest: /etc/apt/preferences.d/borgmatic-bullseye when: - ansible_distribution == "Debian" - ansible_distribution_major_version | int <= 10 - - ansible_distribution_release != "bullseye" - name: Don't pin borgmatic if we are on bullseye file: @@ -32,10 +33,18 @@ retries: 3 until: apt_result is succeeded +- name: Create /etc/borgbackup + file: + path: /etc/borgbackup + state: directory + owner: root + group: root + mode: u=rwx,g=rx,o= + - name: Create SSH key openssh_keypair: - path: /etc/borgbackup/id_remote - type: ed25519 + path: "/etc/borgbackup/id_remote" + type: rsa owner: root group: root mode: u=r,g=r,o= @@ -79,8 +88,6 @@ - borgmatic.service notify: - Run systemd daemon-reload - - Start and enable borgmatic timer - - Start and enable borgmatic service - name: Start and enable borgmatic timer systemd: @@ -94,7 +101,8 @@ state: started enabled: true -- include_role: update_motd +- include_role: + name: update_motd vars: key: 10-borgmatic message: Borgmatic (client) est installé dans /etc/borgmatic/config.yaml. diff --git a/roles/borgbackup_client/templates/apt/list.j2 b/roles/borgbackup_client/templates/apt/list.j2 new file mode 100644 index 0000000..ac5140d --- /dev/null +++ b/roles/borgbackup_client/templates/apt/list.j2 @@ -0,0 +1,3 @@ +{{ ansible_managed | comment }} + +deb https://deb.debian.org/debian/ bullseye main diff --git a/roles/borgbackup_client/templates/apt/preferences.j2 b/roles/borgbackup_client/templates/apt/preferences.j2 new file mode 100644 index 0000000..c4d8784 --- /dev/null +++ b/roles/borgbackup_client/templates/apt/preferences.j2 @@ -0,0 +1,9 @@ +{{ ansible_managed | comment }} + +Package: * +Pin: release n=bullseye +Pin-Priority: 1 + +Package: borgmatic +Pin: release n=bullseye +Pin-Priority: 900