Improve borgmatic version handling and fix deprecated options

- Rename templates to version-based naming (config_1.7.yaml.j2)
- Use command module instead of shell for version detection
- Add check_mode: false for version detection task
- Fix deprecated remote_rate_limit → upload_rate_limit for 1.8+

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Manu 2026-01-05 13:15:40 +00:00
parent 0ff3e2f38e
commit 1d16b64d24
3 changed files with 9 additions and 8 deletions

View File

@ -1,14 +1,15 @@
---
- name: Add Borgmatic config file
block:
- name: Register Borgmatic version
ansible.builtin.shell: "borgmatic --version | cut -d\\ -f2"
register: borgmatic_version
changed_when: False
- name: Get Borgmatic version
ansible.builtin.command: borgmatic --version
register: borgmatic_version_output
changed_when: false
check_mode: false
- name: Store Borgmatic version as a fact
ansible.builtin.set_fact:
borgmatic_version: "{{ borgmatic_version.stdout }}"
borgmatic_version: "{{ borgmatic_version_output.stdout.split()[0] }}"
- name: Ensure /etc/borgmatic exists
ansible.builtin.file:
@ -18,9 +19,9 @@
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
- name: Add legacy Borgmatic configuration for versions prior to 1.8.0
- name: Add Borgmatic configuration for versions prior to 1.8.0
ansible.builtin.template:
src: config_legacy.yaml.j2
src: config_1.7.yaml.j2
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
mode: "0600"
owner: "{{ borg_user }}"

View File

@ -85,7 +85,7 @@ compression: {{ borg_compression|default('auto,zstd') }}
# Remote network upload rate limit in kiBytes/second.
{% if borg_remote_rate_limit %}
remote_rate_limit: {{ borg_remote_rate_limit }}
upload_rate_limit: {{ borg_remote_rate_limit }}
{% endif %}
# Command to use instead of just "ssh". This can be used to specify ssh options.