Files
gitlab-mirror/roles/borgmatic/tasks/install.yml
2025-12-12 18:35:37 +03:00

67 lines
1.9 KiB
YAML

---
- name: "Ensure that system dependencies are installed"
ansible.builtin.apt:
name:
- openssh-client
- python3-pip
- python3-venv
state: present
update_cache: true
cache_valid_time: 3600
- name: "Install pipx"
retries: 3
delay: 1
ansible.builtin.pip:
name: "pipx=={{ pipx_version }}"
executable: pip3
break_system_packages: true
- name: "Ensure pipx binary is available in PATH"
changed_when: false
ansible.builtin.command:
cmd: pipx ensurepath
- name: "Install borgmatic via pipx"
retries: 3
delay: 1
environment:
PIPX_BIN_DIR: "{{ borgmatic_pipx_bin_dir }}"
community.general.pipx:
name: borgmatic
state: present
install_deps: true
- name: "Install Borg if the correct version is not available"
block:
# we are looking for Borg installed in a directory that Max Hoesel's role exects to find it
- name: "Get the currently installed version of Borg"
changed_when: false
register: borgmatic_version_installed
ansible.builtin.command:
cmd: /usr/bin/borg --version
- name: "Check that the correct version of Borg is installed"
ansible.builtin.assert:
that: borgmatic_version_installed.stdout.find(borgmatic_version)
fail_msg: "The expected Borg version was not found: {{ borgmatic_version_installed }}"
success_msg: "Found the expected Borg version ({{ borgmatic_version }})"
rescue:
- name: "Download Borg from a custom URL: '{{ borgmatic_binary_url }}'"
retries: 3
delay: 1
ansible.builtin.unarchive:
src: "{{ borgmatic_binary_url }}"
dest: "/opt/"
remote_src: true
owner: root
group: root
mode: "0755"
- name: "Create a symbolic link for Borg"
ansible.builtin.file:
state: link
src: "/opt/borg-dir/borg.exe"
dest: "/usr/bin/borg"