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