From 8dbec24a3ba0b4eb51d829b0b2f393155cfbf32a Mon Sep 17 00:00:00 2001 From: "pulsar89.5" Date: Mon, 18 Dec 2023 17:12:52 +0100 Subject: [PATCH] feat: Go to pipx --- handlers/main.yml | 2 +- tasks/configuration.yml | 1 + tasks/installation.yml | 40 +++++++++++++++++++++++++++++----------- templates/config.yaml.j2 | 2 ++ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 5218062..72786b9 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -3,7 +3,7 @@ - name: Créer le dépôt ansible.builtin.command: - cmd: borg init -e repokey-blake2 {{ item.path }} + cmd: sudo borgmatic init --encryption repokey become: true loop: "{{ borgmatic_repositories }}" register: borg_init diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 5e8e6f4..ccb6541 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -39,6 +39,7 @@ owner: root group: root mode: u=rw,g=,o= + validate: borgmatic config validate --config %s become: true notify: Créer le dépôt diff --git a/tasks/installation.yml b/tasks/installation.yml index 8774963..3f33b9c 100644 --- a/tasks/installation.yml +++ b/tasks/installation.yml @@ -1,27 +1,45 @@ --- # tasks file for borgmatic -- name: Installer python3-pip +- name: Installer les prérequis ansible.builtin.apt: - name: python3-pip state: latest + name: + - pipx + - build-essential + - libacl1-dev + - libacl1 + - libb2-dev + - liblz4-dev + - libssl-dev + - libzstd-dev + - pkg-config + - python3 + - python3-dev + - python3-pkgconfig become: true -- name: Installer borgbackup - ansible.builtin.apt: - name: borgbackup +- name: Installer les paquets + community.general.pipx: state: latest - default_release: "{{ borgmatic_distribution_release }}-backports" + name: "{{ item }}" + install_deps: true + include_injected: true become: true + environment: + PIPX_HOME: /opt/pipx + PIPX_BIN_DIR: /usr/local/bin + loop: + - borgbackup + - borgmatic -- name: Installer le paquet avec pip - ansible.builtin.pip: - name: borgmatic - state: latest +- name: S'assurer que les paquets sont inclus dans le path + ansible.builtin.command: + cmd: pipx ensurepath become: true - name: Créer l'exemple de configuration ansible.builtin.command: - cmd: generate-borgmatic-config + cmd: borgmatic config generate creates: /etc/borgmatic/config.yaml become: true diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2 index f10c8d6..ded582b 100644 --- a/templates/config.yaml.j2 +++ b/templates/config.yaml.j2 @@ -6,10 +6,12 @@ repositories: path: {{ repository.path }} {% endfor %} +{% if borgmatic_exclude_patterns | length > 0 %} exclude_patterns: {% for pattern in borgmatic_exclude_patterns %} - {{ pattern }} {% endfor %} +{% endif %} source_directories: {% for directory in borgmatic_source_directories %}